-
Notifications
You must be signed in to change notification settings - Fork 14
fix(app): stabilize shell navigation state #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
14cfeda
fix(app): stabilize shell navigation state
Astro-Han 0606f6e
fix(app): show loading while opening session
Astro-Han 2eb551c
test(app): cover shell navigation fallback
Astro-Han dbeeece
fix(app): route sidebar sessions through shell owner
Astro-Han 2c42eea
fix(app): route workspace new sessions through shell owner
Astro-Han 3044fed
test(app): cover delayed sidebar session opening
Astro-Han 90f9a0b
fix(app): route opening recovery through shell owner
Astro-Han 0c057d2
test(app): clarify delayed session opening e2e
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import { describe, expect, test } from "bun:test" | ||
| import { base64Encode } from "@opencode-ai/util/encode" | ||
| import { createShellNavigation } from "./shell-navigation" | ||
|
|
||
| describe("createShellNavigation", () => { | ||
| test("opens a new session through one shell action and releases transient locks first", () => { | ||
| const calls: string[] = [] | ||
| const shell = createShellNavigation({ | ||
| navigate: (route) => calls.push(`navigate:${route}`), | ||
| releaseTransientLocks: (reason) => calls.push(`release:${reason}`), | ||
| resolveProjectRoot: (directory) => `/root:${directory}`, | ||
| currentProjectRoot: () => "/current", | ||
| chooseProject: () => calls.push("chooseProject"), | ||
| openSettingsSurface: () => calls.push("settings"), | ||
| }) | ||
|
|
||
| shell.openNewSession("/repo") | ||
|
|
||
| expect(calls).toEqual([`release:new-session`, `navigate:/${base64Encode("/root:/repo")}/session`]) | ||
| }) | ||
|
|
||
| test("opens an existing session through one shell action and releases transient locks first", () => { | ||
| const calls: string[] = [] | ||
| const shell = createShellNavigation({ | ||
| navigate: (route) => calls.push(`navigate:${route}`), | ||
| releaseTransientLocks: (reason) => calls.push(`release:${reason}`), | ||
| resolveProjectRoot: (directory) => directory, | ||
| currentProjectRoot: () => "/current", | ||
| chooseProject: () => calls.push("chooseProject"), | ||
| openSettingsSurface: () => calls.push("settings"), | ||
| }) | ||
|
|
||
| shell.openSession({ directory: "/repo", id: "ses_123" }) | ||
|
|
||
| expect(calls).toEqual([`release:session`, `navigate:/${base64Encode("/repo")}/session/ses_123`]) | ||
| }) | ||
|
|
||
| test("opens settings through the same shell action owner instead of a standalone signal", () => { | ||
| const calls: string[] = [] | ||
| const shell = createShellNavigation({ | ||
| navigate: (route) => calls.push(`navigate:${route}`), | ||
| releaseTransientLocks: (reason) => calls.push(`release:${reason}`), | ||
| resolveProjectRoot: (directory) => directory, | ||
| currentProjectRoot: () => "/current", | ||
| chooseProject: () => calls.push("chooseProject"), | ||
| openSettingsSurface: () => calls.push("settings"), | ||
| }) | ||
|
|
||
| shell.openSettings() | ||
|
|
||
| expect(calls).toEqual(["release:settings", "settings"]) | ||
| }) | ||
|
|
||
| test("falls back to project chooser when no directory can be resolved for a new session", () => { | ||
| const calls: string[] = [] | ||
| const shell = createShellNavigation({ | ||
| navigate: (route) => calls.push(`navigate:${route}`), | ||
| releaseTransientLocks: (reason) => calls.push(`release:${reason}`), | ||
| resolveProjectRoot: () => "", | ||
| currentProjectRoot: () => undefined, | ||
| chooseProject: () => calls.push("chooseProject"), | ||
| openSettingsSurface: () => calls.push("settings"), | ||
| }) | ||
|
|
||
| shell.openNewSession() | ||
|
|
||
| expect(calls).toEqual(["release:choose-project", "chooseProject"]) | ||
| }) | ||
|
|
||
| test("falls back to project chooser when an explicit directory cannot be resolved", () => { | ||
| const calls: string[] = [] | ||
| const shell = createShellNavigation({ | ||
| navigate: (route) => calls.push(`navigate:${route}`), | ||
| releaseTransientLocks: (reason) => calls.push(`release:${reason}`), | ||
| resolveProjectRoot: () => undefined, | ||
| currentProjectRoot: () => "/current", | ||
| chooseProject: () => calls.push("chooseProject"), | ||
| openSettingsSurface: () => calls.push("settings"), | ||
| }) | ||
|
|
||
| shell.openNewSession("/repo") | ||
|
|
||
| expect(calls).toEqual(["release:choose-project", "chooseProject"]) | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.