Repository navigation
refactor(web): running timers share one clock instead of an interval each #25616
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
juliusmarminge
merged 2 commits into
main
from
effect/split-web-chat-canvas-and-work-rows#1
Oct 26, 2026
+219
−150
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
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/web/src/components/chat/WorktreeSetupCard.browser.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 { ThreadId, type WorktreeSetupSnapshot } from "@t3tools/contracts"; | ||
| import { expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| import { act, fakeTimers, render } from "../../../test/render"; | ||
| import { WorktreeSetupCard } from "./WorktreeSetupCard"; | ||
|
|
||
| const NOW = new Date("2026-10-26T12:00:10.000Z"); | ||
|
|
||
| function snapshot(overrides: Partial<WorktreeSetupSnapshot>): WorktreeSetupSnapshot { | ||
| return { | ||
| threadId: ThreadId.make("thread-1"), | ||
| phase: "running", | ||
| startedAt: "2026-10-26T12:00:00.000Z", | ||
| endedAt: null, | ||
| branch: "t3/feature", | ||
| baseRef: "main", | ||
| worktreePath: "/repo/.t3/worktrees/feature", | ||
| setupScript: null, | ||
| stages: [ | ||
| { | ||
| id: "fetch", | ||
| status: "done", | ||
| startedAt: "2026-10-26T12:00:00.000Z", | ||
| endedAt: "2026-10-26T12:00:03.000Z", | ||
| percent: null, | ||
| detail: null, | ||
| tail: [], | ||
| }, | ||
| { | ||
| id: "checkout", | ||
| status: "running", | ||
| startedAt: "2026-10-26T12:00:03.000Z", | ||
| endedAt: null, | ||
| percent: null, | ||
| detail: null, | ||
| tail: [], | ||
| }, | ||
| ], | ||
| error: null, | ||
| sequence: 1, | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| const card = (value: WorktreeSetupSnapshot) => ( | ||
| <WorktreeSetupCard snapshot={value} onCancel={null} onWorkLocally={null} onOpenTerminal={null} /> | ||
| ); | ||
|
|
||
| it("ticks the running stage while finished stages keep their duration", async () => { | ||
| using _timers = fakeTimers(); | ||
| vi.setSystemTime(NOW); | ||
| await using screen = await render(card(snapshot({}))); | ||
| // Assert synchronously: expect.element polls on timers these tests fake. | ||
| const section = screen.getByRole("region", { name: "Worktree setup" }); | ||
|
|
||
| expect(section.element().textContent).toContain("Fetch base branch3.0s"); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| expect(section.element().textContent).toContain("Check out files7.0s"); | ||
|
|
||
| await act(async () => { | ||
| await vi.advanceTimersByTimeAsync(5_000); | ||
| }); | ||
| expect(section.element().textContent).toContain("Fetch base branch3.0s"); | ||
| expect(section.element().textContent).toContain("Check out files12s"); | ||
| }); | ||
|
|
||
| it("stops a stage interrupted by the setup ending at the setup's end", async () => { | ||
| using _timers = fakeTimers(); | ||
| vi.setSystemTime(NOW); | ||
| const failed = snapshot({ phase: "failed", endedAt: "2026-10-26T12:00:05.000Z" }); | ||
| await using screen = await render(card(failed)); | ||
| const section = screen.getByRole("region", { name: "Worktree setup" }); | ||
|
|
||
| expect(section.element().textContent).toContain("Check out files2.0s"); | ||
| await act(async () => { | ||
| await vi.advanceTimersByTimeAsync(5_000); | ||
| }); | ||
| expect(section.element().textContent).toContain("Check out files2.0s"); | ||
| }); | ||
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.