Skip to content

preview updates (mock electron api, wos checks)#2986

Merged
sawka merged 12 commits intomainfrom
sawka/preview-updates
Mar 7, 2026
Merged

preview updates (mock electron api, wos checks)#2986
sawka merged 12 commits intomainfrom
sawka/preview-updates

Conversation

@sawka
Copy link
Member

@sawka sawka commented Mar 5, 2026

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

Walkthrough

The PR introduces a preview mode across the frontend: adds a mock Electron API and installer, installs it in preview startup, and wires preview-specific global initialization via global-atoms/GlobalModel with a new optional GlobalInitOptions.isPreview flag. The WaveObj store gains preview-object mocking and exported mockObjectForPreview, and backend calls in callBackendService now guard for a missing endpoint. Onboarding InitPage accepts a new telemetryUpdateFn prop and preview examples pass it through. Miscellaneous: broadened ESLint no-unused-vars ignore patterns and a copyright year bump.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description explaining the purpose and scope of the preview updates, mock Electron API additions, and WOS changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'preview updates (mock electron api, wos checks)' directly aligns with the changeset, which adds a mock Electron API, updates WOS functionality, and modifies preview-related files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawka/preview-updates

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.

@cloudflare-workers-and-pages
Copy link

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

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: ea20da0
Status: ✅  Deploy successful!
Preview URL: https://801cb61a.waveterm.pages.dev
Branch Preview URL: https://sawka-preview-updates.waveterm.pages.dev

View logs

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 5, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

CRITICAL

File Line Issue
frontend/app/store/wos.ts 122 Null check breaks preview mode - getWebServerEndpoint() returns null by design in preview windows, but the new null check throws an error, breaking all backend service calls in preview mode

MAJOR

File Line Issue
frontend/preview/preview.tsx 138 Empty object cast to FullConfigType - casting {} as FullConfigType can cause runtime errors when properties are accessed
Resolved Issues

The following issue was identified in earlier reviews but has been fixed in subsequent commits:

File Line Issue Status
frontend/preview/preview-electron-api.ts 62 Missing setIsActive method in mock API ✅ Resolved
Other Observations (not in diff)

Other files using getWebServerEndpoint() that may have similar issues (not in diff, so no inline comments):

File Line Issue
frontend/app/element/markdown-util.ts 168 Uses getWebServerEndpoint() + "/wave/..." - will produce "null/wave/..." in preview mode
frontend/app/store/global.ts 465 Uses getWebServerEndpoint() + "/wave/..." - will produce "null/wave/..." in preview mode
Files Reviewed (10 files)
  • .kilocode/skills/electron-api/SKILL.md - OK (documentation)
  • eslint.config.js - OK
  • frontend/app/onboarding/onboarding.tsx - OK
  • frontend/app/store/client-model.ts - OK
  • frontend/app/store/global-atoms.ts - OK
  • frontend/app/store/wos.ts - 1 CRITICAL issue
  • frontend/preview/preview-electron-api.ts - Issue resolved
  • frontend/preview/preview.tsx - 1 MAJOR issue
  • frontend/preview/previews/onboarding.preview.tsx - OK
  • frontend/types/custom.d.ts - OK

Fix these issues in Kilo Cloud

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: 2

🤖 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/preview/preview-electron-api.ts`:
- Around line 4-61: The previewElectronApi object is missing the required async
method setIsActive defined by the ElectronApi interface; add setIsActive: () =>
Promise<void> to previewElectronApi (e.g., implement a stub that returns
Promise.resolve() or an async no-op) so the object satisfies the type
contract—update the previewElectronApi declaration to include this method
alongside the other functions.

In `@frontend/preview/preview.tsx`:
- Line 138: Replace the unsafe cast "{} as FullConfigType" used in
globalStore.set(getAtoms().fullConfigAtom, {} as FullConfigType) with a
structurally complete default that matches FullConfigType (e.g., include default
presets array and default settings object or use an exported
DEFAULT_FULL_CONFIG). Update the initialization so fullConfig.presets and
fullConfig.settings are defined (either create and use a DEFAULT_FULL_CONFIG
constant or import an existing default) before calling globalStore.set to avoid
runtime property access errors.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e8547e9e-3db6-401b-ac3e-86e84238962c

📥 Commits

Reviewing files that changed from the base of the PR and between 1a1cd85 and 00a1d26.

📒 Files selected for processing (9)
  • eslint.config.js
  • frontend/app/onboarding/onboarding.tsx
  • frontend/app/store/client-model.ts
  • frontend/app/store/global-atoms.ts
  • frontend/app/store/wos.ts
  • frontend/preview/preview-electron-api.ts
  • frontend/preview/preview.tsx
  • frontend/preview/previews/onboarding.preview.tsx
  • frontend/types/custom.d.ts

isPreview: true,
} as GlobalInitOptions;
initGlobalAtoms(initOpts);
globalStore.set(getAtoms().fullConfigAtom, {} as FullConfigType);
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 | 🟠 Major

Initialize fullConfigAtom with a structurally safe default, not {}.

Line 138 sets {} as FullConfigType; preview components that read fullConfig.presets/fullConfig.settings directly can throw at runtime.

🔧 Proposed fix
-    globalStore.set(getAtoms().fullConfigAtom, {} as FullConfigType);
+    globalStore.set(
+        getAtoms().fullConfigAtom,
+        {
+            settings: {},
+            presets: {},
+            connections: {},
+        } as FullConfigType
+    );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
globalStore.set(getAtoms().fullConfigAtom, {} as FullConfigType);
globalStore.set(
getAtoms().fullConfigAtom,
{
settings: {},
presets: {},
connections: {},
} as FullConfigType
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/preview/preview.tsx` at line 138, Replace the unsafe cast "{} as
FullConfigType" used in globalStore.set(getAtoms().fullConfigAtom, {} as
FullConfigType) with a structurally complete default that matches FullConfigType
(e.g., include default presets array and default settings object or use an
exported DEFAULT_FULL_CONFIG). Update the initialization so fullConfig.presets
and fullConfig.settings are defined (either create and use a DEFAULT_FULL_CONFIG
constant or import an existing default) before calling globalStore.set to avoid
runtime property access errors.

usp.set("method", method);
const url = getWebServerEndpoint() + "/wave/service?" + usp.toString();
const webEndpoint = getWebServerEndpoint();
if (webEndpoint == null) throw new Error(`cannot call ${methodName}: no web endpoint`);
Copy link
Contributor

Choose a reason for hiding this comment

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

CRITICAL: Null check breaks preview mode - getWebServerEndpoint() intentionally returns null in preview windows (see frontend/util/endpoints.ts:12), but this null check throws an error. This will crash all backend service calls in preview mode.

The fix should either:

  1. Add an early return for preview windows: if (isPreviewWindow()) return Promise.reject(new Error(...));
  2. Or remove the null check and let it fail with a more descriptive error downstream.

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)
.kilocode/skills/electron-api/SKILL.md (1)

58-66: Documentation correctly demonstrates the preview stub pattern.

The example properly shows a no-op stub that matches the async signature, and the section numbering is adjusted accordingly.

Optional: Consider adding preview stub examples for other patterns.

For consistency and completeness, you could add preview stub examples for the sync and fire-and-forget patterns shown later in the document. For example:

  • Sync: getUserName: () => "unknown"
  • Fire-and-forget: openExternal: (_url: string) => {}

This would help developers understand how to stub different return types and communication patterns.

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

In @.kilocode/skills/electron-api/SKILL.md around lines 58 - 66, Add optional
preview-stub examples for the sync and fire-and-for-get patterns to the SKILL.md
section (alongside the existing captureScreenshot async stub) so readers see all
patterns; specifically, show a sync stub like getUserName that returns a default
string and a fire-and-forget stub like openExternal that is an empty function,
placing them near the "Add Preview Stub" example for consistency and clarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.kilocode/skills/electron-api/SKILL.md:
- Around line 58-66: Add optional preview-stub examples for the sync and
fire-and-for-get patterns to the SKILL.md section (alongside the existing
captureScreenshot async stub) so readers see all patterns; specifically, show a
sync stub like getUserName that returns a default string and a fire-and-forget
stub like openExternal that is an empty function, placing them near the "Add
Preview Stub" example for consistency and clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3aa87407-6089-4e91-bb00-add589a4ff29

📥 Commits

Reviewing files that changed from the base of the PR and between ea20da0 and 897660a.

📒 Files selected for processing (1)
  • .kilocode/skills/electron-api/SKILL.md

@sawka sawka merged commit 7ef0bcd into main Mar 7, 2026
7 checks passed
@sawka sawka deleted the sawka/preview-updates branch March 7, 2026 00:50
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.

2 participants