-
Notifications
You must be signed in to change notification settings - Fork 0
fix(app): land on a draft when no project is registered #248
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { describe, expect, test } from "bun:test" | ||
| import { resolveLandingDirectory } from "./new-session-landing" | ||
|
|
||
| describe("resolveLandingDirectory", () => { | ||
| test("uses the first registered project's worktree", () => { | ||
| expect(resolveLandingDirectory([{ worktree: "/repo/a" }, { worktree: "/repo/b" }], "/cwd")).toBe("/repo/a") | ||
| }) | ||
|
|
||
| // The amicode chat server runs with cwd set to an internal scaffold dir that is | ||
| // never registered as a project. Before this fallback, NewSessionLanding and the | ||
| // titlebar "+" both gave up silently, leaving a permanently blank app. | ||
| test("falls back to the server directory when no project is registered", () => { | ||
| expect(resolveLandingDirectory([], "/scaffold/opencode-project")).toBe("/scaffold/opencode-project") | ||
| }) | ||
|
|
||
| test("returns undefined when there is neither a project nor a server directory", () => { | ||
| expect(resolveLandingDirectory([], undefined)).toBeUndefined() | ||
| }) | ||
| }) |
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,13 @@ | ||
| /** Pick the directory a new draft should be created in. | ||
| * | ||
| * Prefers the first registered project. Falls back to the server's own working | ||
| * directory, because a server can legitimately run somewhere that was never | ||
| * registered as a project — the amicode chat server does exactly that, spawning | ||
| * in an internal scaffold dir. Without the fallback both the "/" landing route | ||
| * and the titlebar "+" return silently and the app renders nothing at all. */ | ||
| export function resolveLandingDirectory( | ||
| projects: readonly { worktree: string }[], | ||
| serverDirectory: string | undefined, | ||
| ): string | undefined { | ||
| return projects[0]?.worktree ?? serverDirectory | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve the selected server in the home fallback.
The home branch already resolves the selected server at Line 300. If that server has no registered project but has a synchronized fallback directory, execution reaches Lines 321-325 and scans connections from the first entry instead.
With multiple connections, the
+button can therefore create the draft on a different server and directory. Try the selectedconnfirst, then scan other connections only if it has no usable directory. Add a two-server regression test.🤖 Prompt for AI Agents