Skip to content

🤖 fix: restore the open chat on hard refresh#3151

Open
ammar-agent wants to merge 1 commit intomainfrom
fix/restore-chat-on-hard-refresh
Open

🤖 fix: restore the open chat on hard refresh#3151
ammar-agent wants to merge 1 commit intomainfrom
fix/restore-chat-on-hard-refresh

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

@ammar-agent ammar-agent commented Apr 9, 2026

Summary

This follow-up to #3141 keeps an open workspace chat on hard refresh and also simplifies the startup routing architecture behind that decision. Browser and standalone startup now classify /workspace/:id restores from the actual navigation type instead of relying on session-storage bookkeeping spread across initialization paths.

Background

#3141 intentionally kept browser fresh-launch behavior from blindly reopening a stale /workspace/:id URL unless the user explicitly chose last workspace. That was still correct for true first loads, but hard refresh got lumped into the same bucket and could bounce an open chat back to the project/new-workspace page.

The first fix for this used per-session flags, which worked for reloads but added more startup coordination state to an already subtle routing area. This revision simplifies that architecture by making RouterContext answer one clearer question on startup: is this a restore-style navigation or a fresh launch?

Implementation

  • add getStartupNavigationType() and shouldRestoreWorkspaceUrlOnStartup() in RouterContext
  • use Navigation Timing (with a legacy performance.navigation fallback) to distinguish reload / back_forward restores from fresh navigate loads
  • remove browser/PWA session-storage startup markers and the RouterProvider effect that existed only to maintain them
  • keep the desktop file:// restore path and launch-behavior handling unchanged
  • update router and workspace-context tests to stub navigation type directly so the startup policy stays explicit and easier to reason about

Validation

  • bun test src/browser/contexts/RouterContext.test.tsx
  • bun test src/browser/contexts/WorkspaceContext.test.tsx
  • make static-check

Risks

This changes browser/PWA startup route restoration logic. A regression here would affect whether /workspace/:id is treated as a fresh launch or a restore on page load, so the updated tests cover both cold-launch and reload behavior.


Generated with mux • Model: openai:gpt-5.4 • Thinking: xhigh • Cost: $18.76

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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".

@ammar-agent ammar-agent force-pushed the fix/restore-chat-on-hard-refresh branch from dfcb7d7 to 665f749 Compare April 9, 2026 20:24
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ 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".

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