diff --git a/aiprompts/config-system.md b/aiprompts/config-system.md index d264e1f7f..65fd996f5 100644 --- a/aiprompts/config-system.md +++ b/aiprompts/config-system.md @@ -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: - -```bash -# Regenerate JSON schema -task build:schema - -# Regenerate TypeScript types -go run cmd/generatets/main-generatets.go -``` +**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 -This will update the schema files and [`frontend/types/gotypes.d.ts`](frontend/types/gotypes.d.ts) with your new settings. +**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. -### 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 diff --git a/docs/docs/config.mdx b/docs/docs/config.mdx index 2eb77ded6..dafd8c99e 100644 --- a/docs/docs/config.mdx +++ b/docs/docs/config.mdx @@ -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) | diff --git a/frontend/app/view/term/term.tsx b/frontend/app/view/term/term.tsx index b232e886a..2656e83aa 100644 --- a/frontend/app/view/term/term.tsx +++ b/frontend/app/view/term/term.tsx @@ -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) => 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) => 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) => scrollback: termScrollback, allowProposedApi: true, // Required by @xterm/addon-search to enable search functionality and decorations ignoreBracketedPasteMode: !termAllowBPM, + macOptionIsMeta: termMacOptionIsMeta, }, { keydownHandler: model.handleTerminalKeydown.bind(model), diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 0842b047f..71cb98225 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -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; diff --git a/package-lock.json b/package-lock.json index 3a7484884..c0827c165 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "waveterm", - "version": "0.12.3", + "version": "0.12.4-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "waveterm", - "version": "0.12.3", + "version": "0.12.4-beta.1", "hasInstallScript": true, "license": "Apache-2.0", "workspaces": [ diff --git a/pkg/waveobj/metaconsts.go b/pkg/waveobj/metaconsts.go index 27b93a95e..801929541 100644 --- a/pkg/waveobj/metaconsts.go +++ b/pkg/waveobj/metaconsts.go @@ -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" diff --git a/pkg/waveobj/wtypemeta.go b/pkg/waveobj/wtypemeta.go index cf45dd61d..efe0a79f1 100644 --- a/pkg/waveobj/wtypemeta.go +++ b/pkg/waveobj/wtypemeta.go @@ -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"` diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go index 40a40ddf8..4a2a37708 100644 --- a/pkg/wconfig/metaconsts.go +++ b/pkg/wconfig/metaconsts.go @@ -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" diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 67aae0a98..4de30cbb6 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -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"` diff --git a/schema/settings.json b/schema/settings.json index e14a53e64..a58b824ea 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -104,6 +104,9 @@ "term:shiftenternewline": { "type": "boolean" }, + "term:macoptionismeta": { + "type": "boolean" + }, "editor:minimapenabled": { "type": "boolean" },