Skip to content

Commit 98431ff

Browse files
committed
Merge remote-tracking branch 'origin/main' into sawka/wave-12
2 parents 5e1e401 + 5165e72 commit 98431ff

78 files changed

Lines changed: 2034 additions & 1437 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/bump-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- name: Get App Token
32-
uses: actions/create-github-app-token@v1
32+
uses: actions/create-github-app-token@v2
3333
id: app-token
3434
with:
3535
app-id: ${{ vars.WAVE_BUILDER_APPID }}

.roo/rules/rules.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The frontend uses yarn (berry).
4444

4545
### Styling
4646

47-
- We use tailwind v4 to style. Custom stuff is defined in tailwindsetup.css.
47+
- We use **Tailwind v4** to style. Custom stuff is defined in frontend/tailwindsetup.css
4848
- _never_ use cursor-help (it looks terrible)
4949
- We have custom CSS setup as well, so it is a hybrid system. For new code we prefer tailwind, and are working to migrate code to all use tailwind.
5050

@@ -53,14 +53,16 @@ The frontend uses yarn (berry).
5353
- **TypeScript Types**: TypeScript types are automatically generated from Go types. After modifying Go types in `pkg/wshrpc/wshrpctypes.go`, run `task generate` to update the TypeScript type definitions in `frontend/types/gotypes.d.ts`.
5454
- **Manual Edits**: Do not manually edit generated files like `frontend/types/gotypes.d.ts` or `frontend/app/store/wshclientapi.ts`. Instead, modify the source Go types and run `task generate`.
5555

56-
### Documentation References
56+
### Development Documentation
5757

58-
Found in /aiprompts
58+
The `/aiprompts` directory contains comprehensive guides for common development tasks:
5959

60-
- config-system.md -- for help with adding new config or settings values
61-
- contextmenu.md
62-
- getsetconfigvar.md
63-
- view-prompt.md -- view model guide
60+
- **config-system.md** - Complete guide for adding new configuration settings, including the hierarchical config system with global, connection, and block-level overrides
61+
- **contextmenu.md** - Instructions for adding context menu items and actions
62+
- **getsetconfigvar.md** - Reference for reading and writing configuration values programmatically
63+
- **view-prompt.md** - Architecture guide for implementing new view models and components
64+
65+
These files provide step-by-step instructions, code examples, and best practices for extending Wave Terminal's functionality.
6466

6567
### Frontend Architecture
6668

Taskfile.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ tasks:
110110
package:
111111
desc: Package the application for the current platform.
112112
cmds:
113-
- cmd: '{{.RMRF}} "make"'
114-
ignore_error: true
115113
- yarn build:prod && yarn electron-builder -c electron-builder.config.cjs -p never {{.CLI_ARGS}}
116114
deps:
115+
- clean
117116
- yarn
118117
- docsite:build:embedded
119118
- build:backend
@@ -267,6 +266,8 @@ tasks:
267266
sources:
268267
- "cmd/wsh/**/*.go"
269268
- "pkg/**/*.go"
269+
generates:
270+
- "dist/bin/wsh*"
270271

271272
build:wsh:internal:
272273
vars:
@@ -429,3 +430,11 @@ tasks:
429430
desc: Recursively copy directory and its contents.
430431
internal: true
431432
cmd: '{{if eq OS "windows"}}powershell Copy-Item -Recurse -Force -Path {{index .MATCH 0}} -Destination {{index .MATCH 1}}{{else}}mkdir -p "$(dirname {{index .MATCH 1}})" && cp -r {{index .MATCH 0}} {{index .MATCH 1}}{{end}}'
433+
434+
clean:
435+
desc: clean make/dist directories
436+
cmds:
437+
- cmd: '{{.RMRF}} "make"'
438+
ignore_error: true
439+
- cmd: '{{.RMRF}} "dist"'
440+
ignore_error: true

aiprompts/config-system.md

Lines changed: 111 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ waveterm/
4141
```
4242

4343
**Key Files:**
44+
4445
- **[`pkg/wconfig/settingsconfig.go`](pkg/wconfig/settingsconfig.go)** - Defines the `SettingsType` struct with all configuration fields
4546
- **[`schema/settings.json`](schema/settings.json)** - JSON Schema for validation and type checking
4647
- **[`pkg/wconfig/defaultconfig/settings.json`](pkg/wconfig/defaultconfig/settings.json)** - Default values for all settings
@@ -56,6 +57,38 @@ waveterm/
5657

5758
Settings cascade from defaults → user settings → block overrides.
5859

60+
### Block-Level Metadata Override System
61+
62+
Wave Terminal supports block-level configuration overrides through the metadata system. This allows settings to be applied globally, per-connection, or per-block:
63+
64+
1. **Global Settings** (`~/.config/waveterm/settings.json`) - Apply to all blocks by default
65+
2. **Connection Settings** (in connections config) - Apply to all blocks using a specific connection
66+
3. **Block Metadata** - Override settings for individual blocks
67+
68+
**Key Files for Block Overrides:**
69+
70+
- **[`pkg/waveobj/wtypemeta.go`](pkg/waveobj/wtypemeta.go)** - Defines the `MetaTSType` struct for block-level metadata
71+
- Block metadata fields should match the corresponding settings fields for consistency
72+
73+
**Frontend Usage:**
74+
75+
```typescript
76+
// Use getOverrideConfigAtom for hierarchical config resolution
77+
const settingValue = useAtomValue(getOverrideConfigAtom(blockId, "namespace:setting"));
78+
79+
// This automatically resolves in order: block metadata → connection config → global settings → default
80+
```
81+
82+
**Setting Block Metadata:**
83+
84+
```bash
85+
# Set for current block
86+
wsh setmeta namespace:setting=value
87+
88+
# Set for specific block
89+
wsh setmeta --block BLOCK_ID namespace:setting=value
90+
```
91+
5992
## How to Add a New Configuration Value
6093

6194
Follow these steps to add a new configuration setting:
@@ -94,6 +127,31 @@ type SettingsType struct {
94127
- Use `[]string` for arrays
95128
- Use `float64` for numbers that can be decimals
96129

130+
### Step 1.5: Add to Block Metadata (Optional)
131+
132+
If your setting should support block-level overrides, also add it to [`pkg/waveobj/wtypemeta.go`](pkg/waveobj/wtypemeta.go):
133+
134+
```go
135+
type MetaTSType struct {
136+
// ... existing fields ...
137+
138+
// Add your new field with matching JSON tag and type
139+
MyNewSetting *string `json:"mynew:setting,omitempty"` // Use pointer for optional values
140+
141+
// For different types:
142+
MyBoolSetting *bool `json:"mynew:boolsetting,omitempty"`
143+
MyNumberSetting *float64 `json:"mynew:numbersetting,omitempty"`
144+
MyIntSetting *int `json:"mynew:intsetting,omitempty"`
145+
MyArraySetting []string `json:"mynew:arraysetting,omitempty"`
146+
}
147+
```
148+
149+
**Block Metadata Guidelines:**
150+
151+
- Use pointer types (`*string`, `*bool`, `*int`, `*float64`) for optional overrides
152+
- JSON tags should exactly match the corresponding settings field
153+
- This enables the hierarchical config system: block metadata → connection config → global settings
154+
97155
### Step 2: Add to JSON Schema
98156

99157
Edit [`schema/settings.json`](schema/settings.json) and add your field to the `properties` section:
@@ -144,7 +202,7 @@ If your setting should have a default value, add it to [`pkg/wconfig/defaultconf
144202
```json
145203
{
146204
"ai:preset": "ai@global",
147-
"ai:model": "gpt-4o-mini",
205+
"ai:model": "gpt-5-mini",
148206
// ... existing defaults ...
149207

150208
"mynew:setting": "default value",
@@ -186,6 +244,7 @@ task generate
186244
```
187245

188246
Or run them individually:
247+
189248
```bash
190249
# Regenerate JSON schema
191250
task build:schema
@@ -201,20 +260,35 @@ This will update the schema files and [`frontend/types/gotypes.d.ts`](frontend/t
201260
Access your new setting in React components:
202261

203262
```typescript
204-
import { useSettingsKeyAtom } from "@/app/store/global";
263+
import { getOverrideConfigAtom, useAtomValue } from "@/store/global";
205264

206265
// In a React component
207-
const MyComponent = () => {
208-
// Read global setting with fallback
209-
const mySetting = useSettingsKeyAtom("mynew:setting") ?? "fallback value";
266+
const MyComponent = ({ blockId }: { blockId: string }) => {
267+
// Use override config atom for hierarchical resolution
268+
// This automatically checks: block metadata → connection config → global settings → default
269+
const mySettingAtom = getOverrideConfigAtom(blockId, "mynew:setting");
270+
const mySetting = useAtomValue(mySettingAtom) ?? "fallback value";
210271

211-
// For block-specific overrides
212-
const myBlockSetting = useOverrideConfigAtom(blockId, "mynew:setting") ?? "fallback";
272+
// For global-only settings (no block overrides)
273+
const globalOnlySetting = useAtomValue(getSettingsKeyAtom("mynew:globalsetting")) ?? "fallback";
213274

214275
return <div>Setting value: {mySetting}</div>;
215276
};
216277
```
217278

279+
**Frontend Configuration Patterns:**
280+
281+
```typescript
282+
// 1. Settings with block-level overrides (recommended)
283+
const termFontSize = useAtomValue(getOverrideConfigAtom(blockId, "term:fontsize")) ?? 12;
284+
285+
// 2. Global-only settings
286+
const appGlobalHotkey = useAtomValue(getSettingsKeyAtom("app:globalhotkey")) ?? "";
287+
288+
// 3. Connection-specific settings
289+
const connStatus = useAtomValue(getConnStatusAtom(connectionName));
290+
```
291+
218292
### Step 7: Use in Backend Code
219293

220294
Access settings in Go code:
@@ -270,7 +344,7 @@ await RpcApi.SetMetaCommand(TabRpcClient, {
270344

271345
## Example: Adding a New Terminal Setting
272346

273-
Let's walk through adding a new terminal setting `term:bellsound`:
347+
Let's walk through adding a new terminal setting `term:bellsound` with block-level override support:
274348

275349
### 1. Go Struct (settingsconfig.go)
276350

@@ -281,7 +355,16 @@ type SettingsType struct {
281355
}
282356
```
283357

284-
### 2. JSON Schema (schema/settings.json)
358+
### 2. Block Metadata (wtypemeta.go)
359+
360+
```go
361+
type MetaTSType struct {
362+
// ... existing fields ...
363+
TermBellSound *string `json:"term:bellsound,omitempty"` // Pointer for optional override
364+
}
365+
```
366+
367+
### 3. JSON Schema (schema/settings.json)
285368

286369
```json
287370
{
@@ -293,24 +376,39 @@ type SettingsType struct {
293376
}
294377
```
295378

296-
### 3. Default Value (defaultconfig/settings.json)
379+
### 4. Default Value (defaultconfig/settings.json)
297380

298381
```json
299382
{
300383
"term:bellsound": "default"
301384
}
302385
```
303386

304-
### 4. Documentation (docs/config.mdx)
387+
### 5. Documentation (docs/config.mdx)
305388

306389
```markdown
307390
| term:bellsound | string | Sound to play for terminal bell ("default", "none", or custom sound file path) |
308391
```
309392

310-
### 5. Frontend Usage
393+
### 6. Frontend Usage
311394

312395
```typescript
313-
const bellSound = useOverrideConfigAtom(blockId, "term:bellsound") ?? "default";
396+
// Use override config for hierarchical resolution
397+
const bellSoundAtom = getOverrideConfigAtom(blockId, "term:bellsound");
398+
const bellSound = useAtomValue(bellSoundAtom) ?? "default";
399+
```
400+
401+
### 7. Usage Examples
402+
403+
```bash
404+
# Set globally
405+
wsh setconfig term:bellsound="custom.wav"
406+
407+
# Set for current block only
408+
wsh setmeta term:bellsound="none"
409+
410+
# Set for specific block
411+
wsh setmeta --block BLOCK_ID term:bellsound="beep"
314412
```
315413

316414
## Testing Your Configuration

0 commit comments

Comments
 (0)