fix(tui): handle --continue in directories with no prior sessions#23439
Open
rmk40 wants to merge 1 commit intoanomalyco:devfrom
Open
fix(tui): handle --continue in directories with no prior sessions#23439rmk40 wants to merge 1 commit intoanomalyco:devfrom
rmk40 wants to merge 1 commit intoanomalyco:devfrom
Conversation
- Extract CONTINUE_PLACEHOLDER_ID constant in context/route.tsx so the sentinel value is defined once and shared by both consumers - Guard session route fetch to skip eager session.get() while the route holds the placeholder, preventing invalid GET /session/dummy requests - Add no-match fallback in the continue effect: wait for sync complete before concluding no sessions exist, then navigate to home - Navigate home on fork failure instead of leaving user on placeholder - Flatten else branches to use early returns per style guide Closes anomalyco#23437
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #23437
Type of change
What does this PR do?
opencode -changs indefinitely in directories with no prior sessions.The
--continueflag seeds the router with a placeholder session route (sessionID: "dummy") to prevent a visual flash before the real session loads. When no sessions exist, the session component eagerly fetchesGET /session/dummy(which fails validation), and the continue effect never replaces the placeholder route because there is no session to match against. The TUI gets stuck.This PR makes three changes:
Extracts
CONTINUE_PLACEHOLDER_IDconstant incontext/route.tsxso the sentinel value is defined once and imported by both consumers. Prevents silent breakage if either site is changed independently.Guards the session route fetch in
routes/session/index.tsxto skip the eagersession.get()call while the route still holds the placeholder. The continue effect inApp()replaces it with a real session or home.Adds a no-match fallback in the continue effect in
app.tsx. When no root session exists, it waits forsync.status === "complete"(to avoid false negatives at"partial"), then navigates to home. Also navigates home on fork failure instead of leaving the user on the placeholder.How did you verify your code works?
Reproduced the hang in a fresh temp directory with
opencode -c. After the fix, the TUI starts on the home screen instead of hanging. Also verified thatopencode -cin a directory with existing sessions still navigates directly to the most recent session without a flash.Screenshots / recordings
N/A — no UI change, behavior fix only.
Checklist