Skip to content

Change presets/bg.json => backgrounds.json, migrate, change tab background to tab:background key#3108

Open
sawka wants to merge 11 commits intomainfrom
sawka/no-config-dirs
Open

Change presets/bg.json => backgrounds.json, migrate, change tab background to tab:background key#3108
sawka wants to merge 11 commits intomainfrom
sawka/no-config-dirs

Conversation

@sawka
Copy link
Member

@sawka sawka commented Mar 24, 2026

also fixes aipanel's border colors

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 854d4f0d-10da-454e-a976-d67d10cc71d6

📥 Commits

Reviewing files that changed from the base of the PR and between 49f5f9e and 3150e03.

📒 Files selected for processing (5)
  • cmd/generateschema/main-generateschema.go
  • frontend/app/view/codeeditor/codeeditor.tsx
  • frontend/app/view/waveconfig/waveconfig.tsx
  • schema/backgrounds.json
  • schema/widgets.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • schema/backgrounds.json
  • frontend/app/view/waveconfig/waveconfig.tsx

Walkthrough

Replaces the preset-based background system with a dedicated backgrounds system: adds BackgroundConfigType and a new "tab:background" settings/meta key, provides MigratePresetsBackgrounds() to move bg@ entries into backgrounds.json, ships a default backgrounds.json and clears old presets.json. Introduces MetaKeyAtomFnType (renamed from BlockMetaKeyAtomFnType), adds WaveEnv APIs getTabMetaKeyAtom and getConfigBackgroundAtom with implementations and mock support, updates frontend hooks/components to resolve tab backgrounds/border colors, extends schemas/types, updates CLI setbg flags/validation, and refreshes docs and editor schemas.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.06% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: renaming presets/bg.json to backgrounds.json, implementing migration logic, and introducing the tab:background key.
Description check ✅ Passed The description relates to the changeset by mentioning the AIPanel border color fix, which is corroborated by the aipanel.tsx changes in the raw summary.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sawka/no-config-dirs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 24, 2026

Code Review Summary

Status: 1 Minor Issue | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
frontend/app/aipanel/aipanel.tsx 268 Type signature accepts `string
Other Observations
  • Migration function MigratePresetsBackgrounds() correctly checks if backgrounds.json exists before migrating
  • Border color CLI flags implementation with proper validation looks correct
  • Type consolidation from BlockMetaKeyAtomFnType to MetaKeyAtomFnType is consistent
Files Reviewed (41 files)
  • .kilocode/skills/waveenv/SKILL.md - WaveEnv type updates
  • cmd/generateschema/main-generateschema.go - Schema file renames
  • cmd/server/main-server.go - Migration function call
  • cmd/wsh/cmd/wshcmd-setbg.go - New border-color flags
  • docs/docs/config.mdx - Deprecation badges
  • docs/docs/customization.mdx - Updated references
  • docs/docs/presets.mdxtab-backgrounds.mdx - File renamed
  • docs/src/components/versionbadge.tsx - Added DeprecatedBadge
  • frontend/app/aipanel/aipanel.tsx - Border color integration
  • frontend/app/app-bg.tsx - Background config resolution
  • frontend/app/block/blockenv.ts - Type updates
  • frontend/app/block/blockframe.tsx - useTabBackground usage
  • frontend/app/block/blockutil.tsx - New useTabBackground hook
  • frontend/app/store/global.ts - New exports
  • frontend/app/tab/tabcontextmenu.ts - Backgrounds menu updates
  • pkg/wconfig/settingsconfig.go - BackgroundConfigType, migration logic
  • Plus 24 other modified files

Reviewed by minimax-m2.5-20260211


Reviewed by minimax-m2.5-20260211 · 322,645 tokens

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
docs/src/components/versionbadge.css (1)

24-41: LGTM with optional refactor suggestion.

The .deprecated-badge styling is well-implemented with appropriate gray colors for deprecation semantics and proper dark mode support.

The styling properties are largely duplicated from .version-badge. If more badge variants are added in the future, consider extracting common properties to a shared base class, but this is not necessary for the current scope.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/src/components/versionbadge.css` around lines 24 - 41, The
.deprecated-badge rules duplicate many properties from .version-badge; refactor
by extracting shared declarations (display, padding, margin-left, font-size,
font-weight, line-height, border-radius, vertical-align, white-space) into a
common base class (e.g., .badge or .base-badge) and have .version-badge and
.deprecated-badge extend/override only the variant-specific properties like
background-color and color (including the [data-theme="dark"] overrides) to
reduce duplication and make future badge variants easier to add.
cmd/generateschema/main-generateschema.go (1)

188-192: Consider updating the error message for consistency.

The schema generation now uses BackgroundConfigType and backgrounds.json, but the error message still references "bg presets". This is a minor inconsistency.

🧹 Suggested fix
 	bgPresetsTemplate := make(map[string]wconfig.BackgroundConfigType)
 	err = generateSchema(&bgPresetsTemplate, WaveSchemaBackgroundsFileName)
 	if err != nil {
-		log.Fatalf("bg presets schema error: %v", err)
+		log.Fatalf("backgrounds schema error: %v", err)
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/generateschema/main-generateschema.go` around lines 188 - 192, The log
message "bg presets schema error" is inconsistent with the types and filename;
update the error message in the generateSchema call handling to reference
BackgroundConfigType/WaveSchemaBackgroundsFileName (e.g., "backgrounds schema
error" or "backgrounds.json schema error") so it matches bgPresetsTemplate,
BackgroundConfigType and WaveSchemaBackgroundsFileName; locate the block using
bgPresetsTemplate and generateSchema and replace the log.Fatalf message
accordingly.
frontend/app/aipanel/aipanel.tsx (1)

29-29: Minor: Trailing whitespace detected.

There appears to be trailing whitespace (tab character) at the end of this import line.

🧹 Proposed fix
-import { BYOKAnnouncement } from "./byokannouncement";	
+import { BYOKAnnouncement } from "./byokannouncement";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/app/aipanel/aipanel.tsx` at line 29, The import line importing
BYOKAnnouncement from "./byokannouncement" contains trailing whitespace (a tab)
at the end; remove the trailing whitespace character so the line reads exactly:
import { BYOKAnnouncement } from "./byokannouncement"; and run the project's
formatter or linter to ensure no other trailing whitespace remains.
cmd/wsh/cmd/wshcmd-setbg.go (1)

127-132: Consider removing duplicate border color assignment.

Border color metadata is set twice: once inside the no-args branch (lines 127-132) and again unconditionally after both branches (lines 198-203). Since lines 198-203 always execute, the assignment at lines 127-132 is redundant.

♻️ Proposed fix to remove duplication
 		if setBgClear {
 			meta["bg:*"] = true
 		} else if cmd.Flags().Changed("opacity") {
 			meta["bg:opacity"] = setBgOpacity
 		}
-		if borderColorChanged {
-			meta["bg:bordercolor"] = setBgBorderColor
-		}
-		if activeBorderColorChanged {
-			meta["bg:activebordercolor"] = setBgActiveBorderColor
-		}
 	} else if len(args) > 1 {

Also applies to: 198-203

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/wsh/cmd/wshcmd-setbg.go` around lines 127 - 132, In the no-args branch of
the set-bg command you currently assign meta["bg:bordercolor"] =
setBgBorderColor and meta["bg:activebordercolor"] = setBgActiveBorderColor
guarded by borderColorChanged and activeBorderColorChanged, but those same
assignments are always applied later unconditionally; remove the guarded
assignments in the no-args branch (references: meta map, setBgBorderColor,
setBgActiveBorderColor, borderColorChanged, activeBorderColorChanged, function
handling the no-args set-bg path) so the metadata is only set once by the later
unconditional block.
frontend/types/gotypes.d.ts (1)

111-120: Minor documentation/type discrepancy: display:name optionality.

The documentation states that display:name is "required" for background entries, but the TypeScript type defines it as optional ("display:name"?: string). Since this is a generated file from Go types, this may be intentional to allow flexibility during migration or for internal use. Just flagging for awareness.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/types/gotypes.d.ts` around lines 111 - 120, The type for
BackgroundConfigType declares "display:name" as optional but the docs state it
is required; update the generated Go->TS mapping so BackgroundConfigType's
"display:name" property is non-optional (remove the optional marker for
"display:name") to match documentation, ensuring the generator that produces
this file (or the Go struct tags) is adjusted accordingly; reference the
BackgroundConfigType type and the "display:name" property when making the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/app/aipanel/aipanel.tsx`:
- Line 268: The caller passes tabModel?.tabId which can be undefined but
useTabBackground currently types tabId as string | null; update useTabBackground
to explicitly handle undefined or accept it in the signature: change the
parameter type to tabId: string | null | undefined OR add an early guard in
useTabBackground that maps undefined -> null (or returns safe defaults) before
calling waveEnv.getTabMetaKeyAtom; reference useTabBackground, useTabModelMaybe
(source of tabModel?.tabId), and waveEnv.getTabMetaKeyAtom to ensure atoms are
always invoked with a value the implementation expects and avoid relying on
implicit conversion via makeORef.

---

Nitpick comments:
In `@cmd/generateschema/main-generateschema.go`:
- Around line 188-192: The log message "bg presets schema error" is inconsistent
with the types and filename; update the error message in the generateSchema call
handling to reference BackgroundConfigType/WaveSchemaBackgroundsFileName (e.g.,
"backgrounds schema error" or "backgrounds.json schema error") so it matches
bgPresetsTemplate, BackgroundConfigType and WaveSchemaBackgroundsFileName;
locate the block using bgPresetsTemplate and generateSchema and replace the
log.Fatalf message accordingly.

In `@cmd/wsh/cmd/wshcmd-setbg.go`:
- Around line 127-132: In the no-args branch of the set-bg command you currently
assign meta["bg:bordercolor"] = setBgBorderColor and
meta["bg:activebordercolor"] = setBgActiveBorderColor guarded by
borderColorChanged and activeBorderColorChanged, but those same assignments are
always applied later unconditionally; remove the guarded assignments in the
no-args branch (references: meta map, setBgBorderColor, setBgActiveBorderColor,
borderColorChanged, activeBorderColorChanged, function handling the no-args
set-bg path) so the metadata is only set once by the later unconditional block.

In `@docs/src/components/versionbadge.css`:
- Around line 24-41: The .deprecated-badge rules duplicate many properties from
.version-badge; refactor by extracting shared declarations (display, padding,
margin-left, font-size, font-weight, line-height, border-radius, vertical-align,
white-space) into a common base class (e.g., .badge or .base-badge) and have
.version-badge and .deprecated-badge extend/override only the variant-specific
properties like background-color and color (including the [data-theme="dark"]
overrides) to reduce duplication and make future badge variants easier to add.

In `@frontend/app/aipanel/aipanel.tsx`:
- Line 29: The import line importing BYOKAnnouncement from "./byokannouncement"
contains trailing whitespace (a tab) at the end; remove the trailing whitespace
character so the line reads exactly: import { BYOKAnnouncement } from
"./byokannouncement"; and run the project's formatter or linter to ensure no
other trailing whitespace remains.

In `@frontend/types/gotypes.d.ts`:
- Around line 111-120: The type for BackgroundConfigType declares "display:name"
as optional but the docs state it is required; update the generated Go->TS
mapping so BackgroundConfigType's "display:name" property is non-optional
(remove the optional marker for "display:name") to match documentation, ensuring
the generator that produces this file (or the Go struct tags) is adjusted
accordingly; reference the BackgroundConfigType type and the "display:name"
property when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 588e5daf-017e-4e49-9bce-2fc87f4c12ef

📥 Commits

Reviewing files that changed from the base of the PR and between 2b11043 and f8d461d.

📒 Files selected for processing (40)
  • .kilocode/skills/waveenv/SKILL.md
  • cmd/generateschema/main-generateschema.go
  • cmd/server/main-server.go
  • cmd/wsh/cmd/wshcmd-setbg.go
  • docs/docs/config.mdx
  • docs/docs/customization.mdx
  • docs/docs/releasenotes.mdx
  • docs/docs/tab-backgrounds.mdx
  • docs/docs/wsh-reference.mdx
  • docs/src/components/versionbadge.css
  • docs/src/components/versionbadge.tsx
  • frontend/app/aipanel/aipanel.tsx
  • frontend/app/app-bg.tsx
  • frontend/app/block/blockenv.ts
  • frontend/app/block/blockframe.tsx
  • frontend/app/block/blockutil.tsx
  • frontend/app/monaco/schemaendpoints.ts
  • frontend/app/store/global.ts
  • frontend/app/tab/tabcontextmenu.ts
  • frontend/app/view/sysinfo/sysinfo.tsx
  • frontend/app/view/term/fitaddon.ts
  • frontend/app/view/waveconfig/waveconfig-model.ts
  • frontend/app/view/waveconfig/waveconfig.tsx
  • frontend/app/view/waveconfig/waveconfigenv.ts
  • frontend/app/view/webview/webviewenv.ts
  • frontend/app/waveenv/waveenv.ts
  • frontend/app/waveenv/waveenvimpl.ts
  • frontend/preview/mock/defaultconfig.ts
  • frontend/preview/mock/mockwaveenv.ts
  • frontend/types/gotypes.d.ts
  • pkg/waveobj/metaconsts.go
  • pkg/waveobj/wtypemeta.go
  • pkg/wconfig/defaultconfig/backgrounds.json
  • pkg/wconfig/defaultconfig/presets.json
  • pkg/wconfig/metaconsts.go
  • pkg/wconfig/settingsconfig.go
  • pkg/wcore/workspace.go
  • schema/backgrounds.json
  • schema/settings.json
  • tsconfig.json

const telemetryEnabled = jotai.useAtomValue(getSettingsKeyAtom("telemetry:enabled")) ?? false;
const isPanelVisible = jotai.useAtomValue(model.getPanelVisibleAtom());
const tabModel = useTabModelMaybe();
const [tabBorderColor, tabActiveBorderColor] = useTabBackground(waveEnv, tabModel?.tabId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check useTabBackground implementation for undefined tabId handling

# Find and display the useTabBackground hook implementation
ast-grep --pattern $'function useTabBackground($_, $_) {
  $$$
}'

# Also search with export pattern
rg -nA 20 'export function useTabBackground'

Repository: wavetermdev/waveterm

Length of output: 1974


🏁 Script executed:

#!/bin/bash
# Check how getTabMetaKeyAtom and getConfigBackgroundAtom handle null/undefined
rg -nA 10 'getTabMetaKeyAtom' frontend/app/block/blockutil.tsx

Repository: wavetermdev/waveterm

Length of output: 1412


🏁 Script executed:

#!/bin/bash
# Find the TabBackgroundEnv type definition to understand the atom methods
rg -nB 3 'getTabMetaKeyAtom|getConfigBackgroundAtom' frontend/app/block/blockutil.tsx | head -50

Repository: wavetermdev/waveterm

Length of output: 851


🏁 Script executed:

#!/bin/bash
# Check the actual usage at aipanel.tsx line 268
sed -n '265,275p' frontend/app/aipanel/aipanel.tsx

Repository: wavetermdev/waveterm

Length of output: 796


🏁 Script executed:

#!/bin/bash
# Search for MetaKeyAtomFnType definition
rg -nB 5 'type MetaKeyAtomFnType' --type typescript

Repository: wavetermdev/waveterm

Length of output: 98


🏁 Script executed:

#!/bin/bash
# Search for WaveEnv type definition and getTabMetaKeyAtom
rg -nA 15 'export type WaveEnv' | head -80

Repository: wavetermdev/waveterm

Length of output: 1998


🏁 Script executed:

#!/bin/bash
# Look for getTabMetaKeyAtom implementation
rg -n 'getTabMetaKeyAtom.*=' --type typescript | head -20

Repository: wavetermdev/waveterm

Length of output: 98


🏁 Script executed:

#!/bin/bash
# Search for MetaKeyAtomFnType definition
rg -n 'MetaKeyAtomFnType' frontend/

Repository: wavetermdev/waveterm

Length of output: 1779


🏁 Script executed:

#!/bin/bash
# Search for getTabMetaKeyAtom implementation
rg -n 'getTabMetaKeyAtom' frontend/app/waveenv/

Repository: wavetermdev/waveterm

Length of output: 268


🏁 Script executed:

#!/bin/bash
# Check if useTabModelMaybe can return undefined tabId
rg -nA 10 'useTabModelMaybe'

Repository: wavetermdev/waveterm

Length of output: 2318


🏁 Script executed:

#!/bin/bash
# Get the full MetaKeyAtomFnType definition
sed -n '9,15p' frontend/app/waveenv/waveenv.ts

Repository: wavetermdev/waveterm

Length of output: 343


🏁 Script executed:

#!/bin/bash
# Check TabModel type definition
rg -nA 20 'export type TabModel' frontend/app/store/tab-model.ts | head -40

Repository: wavetermdev/waveterm

Length of output: 866


🏁 Script executed:

#!/bin/bash
# Check the getTabMetaKeyAtom implementation in waveenvimpl.ts
rg -nB 5 -A 20 'getTabMetaKeyAtom' frontend/app/waveenv/waveenvimpl.ts | head -50

Repository: wavetermdev/waveterm

Length of output: 1420


🏁 Script executed:

#!/bin/bash
# Find the getTabMetaKeyAtom implementation in global store
rg -n 'export.*getTabMetaKeyAtom' frontend/app/store/

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Search for getTabMetaKeyAtom definition
rg -nB 3 -A 10 'const getTabMetaKeyAtom' frontend/

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Check what happens when null/undefined is passed to getTabMetaKeyAtom
# Look for its implementation in global.ts
rg -nB 5 -A 15 'getTabMetaKeyAtom.*=' frontend/app/store/global.ts

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# List all files in the store directory
ls -la frontend/app/store/

Repository: wavetermdev/waveterm

Length of output: 1868


🏁 Script executed:

#!/bin/bash
# Search for getTabMetaKeyAtom more broadly
rg 'getTabMetaKeyAtom' frontend/app/store/ -l

Repository: wavetermdev/waveterm

Length of output: 92


🏁 Script executed:

#!/bin/bash
# Try searching in global.ts directly
head -100 frontend/app/store/global.ts | tail -80

Repository: wavetermdev/waveterm

Length of output: 2809


🏁 Script executed:

#!/bin/bash
# Search for getTabMetaKeyAtom in global.ts
rg -n 'getTabMetaKeyAtom' frontend/app/store/global.ts

Repository: wavetermdev/waveterm

Length of output: 191


🏁 Script executed:

#!/bin/bash
# Get the content around getTabMetaKeyAtom in global.ts
rg -n -B 3 -A 15 'export const getTabMetaKeyAtom' frontend/app/store/global.ts

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# If not found, search in global-atoms.ts
rg -n -B 3 -A 15 'getTabMetaKeyAtom' frontend/app/store/global-atoms.ts

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Get the full implementation of getTabMetaKeyAtom
sed -n '135,155p' frontend/app/store/global.ts

Repository: wavetermdev/waveterm

Length of output: 849


🏁 Script executed:

#!/bin/bash
# Check how orefAtomCache works - is it null/undefined safe?
rg -n -B 5 -A 10 'orefAtomCache' frontend/app/store/global-atoms.ts | head -50

Repository: wavetermdev/waveterm

Length of output: 1131


🏁 Script executed:

#!/bin/bash
# Check WOS.makeORef implementation
rg -n -A 5 'function makeORef\|export.*makeORef' frontend/app/store/wos.ts

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Check if undefined gets converted to string somewhere
sed -n '1,50p' frontend/app/store/wos.ts

Repository: wavetermdev/waveterm

Length of output: 1422


🏁 Script executed:

#!/bin/bash
# Search for makeORef in wos.ts
rg -n 'makeORef' frontend/app/store/wos.ts

Repository: wavetermdev/waveterm

Length of output: 252


🏁 Script executed:

#!/bin/bash
# Get more context around the oref building
sed -n '1,150p' frontend/app/store/wos.ts | tail -100

Repository: wavetermdev/waveterm

Length of output: 3566


🏁 Script executed:

#!/bin/bash
# Check getSingleOrefAtomCache implementation
rg -n -A 10 'function getSingleOrefAtomCache' frontend/app/store/global.ts

Repository: wavetermdev/waveterm

Length of output: 575


🏁 Script executed:

#!/bin/bash
# Check if getWaveObjectAtom handles null oref safely
rg -n -B 3 -A 10 'export function getWaveObjectAtom\|export const getWaveObjectAtom' frontend/app/store/wos.ts

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Check the actual return values from useTabBackground - what happens when things are undefined
sed -n '169,180p' frontend/app/block/blockutil.tsx

Repository: wavetermdev/waveterm

Length of output: 833


🏁 Script executed:

#!/bin/bash
# Check if TabModel.tabId is defined
rg -n -A 5 'class TabModel' frontend/app/store/tab-model.ts

Repository: wavetermdev/waveterm

Length of output: 272


🏁 Script executed:

#!/bin/bash
# Check useTabModelMaybe return type
sed -n '80,95p' frontend/app/store/tab-model.ts

Repository: wavetermdev/waveterm

Length of output: 382


🏁 Script executed:

#!/bin/bash
# Look for any TypeScript compilation or type checking that might catch this
find . -name 'tsconfig.json' -o -name '.eslintrc*' | head -5

Repository: wavetermdev/waveterm

Length of output: 133


🏁 Script executed:

#!/bin/bash
# Check the actual type of useContext return and whether it can be null/undefined
rg -n 'TabModelContext' frontend/app/store/tab-model.ts

Repository: wavetermdev/waveterm

Length of output: 241


🏁 Script executed:

#!/bin/bash
# Check what type useContext returns in this case
sed -n '1,20p' frontend/app/store/tab-model.ts

Repository: wavetermdev/waveterm

Length of output: 674


🏁 Script executed:

#!/bin/bash
# Search for getWaveObjectAtom implementation in wos.ts
rg -n 'export.*getWaveObjectAtom\|function getWaveObjectAtom' frontend/app/store/wos.ts

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Get more context on the waveObjectValueCache and how it handles null orefs
sed -n '100,200p' frontend/app/store/wos.ts | grep -A 20 'getWaveObjectAtom'

Repository: wavetermdev/waveterm

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Search for getWaveObjectAtom in all files
rg -n 'getWaveObjectAtom' frontend/app/store/

Repository: wavetermdev/waveterm

Length of output: 1642


🏁 Script executed:

#!/bin/bash
# Look for export statements in wos.ts
grep -n 'export' frontend/app/store/wos.ts | head -30

Repository: wavetermdev/waveterm

Length of output: 76


🏁 Script executed:

#!/bin/bash
# Get the full implementation of getWaveObjectAtom
sed -n '213,240p' frontend/app/store/wos.ts

Repository: wavetermdev/waveterm

Length of output: 1050


🏁 Script executed:

#!/bin/bash
# Check what happens when makeORef returns null and how it's used
sed -n '51,60p' frontend/app/store/wos.ts

Repository: wavetermdev/waveterm

Length of output: 361


Add explicit undefined handling or update type signature for useTabBackground.

The function signature declares tabId: string | null, but the caller at line 268 passes tabModel?.tabId which can be undefined (since useTabModelMaybe() returns TabModel | undefined from TabModelContext). While the code happens to work because makeORef converts undefined to null, this relies on an implicit chain rather than explicit handling.

Either:

  • Update the type signature to accept string | null | undefined
  • Add an explicit null/undefined guard in useTabBackground to return safe defaults early
Current implementation
export function useTabBackground(
    waveEnv: TabBackgroundEnv,
    tabId: string | null
): [string, string, BackgroundConfigType] {
    const tabActiveBorderColorDirect = jotai.useAtomValue(waveEnv.getTabMetaKeyAtom(tabId, "bg:activebordercolor"));
    const tabBorderColorDirect = jotai.useAtomValue(waveEnv.getTabMetaKeyAtom(tabId, "bg:bordercolor"));
    const tabBg = jotai.useAtomValue(waveEnv.getTabMetaKeyAtom(tabId, "tab:background"));
    const configBg = jotai.useAtomValue(waveEnv.getConfigBackgroundAtom(tabBg));
    const tabActiveBorderColor = tabActiveBorderColorDirect ?? configBg?.["bg:activebordercolor"];
    const tabBorderColor = tabBorderColorDirect ?? configBg?.["bg:bordercolor"];
    return [tabBorderColor, tabActiveBorderColor, configBg];
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/app/aipanel/aipanel.tsx` at line 268, The caller passes
tabModel?.tabId which can be undefined but useTabBackground currently types
tabId as string | null; update useTabBackground to explicitly handle undefined
or accept it in the signature: change the parameter type to tabId: string | null
| undefined OR add an early guard in useTabBackground that maps undefined ->
null (or returns safe defaults) before calling waveEnv.getTabMetaKeyAtom;
reference useTabBackground, useTabModelMaybe (source of tabModel?.tabId), and
waveEnv.getTabMetaKeyAtom to ensure atoms are always invoked with a value the
implementation expects and avoid relying on implicit conversion via makeORef.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 24, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3150e03
Status: ✅  Deploy successful!
Preview URL: https://da81fb7b.waveterm.pages.dev
Branch Preview URL: https://sawka-no-config-dirs.waveterm.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
cmd/wsh/cmd/wshcmd-setbg.go (1)

133-133: Use defined constants for metadata keys instead of raw strings.

The codebase defines constants for these metadata keys in pkg/waveobj/metaconsts.go:

  • MetaKey_TabBackground = "tab:background"
  • MetaKey_BgBorderColor = "bg:bordercolor"
  • MetaKey_BgActiveBorderColor = "bg:activebordercolor"

Using raw string literals instead of these constants reduces maintainability and risks inconsistency if keys are renamed.

♻️ Suggested refactor to use constants
 		// Handle background setting
 		meta["bg:*"] = true
-		meta["tab:background"] = nil
+		meta[waveobj.MetaKey_TabBackground] = nil
 		if setBgOpacity < 0 || setBgOpacity > 1 {
 	if borderColorChanged {
-		meta["bg:bordercolor"] = setBgBorderColor
+		meta[waveobj.MetaKey_BgBorderColor] = setBgBorderColor
 	}
 	if activeBorderColorChanged {
-		meta["bg:activebordercolor"] = setBgActiveBorderColor
+		meta[waveobj.MetaKey_BgActiveBorderColor] = setBgActiveBorderColor
 	}

You'll need to add an import for the waveobj package.

Also applies to: 192-197

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/wsh/cmd/wshcmd-setbg.go` at line 133, Replace raw metadata key string
literals with the defined constants from the waveobj package: use
waveobj.MetaKey_TabBackground instead of "tab:background" (the occurrence at
meta["tab:background"]) and likewise replace "bg:bordercolor" and
"bg:activebordercolor" with waveobj.MetaKey_BgBorderColor and
waveobj.MetaKey_BgActiveBorderColor (the occurrences around lines 192–197). Add
the waveobj import to the file and update all meta[...] accesses to use these
constants to ensure consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cmd/wsh/cmd/wshcmd-setbg.go`:
- Line 133: Replace raw metadata key string literals with the defined constants
from the waveobj package: use waveobj.MetaKey_TabBackground instead of
"tab:background" (the occurrence at meta["tab:background"]) and likewise replace
"bg:bordercolor" and "bg:activebordercolor" with waveobj.MetaKey_BgBorderColor
and waveobj.MetaKey_BgActiveBorderColor (the occurrences around lines 192–197).
Add the waveobj import to the file and update all meta[...] accesses to use
these constants to ensure consistency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 47ee54fa-5a3e-4814-9358-0374ae83cca6

📥 Commits

Reviewing files that changed from the base of the PR and between f8d461d and 6eb6db6.

📒 Files selected for processing (6)
  • cmd/generateschema/main-generateschema.go
  • cmd/wsh/cmd/wshcmd-setbg.go
  • frontend/app/aipanel/aipanel.tsx
  • frontend/types/gotypes.d.ts
  • pkg/wconfig/settingsconfig.go
  • schema/backgrounds.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • schema/backgrounds.json
  • frontend/types/gotypes.d.ts
  • cmd/generateschema/main-generateschema.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/wconfig/settingsconfig.go (1)

896-937: Migration logic looks solid with proper error handling.

The function correctly:

  • Performs idempotent migration (only when backgrounds.json doesn't exist)
  • Preserves original JSON structure using json.RawMessage
  • Uses atomic file writes to prevent corruption
  • Handles various error cases with appropriate logging

Minor observation: The migrated file uses 4-space indentation (line 927) while jsonMarshalConfigInOrder uses 2-space indentation. Consider aligning indentation style across config files for consistency.

🔧 Optional: Align indentation style
-	outBarr, err := json.MarshalIndent(filtered, "", "    ")
+	outBarr, err := json.MarshalIndent(filtered, "", "  ")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/wconfig/settingsconfig.go` around lines 896 - 937,
MigratePresetsBackgrounds currently marshals the migrated JSON with 4-space
indentation (json.MarshalIndent(filtered, "", "    ")), which differs from the
2-space indentation used elsewhere (e.g., jsonMarshalConfigInOrder); update the
MarshalIndent call in MigratePresetsBackgrounds to use a 2-space indent string
(e.g., "  ") so backgrounds.json matches the project's config formatting
conventions and then write that output with fileutil.AtomicWriteFile as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/wconfig/settingsconfig.go`:
- Around line 896-937: MigratePresetsBackgrounds currently marshals the migrated
JSON with 4-space indentation (json.MarshalIndent(filtered, "", "    ")), which
differs from the 2-space indentation used elsewhere (e.g.,
jsonMarshalConfigInOrder); update the MarshalIndent call in
MigratePresetsBackgrounds to use a 2-space indent string (e.g., "  ") so
backgrounds.json matches the project's config formatting conventions and then
write that output with fileutil.AtomicWriteFile as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1eeb2ff1-769e-4977-a657-93567eb038f4

📥 Commits

Reviewing files that changed from the base of the PR and between 6eb6db6 and 49f5f9e.

📒 Files selected for processing (3)
  • frontend/app/app-bg.tsx
  • frontend/util/waveutil.ts
  • pkg/wconfig/settingsconfig.go
✅ Files skipped from review due to trivial changes (1)
  • frontend/app/app-bg.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant