Skip to content

Conversation

@zah
Copy link
Member

@zah zah commented Dec 20, 2025

Note

Adds validation and auto-reset for corrupted/incompatible layout JSON, forwards Playwright --inspect/--remote-debugging-port to Electron, and introduces layout resilience tests.

  • Frontend (Electron UI):
    • Validate layout JSON via isValidLayoutConfig and auto-reset to bundled default with resetLayoutToDefault when corrupt/incompatible.
    • Harden loadLayoutConfig/loadEditLayoutConfig with parse/structure checks and recovery; add fsUnlinkWithErr bridge in helpers.ts and bindings.
  • CLI/Launch:
    • Add config options inspect and remote-debugging-port; eventuallyWrapElectron(conf) now forwards these to Electron.
    • Refactor wrapElectron(electronArgs, appArgs) (posix) and adapt electron command to use electronAppArgs.
    • Replace generic exception handlers with CatchableError in Nim entrypoints.
  • Tests:
    • Add Playwright spec tsc-ui-tests/tests/layout/layout_resilience.spec.ts and C# UI tests LayoutResilienceTests with registry entries, plus cleaner env setup in ct_helpers.ts.

Written by Cursor Bugbot for commit 2426f92. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

if conf.remoteDebuggingPort.isSome:
electronArgs.add("--remote-debugging-port=" & conf.remoteDebuggingPort.get)

wrapElectron(electronArgs, appArgs)
Copy link

Choose a reason for hiding this comment

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

Electron debug flags duplicated in command line arguments

In eventuallyWrapElectron, appArgs is populated with ALL raw command line arguments via paramStr(i), which includes --inspect and --remote-debugging-port flags injected by Playwright. These same flags are then also extracted from the parsed conf and added to electronArgs. When wrapElectron(electronArgs, appArgs) is called, the flags appear twice in the final electron command—once before and once after the entry point. This differs from the StartupCommand.electron case which correctly uses conf.electronAppArgs with the restOfArgs pragma to exclude parsed options.

Fix in Cursor Fix in Web

warnPrint "Could not copy default layout, reading bundled default directly"
let (bundledData, bundledErr) = await fsreadFileWithErr(cstring(fmt"{configDir / defaultLayoutPath}"))
if bundledErr.isNil:
return JSON.parse(bundledData)
Copy link

Choose a reason for hiding this comment

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

Unhandled JSON parse exceptions in reset function

The JSON.parse calls in resetLayoutToDefault (lines 270 and 276) are not wrapped in try/except. When this function is called from inside an except block in loadLayoutConfig or loadEditLayoutConfig, any parse exception would propagate up unhandled instead of reaching the intended quit(1) with the "critical - cannot load any layout config" error message. This undermines the PR's goal of robust error handling if the bundled default layout is somehow corrupted.

Additional Locations (2)

Fix in Cursor Fix in Web

@zah zah merged commit 2ced36a into main Dec 20, 2025
27 checks passed
@zah zah deleted the resilient-layout-files branch December 20, 2025 21:57
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants