Repository navigation
fix(mobile): Retry after a failed worktree setup shows the new attempt #30897
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
Open
juliusmarminge
wants to merge
11
commits into
main
Choose a base branch
from
fix/issue-30849
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−9
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b66031a
test(mobile): reproduce #30849 worktree setup retry not reaching the …
juliusmarminge 9a79dc4
fix(mobile): worktree setup card follows a retried preparation
juliusmarminge 229b941
fix(client): a later worktree setup attempt replaces a held failure
juliusmarminge 736f024
docs(mobile): describe when the worktree setup read stays open
juliusmarminge 5cd3f0b
Merge remote-tracking branch 'origin/main' into fix/issue-30849
juliusmarminge 8c1b2cc
fix(mobile): keep reading worktree setup until a retry's snapshot arr…
juliusmarminge b108eea
Merge remote-tracking branch 'origin/main' into fix/issue-30849
juliusmarminge 5bf23a9
test(mobile): drop resolver row duplicated by the web logic test
juliusmarminge cec82e1
Merge remote-tracking branch 'gh/main' into fix/issue-30849
juliusmarminge 61e3322
fix(mobile): keep reading worktree setup while a retry can follow
juliusmarminge 5baecf7
Merge remote-tracking branch 'origin/main' into fix/issue-30849
juliusmarminge 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
78 changes: 78 additions & 0 deletions
78
apps/mobile/src/features/threads/use-worktree-setup.test.tsx
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,78 @@ | ||
| import { EnvironmentId, ThreadId, type WorktreeSetupSnapshot } from "@t3tools/contracts"; | ||
| import { act, useLayoutEffect } from "react"; | ||
| import { createRoot } from "react-dom/client"; | ||
| import { expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| server: null as WorktreeSetupSnapshot | null, | ||
| })); | ||
|
|
||
| vi.mock("../../state/vcs", () => ({ | ||
| vcsEnvironment: { worktreeSetup: () => "worktree-setup" }, | ||
| })); | ||
| // The server only pushes snapshots to an open subscription. | ||
| vi.mock("../../state/query", () => ({ | ||
| useEnvironmentQuery: (atom: string | null) => ({ | ||
| data: atom === "worktree-setup" ? mocks.server : null, | ||
| isPending: false, | ||
| refresh: () => {}, | ||
| }), | ||
| })); | ||
|
|
||
| import { useWorktreeSetup } from "./use-worktree-setup"; | ||
|
|
||
| const environmentId = EnvironmentId.make("environment"); | ||
| const threadId = ThreadId.make("setup-thread"); | ||
| const failed: WorktreeSetupSnapshot = { | ||
| threadId, | ||
| sequence: 2, | ||
| phase: "failed", | ||
| startedAt: "2026-10-30T00:00:00.000Z", | ||
| endedAt: "2026-10-30T00:00:00.980Z", | ||
| branch: "feature", | ||
| baseRef: "origin/main", | ||
| worktreePath: null, | ||
| setupScript: null, | ||
| stages: [], | ||
| error: "Fetch base branch failed", | ||
| }; | ||
|
|
||
| function Probe(props: { preparing: boolean; seen: Array<WorktreeSetupSnapshot | null> }) { | ||
| const { snapshot } = useWorktreeSetup({ | ||
| environmentId, | ||
| threadId, | ||
| preparing: props.preparing, | ||
| hasWorktree: false, | ||
| turnStarted: false, | ||
| followUpSent: false, | ||
| }); | ||
| useLayoutEffect(() => { | ||
| props.seen.push(snapshot); | ||
| }); | ||
| return null; | ||
| } | ||
|
|
||
| // A fast retry's preparing -> failed can coalesce, so the hook never renders it as preparing. | ||
| it("shows a retry's failure that arrives without a preparing render", async () => { | ||
| mocks.server = failed; | ||
| const seen: Array<WorktreeSetupSnapshot | null> = []; | ||
| const root = createRoot(document.createElement("div")); | ||
| await act(async () => root.render(<Probe preparing seen={seen} />)); | ||
| await act(async () => root.render(<Probe preparing={false} seen={seen} />)); | ||
| expect(seen.at(-1)).toBe(failed); | ||
|
|
||
| // Retention ended, so the server resets the retry's sequence. | ||
| mocks.server = null; | ||
| await act(async () => root.render(<Probe preparing={false} seen={seen} />)); | ||
| const retryFailed: WorktreeSetupSnapshot = { | ||
| ...failed, | ||
| sequence: 0, | ||
| startedAt: "2026-10-30T00:01:00.000Z", | ||
| endedAt: "2026-10-30T00:01:00.050Z", | ||
| error: "Checkout failed", | ||
| }; | ||
| mocks.server = retryFailed; | ||
| await act(async () => root.render(<Probe preparing={false} seen={seen} />)); | ||
| expect(seen.at(-1)).toBe(retryFailed); | ||
| act(() => root.unmount()); | ||
| }); |
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
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.
Script executed:
Repository: pingdotgg/t3code
Length of output: 28008
Script executed:
Repository: pingdotgg/t3code
Length of output: 22436
Script executed:
Repository: pingdotgg/t3code
Length of output: 7097
Script executed:
Repository: pingdotgg/t3code
Length of output: 13124
Script executed:
Repository: pingdotgg/t3code
Length of output: 19195
Script executed:
Repository: pingdotgg/t3code
Length of output: 12432
Script executed:
Repository: pingdotgg/t3code
Length of output: 14838
Script executed:
Repository: pingdotgg/t3code
Length of output: 21822
Script executed:
Repository: pingdotgg/t3code
Length of output: 12763
Reopen the snapshot query when a retry starts.
If a fast retry’s
preparingandfailedupdates reach the screen in one projection update, the hook can retain the previous attempt’s snapshot. The setup card can then show the old duration and stages. Reopen the query without relying on an intermediatepreparingrender, and cover that path in the retry test.