Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 21 additions & 75 deletions aiprompts/config-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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):

Expand All @@ -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:

Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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)

Expand All @@ -364,32 +316,26 @@ 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
{
"term:bellsound": "default"
}
```

### 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
Expand Down
1 change: 1 addition & 0 deletions docs/docs/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
8 changes: 3 additions & 5 deletions frontend/app/view/term/term.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import "./xterm.css";

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

type InitialLoadDataType = {
loaded: boolean;
heldData: Uint8Array[];
};

interface TerminalViewProps {
blockId: string;
model: TermViewModel;
Expand Down Expand Up @@ -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"]) {
Expand All @@ -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,
Expand All @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/waveobj/metaconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions pkg/waveobj/wtypemeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions pkg/wconfig/metaconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions pkg/wconfig/settingsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 3 additions & 0 deletions schema/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
"term:shiftenternewline": {
"type": "boolean"
},
"term:macoptionismeta": {
"type": "boolean"
},
"editor:minimapenabled": {
"type": "boolean"
},
Expand Down
Loading