add new setting term:macoptionismeta (#2589)

This commit is contained in:
Mike Sawka 2025-11-21 10:54:58 -08:00 committed by GitHub
parent e0ca73ad53
commit cc51509fe7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 34 additions and 80 deletions

View file

@ -152,50 +152,7 @@ type MetaTSType struct {
- JSON tags should exactly match the corresponding settings field
- This enables the hierarchical config system: block metadata → connection config → global settings
### Step 2: Add to JSON Schema
Edit [`schema/settings.json`](schema/settings.json) and add your field to the `properties` section:
```json
{
"$defs": {
"SettingsType": {
"properties": {
// ... existing properties ...
"mynew:setting": {
"type": "string"
},
"mynew:boolsetting": {
"type": "boolean"
},
"mynew:numbersetting": {
"type": "number"
},
"mynew:intsetting": {
"type": "integer"
},
"mynew:arraysetting": {
"items": {
"type": "string"
},
"type": "array"
}
}
}
}
}
```
**Schema Type Mapping:**
- Go `string` → JSON Schema `"string"`
- Go `bool` → JSON Schema `"boolean"`
- Go `float64` → JSON Schema `"number"`
- Go `int64` → JSON Schema `"integer"`
- Go `[]string` → JSON Schema `"array"` with `"items": {"type": "string"}`
### Step 3: Set Default Value (Optional)
### Step 2: Set Default Value (Optional)
If your setting should have a default value, add it to [`pkg/wconfig/defaultconfig/settings.json`](pkg/wconfig/defaultconfig/settings.json):
@ -218,7 +175,7 @@ If your setting should have a default value, add it to [`pkg/wconfig/defaultconf
- Ensure defaults make sense for the typical user experience
- Keep defaults conservative and safe
### Step 4: Update Documentation
### Step 3: Update Documentation
Add your new setting to the configuration table in [`docs/docs/config.mdx`](docs/docs/config.mdx):
@ -234,28 +191,23 @@ Add your new setting to the configuration table in [`docs/docs/config.mdx`](docs
Also update the default configuration example in the same file if you added defaults.
### Step 5: Regenerate Schema and TypeScript Types
### Step 4: Regenerate Schema and TypeScript Types
Run the build tasks to regenerate schema and TypeScript types:
Run the generate task to automatically regenerate the JSON schema and TypeScript types:
```bash
task build:schema
task generate
```
Or run them individually:
**What this does:**
- Runs `task build:schema` (automatically generates JSON schema from Go structs)
- Generates TypeScript type definitions in [`frontend/types/gotypes.d.ts`](frontend/types/gotypes.d.ts)
- Generates RPC client APIs
- Generates metadata constants
```bash
# Regenerate JSON schema
task build:schema
**Note:** The JSON schema in [`schema/settings.json`](schema/settings.json) is **automatically generated** from the Go struct definitions - you don't need to edit it manually.
# Regenerate TypeScript types
go run cmd/generatets/main-generatets.go
```
This will update the schema files and [`frontend/types/gotypes.d.ts`](frontend/types/gotypes.d.ts) with your new settings.
### Step 6: Use in Frontend Code
### Step 5: Use in Frontend Code
Access your new setting in React components:
@ -289,7 +241,7 @@ const appGlobalHotkey = useAtomValue(getSettingsKeyAtom("app:globalhotkey")) ??
const connStatus = useAtomValue(getConnStatusAtom(connectionName));
```
### Step 7: Use in Backend Code
### Step 6: Use in Backend Code
Access settings in Go code:
@ -344,7 +296,7 @@ await RpcApi.SetMetaCommand(TabRpcClient, {
## Example: Adding a New Terminal Setting
Let's walk through adding a new terminal setting `term:bellsound` with block-level override support:
Here's a complete example adding a new terminal setting `term:bellsound` with block-level override support:
### 1. Go Struct (settingsconfig.go)
@ -364,19 +316,7 @@ type MetaTSType struct {
}
```
### 3. JSON Schema (schema/settings.json)
```json
{
"properties": {
"term:bellsound": {
"type": "string"
}
}
}
```
### 4. Default Value (defaultconfig/settings.json)
### 3. Default Value (defaultconfig/settings.json - optional)
```json
{
@ -384,12 +324,18 @@ type MetaTSType struct {
}
```
### 5. Documentation (docs/config.mdx)
### 4. Documentation (docs/config.mdx)
```markdown
| term:bellsound | string | Sound to play for terminal bell ("default", "none", or custom sound file path) |
```
### 5. Regenerate Types
```bash
task generate
```
### 6. Frontend Usage
```typescript

View file

@ -60,6 +60,7 @@ wsh editconfig
| term:transparency | float64 | set the background transparency of terminal theme (default 0.5, 0 = not transparent, 1.0 = fully transparent) |
| term:allowbracketedpaste | bool | allow bracketed paste mode in terminal (default false) |
| term:shiftenternewline | bool | when enabled, Shift+Enter sends escape sequence + newline (\u001b\n) instead of carriage return, useful for claude code and similar AI coding tools (default false) |
| term:macoptionismeta | bool | on macOS, treat the Option key as Meta key for terminal keybindings (default false) |
| editor:minimapenabled | bool | set to false to disable editor minimap |
| editor:stickyscrollenabled | bool | enables monaco editor's stickyScroll feature (pinning headers of current context, e.g. class names, method names, etc.), defaults to false |
| editor:wordwrap | bool | set to true to enable word wrapping in the editor (defaults to false) |

View file

@ -23,11 +23,6 @@ import "./xterm.css";
const dlog = debug("wave:term");
type InitialLoadDataType = {
loaded: boolean;
heldData: Uint8Array[];
};
interface TerminalViewProps {
blockId: string;
model: TermViewModel;
@ -251,6 +246,7 @@ const TerminalView = ({ blockId, model }: ViewComponentProps<TermViewModel>) =>
const termThemeName = globalStore.get(model.termThemeNameAtom);
const termTransparency = globalStore.get(model.termTransparencyAtom);
const termBPMAtom = getOverrideConfigAtom(blockId, "term:allowbracketedpaste");
const termMacOptionIsMetaAtom = getOverrideConfigAtom(blockId, "term:macoptionismeta");
const [termTheme, _] = computeTheme(fullConfig, termThemeName, termTransparency);
let termScrollback = 2000;
if (termSettings?.["term:scrollback"]) {
@ -266,6 +262,7 @@ const TerminalView = ({ blockId, model }: ViewComponentProps<TermViewModel>) =>
termScrollback = 50000;
}
const termAllowBPM = globalStore.get(termBPMAtom) ?? false;
const termMacOptionIsMeta = globalStore.get(termMacOptionIsMetaAtom) ?? false;
const wasFocused = model.termRef.current != null && globalStore.get(model.nodeModel.isFocused);
const termWrap = new TermWrap(
blockId,
@ -281,6 +278,7 @@ const TerminalView = ({ blockId, model }: ViewComponentProps<TermViewModel>) =>
scrollback: termScrollback,
allowProposedApi: true, // Required by @xterm/addon-search to enable search functionality and decorations
ignoreBracketedPasteMode: !termAllowBPM,
macOptionIsMeta: termMacOptionIsMeta,
},
{
keydownHandler: model.handleTerminalKeydown.bind(model),

View file

@ -873,6 +873,7 @@ declare global {
"term:transparency"?: number;
"term:allowbracketedpaste"?: boolean;
"term:shiftenternewline"?: boolean;
"term:macoptionismeta"?: boolean;
"term:conndebug"?: string;
"web:zoom"?: number;
"web:hidenav"?: boolean;
@ -1054,6 +1055,7 @@ declare global {
"term:transparency"?: number;
"term:allowbracketedpaste"?: boolean;
"term:shiftenternewline"?: boolean;
"term:macoptionismeta"?: boolean;
"editor:minimapenabled"?: boolean;
"editor:stickyscrollenabled"?: boolean;
"editor:wordwrap"?: boolean;

View file

@ -114,6 +114,7 @@ const (
MetaKey_TermTransparency = "term:transparency"
MetaKey_TermAllowBracketedPaste = "term:allowbracketedpaste"
MetaKey_TermShiftEnterNewline = "term:shiftenternewline"
MetaKey_TermMacOptionIsMeta = "term:macoptionismeta"
MetaKey_TermConnDebug = "term:conndebug"
MetaKey_WebZoom = "web:zoom"

View file

@ -118,6 +118,7 @@ type MetaTSType struct {
TermTransparency *float64 `json:"term:transparency,omitempty"` // default 0.5
TermAllowBracketedPaste *bool `json:"term:allowbracketedpaste,omitempty"`
TermShiftEnterNewline *bool `json:"term:shiftenternewline,omitempty"`
TermMacOptionIsMeta *bool `json:"term:macoptionismeta,omitempty"`
TermConnDebug string `json:"term:conndebug,omitempty"` // null, info, debug
WebZoom float64 `json:"web:zoom,omitempty"`

View file

@ -41,6 +41,7 @@ const (
ConfigKey_TermTransparency = "term:transparency"
ConfigKey_TermAllowBracketedPaste = "term:allowbracketedpaste"
ConfigKey_TermShiftEnterNewline = "term:shiftenternewline"
ConfigKey_TermMacOptionIsMeta = "term:macoptionismeta"
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"

View file

@ -87,6 +87,7 @@ type SettingsType struct {
TermTransparency *float64 `json:"term:transparency,omitempty"`
TermAllowBracketedPaste *bool `json:"term:allowbracketedpaste,omitempty"`
TermShiftEnterNewline *bool `json:"term:shiftenternewline,omitempty"`
TermMacOptionIsMeta *bool `json:"term:macoptionismeta,omitempty"`
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`

View file

@ -104,6 +104,9 @@
"term:shiftenternewline": {
"type": "boolean"
},
"term:macoptionismeta": {
"type": "boolean"
},
"editor:minimapenabled": {
"type": "boolean"
},