Skip to content

[codex] Fix workspace switch crash#131

Merged
samuelstroschein merged 1 commit into
mainfrom
codex/fix-workspace-switch-crash
Jun 17, 2026
Merged

[codex] Fix workspace switch crash#131
samuelstroschein merged 1 commit into
mainfrom
codex/fix-workspace-switch-crash

Conversation

@samuelstroschein

@samuelstroschein samuelstroschein commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

Fixes workspace switching so Flashtype closes the current Lix session before adopting the next workspace.

The crash/stale-state path came from updating the main-process workspace descriptor before tearing down the old Lix handle. That could leave the window showing the new workspace while data was still served from the previous one, especially when switching into an empty folder.

Changes

  • Serialize main-process workspace changes so overlapping workspace.open calls cannot race.
  • Close the current Lix session before changing workspaces, while allowing workspace switching to recover from a failed old Lix open.
  • Add an Electron e2e regression for switching from a populated workspace into an empty folder.
  • Add a patch changenote.

Validation

  • pnpm exec oxlint --tsconfig ./tsconfig.json --format stylish electron/main.mjs electron/ipc-lix.mjs electron/lix.mjs electron/workspace.mjs e2e/workspace-switch.spec.ts
  • pnpm run typecheck
  • pnpm exec playwright test e2e/workspace-switch.spec.ts
  • node scripts/validate-changes.mjs

Note

Medium Risk
Touches main-process workspace and Lix lifecycle ordering; behavior change on every folder switch, though scoped and covered by a new e2e test.

Overview
Fixes crashes and stale UI when switching workspaces (especially into an empty folder) by tearing down the current Lix session before the main process adopts the next workspace path.

Workspace opens are serialized via a queue so overlapping workspace.open calls cannot race. registerWorkspaceIpc now accepts a beforeChange hook; startup wires it to closeLixSession({ ignoreOpenError: true }) so a failed old Lix open does not block switching. Lix teardown is centralized in closeLixSession (IPC handles, transactions/observers, then closeLix with optional ignoreOpenError).

Adds an Electron e2e regression (populated folder → empty folder) and a patch changenote.

Reviewed by Cursor Bugbot for commit 03e849d. Bugbot is set up for automated code reviews on this repo. Configure here.

@samuelstroschein samuelstroschein marked this pull request as ready for review June 17, 2026 18:35
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
flashtype-website 03e849d Commit Preview URL

Branch Preview URL
Jun 17 2026, 06:35 PM

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03e849d1d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread electron/main.mjs
registerAppIpc();
registerWorkspaceIpc((event) => BrowserWindow.fromWebContents(event.sender));
registerWorkspaceIpc((event) => BrowserWindow.fromWebContents(event.sender), {
beforeChange: () => closeLixSession({ ignoreOpenError: true }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Don't ignore old-session close failures

In the workspace-switch path this passes ignoreOpenError into closeLixSession, but closeCurrentLix applies that flag to the whole try, including await lix.close(). If the previous workspace opened successfully but its native close/flush fails, the switch still advances to the new workspace and clears lixPromise, leaving the old session unclosed—the stale-handle state this change is meant to avoid. Please only ignore rejection from the old open promise, not failures from closing an already-open session.

Useful? React with 👍 / 👎.

@samuelstroschein samuelstroschein merged commit 164d38d into main Jun 17, 2026
5 checks passed
@samuelstroschein samuelstroschein deleted the codex/fix-workspace-switch-crash branch June 17, 2026 18:46
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