Skip to content

Commit cc51509

Browse files
authored
add new setting term:macoptionismeta (#2589)
1 parent e0ca73a commit cc51509

File tree

9 files changed

+34
-80
lines changed

9 files changed

+34
-80
lines changed

aiprompts/config-system.md

Lines changed: 21 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -152,50 +152,7 @@ type MetaTSType struct {
152152
- JSON tags should exactly match the corresponding settings field
153153
- This enables the hierarchical config system: block metadata → connection config → global settings
154154

155-
### Step 2: Add to JSON Schema
156-
157-
Edit [`schema/settings.json`](schema/settings.json) and add your field to the `properties` section:
158-
159-
```json
160-
{
161-
"$defs": {
162-
"SettingsType": {
163-
"properties": {
164-
// ... existing properties ...
165-
166-
"mynew:setting": {
167-
"type": "string"
168-
},
169-
"mynew:boolsetting": {
170-
"type": "boolean"
171-
},
172-
"mynew:numbersetting": {
173-
"type": "number"
174-
},
175-
"mynew:intsetting": {
176-
"type": "integer"
177-
},
178-
"mynew:arraysetting": {
179-
"items": {
180-
"type": "string"
181-
},
182-
"type": "array"
183-
}
184-
}
185-
}
186-
}
187-
}
188-
```
189-
190-
**Schema Type Mapping:**
191-
192-
- Go `string` → JSON Schema `"string"`
193-
- Go `bool` → JSON Schema `"boolean"`
194-
- Go `float64` → JSON Schema `"number"`
195-
- Go `int64` → JSON Schema `"integer"`
196-
- Go `[]string` → JSON Schema `"array"` with `"items": {"type": "string"}`
197-
198-
### Step 3: Set Default Value (Optional)
155+
### Step 2: Set Default Value (Optional)
199156

200157
If your setting should have a default value, add it to [`pkg/wconfig/defaultconfig/settings.json`](pkg/wconfig/defaultconfig/settings.json):
201158

@@ -218,7 +175,7 @@ If your setting should have a default value, add it to [`pkg/wconfig/defaultconf
218175
- Ensure defaults make sense for the typical user experience
219176
- Keep defaults conservative and safe
220177

221-
### Step 4: Update Documentation
178+
### Step 3: Update Documentation
222179

223180
Add your new setting to the configuration table in [`docs/docs/config.mdx`](docs/docs/config.mdx):
224181

@@ -234,28 +191,23 @@ Add your new setting to the configuration table in [`docs/docs/config.mdx`](docs
234191

235192
Also update the default configuration example in the same file if you added defaults.
236193

237-
### Step 5: Regenerate Schema and TypeScript Types
194+
### Step 4: Regenerate Schema and TypeScript Types
238195

239-
Run the build tasks to regenerate schema and TypeScript types:
196+
Run the generate task to automatically regenerate the JSON schema and TypeScript types:
240197

241198
```bash
242-
task build:schema
243199
task generate
244200
```
245201

246-
Or run them individually:
247-
248-
```bash
249-
# Regenerate JSON schema
250-
task build:schema
251-
252-
# Regenerate TypeScript types
253-
go run cmd/generatets/main-generatets.go
254-
```
202+
**What this does:**
203+
- Runs `task build:schema` (automatically generates JSON schema from Go structs)
204+
- Generates TypeScript type definitions in [`frontend/types/gotypes.d.ts`](frontend/types/gotypes.d.ts)
205+
- Generates RPC client APIs
206+
- Generates metadata constants
255207

256-
This will update the schema files and [`frontend/types/gotypes.d.ts`](frontend/types/gotypes.d.ts) with your new settings.
208+
**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.
257209

258-
### Step 6: Use in Frontend Code
210+
### Step 5: Use in Frontend Code
259211

260212
Access your new setting in React components:
261213

@@ -289,7 +241,7 @@ const appGlobalHotkey = useAtomValue(getSettingsKeyAtom("app:globalhotkey")) ??
289241
const connStatus = useAtomValue(getConnStatusAtom(connectionName));
290242
```
291243

292-
### Step 7: Use in Backend Code
244+
### Step 6: Use in Backend Code
293245

294246
Access settings in Go code:
295247

@@ -344,7 +296,7 @@ await RpcApi.SetMetaCommand(TabRpcClient, {
344296

345297
## Example: Adding a New Terminal Setting
346298

347-
Let's walk through adding a new terminal setting `term:bellsound` with block-level override support:
299+
Here's a complete example adding a new terminal setting `term:bellsound` with block-level override support:
348300

349301
### 1. Go Struct (settingsconfig.go)
350302

@@ -364,32 +316,26 @@ type MetaTSType struct {
364316
}
365317
```
366318

367-
### 3. JSON Schema (schema/settings.json)
368-
369-
```json
370-
{
371-
"properties": {
372-
"term:bellsound": {
373-
"type": "string"
374-
}
375-
}
376-
}
377-
```
378-
379-
### 4. Default Value (defaultconfig/settings.json)
319+
### 3. Default Value (defaultconfig/settings.json - optional)
380320

381321
```json
382322
{
383323
"term:bellsound": "default"
384324
}
385325
```
386326

387-
### 5. Documentation (docs/config.mdx)
327+
### 4. Documentation (docs/config.mdx)
388328

389329
```markdown
390330
| term:bellsound | string | Sound to play for terminal bell ("default", "none", or custom sound file path) |
391331
```
392332

333+
### 5. Regenerate Types
334+
335+
```bash
336+
task generate
337+
```
338+
393339
### 6. Frontend Usage
394340

395341
```typescript

docs/docs/config.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ wsh editconfig
6060
| term:transparency | float64 | set the background transparency of terminal theme (default 0.5, 0 = not transparent, 1.0 = fully transparent) |
6161
| term:allowbracketedpaste | bool | allow bracketed paste mode in terminal (default false) |
6262
| 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) |
63+
| term:macoptionismeta | bool | on macOS, treat the Option key as Meta key for terminal keybindings (default false) |
6364
| editor:minimapenabled | bool | set to false to disable editor minimap |
6465
| editor:stickyscrollenabled | bool | enables monaco editor's stickyScroll feature (pinning headers of current context, e.g. class names, method names, etc.), defaults to false |
6566
| editor:wordwrap | bool | set to true to enable word wrapping in the editor (defaults to false) |

frontend/app/view/term/term.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ import "./xterm.css";
2323

2424
const dlog = debug("wave:term");
2525

26-
type InitialLoadDataType = {
27-
loaded: boolean;
28-
heldData: Uint8Array[];
29-
};
30-
3126
interface TerminalViewProps {
3227
blockId: string;
3328
model: TermViewModel;
@@ -251,6 +246,7 @@ const TerminalView = ({ blockId, model }: ViewComponentProps<TermViewModel>) =>
251246
const termThemeName = globalStore.get(model.termThemeNameAtom);
252247
const termTransparency = globalStore.get(model.termTransparencyAtom);
253248
const termBPMAtom = getOverrideConfigAtom(blockId, "term:allowbracketedpaste");
249+
const termMacOptionIsMetaAtom = getOverrideConfigAtom(blockId, "term:macoptionismeta");
254250
const [termTheme, _] = computeTheme(fullConfig, termThemeName, termTransparency);
255251
let termScrollback = 2000;
256252
if (termSettings?.["term:scrollback"]) {
@@ -266,6 +262,7 @@ const TerminalView = ({ blockId, model }: ViewComponentProps<TermViewModel>) =>
266262
termScrollback = 50000;
267263
}
268264
const termAllowBPM = globalStore.get(termBPMAtom) ?? false;
265+
const termMacOptionIsMeta = globalStore.get(termMacOptionIsMetaAtom) ?? false;
269266
const wasFocused = model.termRef.current != null && globalStore.get(model.nodeModel.isFocused);
270267
const termWrap = new TermWrap(
271268
blockId,
@@ -281,6 +278,7 @@ const TerminalView = ({ blockId, model }: ViewComponentProps<TermViewModel>) =>
281278
scrollback: termScrollback,
282279
allowProposedApi: true, // Required by @xterm/addon-search to enable search functionality and decorations
283280
ignoreBracketedPasteMode: !termAllowBPM,
281+
macOptionIsMeta: termMacOptionIsMeta,
284282
},
285283
{
286284
keydownHandler: model.handleTerminalKeydown.bind(model),

frontend/types/gotypes.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ declare global {
873873
"term:transparency"?: number;
874874
"term:allowbracketedpaste"?: boolean;
875875
"term:shiftenternewline"?: boolean;
876+
"term:macoptionismeta"?: boolean;
876877
"term:conndebug"?: string;
877878
"web:zoom"?: number;
878879
"web:hidenav"?: boolean;
@@ -1054,6 +1055,7 @@ declare global {
10541055
"term:transparency"?: number;
10551056
"term:allowbracketedpaste"?: boolean;
10561057
"term:shiftenternewline"?: boolean;
1058+
"term:macoptionismeta"?: boolean;
10571059
"editor:minimapenabled"?: boolean;
10581060
"editor:stickyscrollenabled"?: boolean;
10591061
"editor:wordwrap"?: boolean;

pkg/waveobj/metaconsts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ const (
114114
MetaKey_TermTransparency = "term:transparency"
115115
MetaKey_TermAllowBracketedPaste = "term:allowbracketedpaste"
116116
MetaKey_TermShiftEnterNewline = "term:shiftenternewline"
117+
MetaKey_TermMacOptionIsMeta = "term:macoptionismeta"
117118
MetaKey_TermConnDebug = "term:conndebug"
118119

119120
MetaKey_WebZoom = "web:zoom"

pkg/waveobj/wtypemeta.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ type MetaTSType struct {
118118
TermTransparency *float64 `json:"term:transparency,omitempty"` // default 0.5
119119
TermAllowBracketedPaste *bool `json:"term:allowbracketedpaste,omitempty"`
120120
TermShiftEnterNewline *bool `json:"term:shiftenternewline,omitempty"`
121+
TermMacOptionIsMeta *bool `json:"term:macoptionismeta,omitempty"`
121122
TermConnDebug string `json:"term:conndebug,omitempty"` // null, info, debug
122123

123124
WebZoom float64 `json:"web:zoom,omitempty"`

pkg/wconfig/metaconsts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141
ConfigKey_TermTransparency = "term:transparency"
4242
ConfigKey_TermAllowBracketedPaste = "term:allowbracketedpaste"
4343
ConfigKey_TermShiftEnterNewline = "term:shiftenternewline"
44+
ConfigKey_TermMacOptionIsMeta = "term:macoptionismeta"
4445

4546
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
4647
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"

pkg/wconfig/settingsconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type SettingsType struct {
8787
TermTransparency *float64 `json:"term:transparency,omitempty"`
8888
TermAllowBracketedPaste *bool `json:"term:allowbracketedpaste,omitempty"`
8989
TermShiftEnterNewline *bool `json:"term:shiftenternewline,omitempty"`
90+
TermMacOptionIsMeta *bool `json:"term:macoptionismeta,omitempty"`
9091

9192
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
9293
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`

schema/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
"term:shiftenternewline": {
105105
"type": "boolean"
106106
},
107+
"term:macoptionismeta": {
108+
"type": "boolean"
109+
},
107110
"editor:minimapenabled": {
108111
"type": "boolean"
109112
},

0 commit comments

Comments
 (0)