Repository navigation
fix(web): avoid guessing local workspaces before settings load #24085
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
nateEc
wants to merge
10
commits into
pingdotgg:main
Choose a base branch
from
nateEc:codex/fix-23639-cold-workspace-default
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.
+231
−12
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
59dc8e7
fix(web): 避免配置未加载时误用本地工作区
nateEc 3ba80c5
fix(web): 配置未就绪时等待手动重试新线程
nateEc d304018
test(web): 按浏览器规范等待手动重试断言
nateEc fe06c3e
chore(web): 协调新线程配置与草稿竞态回归
nateEc 7a8b2bb
Merge remote-tracking branch 'origin/main' into codex/fix-23639-cold-…
juliusmarminge 44c479b
fix(web): wait for environment config before the landing opens a draft
juliusmarminge 7234128
chore: 合并主线并解决冲突
nateEc 27a5e39
fix(web): 补齐环境连接提示的翻译目录
nateEc 5c75f95
fix(web): 让首页等待环境设置时可以重试
nateEc 6beacd7
test(web): 隔离首页设置恢复的浏览器测试
nateEc 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { createMemoryHistory } from "@tanstack/react-router"; | ||
| import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; | ||
| import type * as Context from "effect/Context"; | ||
| import { Atom } from "effect/reactivity"; | ||
| import { expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| import { AppRoot } from "~/AppRoot"; | ||
| import { DraftId, useComposerDraftStore } from "~/composerDraftStore"; | ||
| import { __setClientSettingsForTests } from "~/hooks/useSettings"; | ||
| import stylesheet from "~/index.css?inline"; | ||
| import { getRouter } from "~/router"; | ||
| import { appAtomRegistry } from "~/rpc/atomRegistry"; | ||
| import { | ||
| ENVIRONMENT_ID, | ||
| installFakeEnvironment, | ||
| threadWithHistory, | ||
| type FakeDriver, | ||
| } from "../../test/fakeEnvironment"; | ||
| import { act, render } from "../../test/render"; | ||
|
|
||
| const configVisible = Atom.make(false).pipe(Atom.keepAlive); | ||
|
|
||
| vi.mock(import("~/state/server"), async (original) => { | ||
| const actual = await original(); | ||
| const { Atom } = await import("effect/reactivity"); | ||
| return { | ||
| ...actual, | ||
| environmentServerConfigsAtom: Atom.make((get) => { | ||
| if (!get(configVisible)) return new Map(); | ||
| const config = get(actual.environmentServerConfigsAtom).get(ENVIRONMENT_ID); | ||
| if (config === undefined) return new Map(); | ||
| return new Map([ | ||
| [ | ||
| ENVIRONMENT_ID, | ||
| { | ||
| ...config, | ||
| settings: { ...config.settings, defaultThreadEnvMode: "worktree" as const }, | ||
| }, | ||
| ], | ||
| ]); | ||
| }), | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock("../../../../packages/client-runtime/src/connection/driver.ts", async (original) => { | ||
| const [actual, { fakeDriver }, Layer] = await Promise.all([ | ||
| original<{ readonly ConnectionDriver: Context.Key<unknown, FakeDriver> }>(), | ||
| import("../../test/fakeEnvironment"), | ||
| import("effect/Layer"), | ||
| ]); | ||
| return { ...actual, layer: Layer.succeed(actual.ConnectionDriver, fakeDriver) }; | ||
| }); | ||
|
|
||
| function setup() { | ||
| appAtomRegistry.set(configVisible, false); | ||
| __setClientSettingsForTests({ | ||
| ...DEFAULT_CLIENT_SETTINGS, | ||
| onboardingCompletedAt: "2026-01-01T00:00:00.000Z", | ||
| }); | ||
| return installFakeEnvironment([threadWithHistory("home-settings", 1)]); | ||
| } | ||
|
|
||
| it("stays recoverable while the most recent project's settings are unavailable", async () => { | ||
| using _environment = setup(); | ||
| const router = getRouter(createMemoryHistory({ initialEntries: ["/"] })); | ||
| await router.load(); | ||
| await using screen = await render( | ||
| <> | ||
| <style>{stylesheet}</style> | ||
| <AppRoot router={router} /> | ||
| </>, | ||
| { router: false }, | ||
| ); | ||
|
|
||
| const retry = screen.getByRole("button", { name: "Try again", exact: true }); | ||
| await expect.element(retry).toBeVisible(); | ||
| await expect.element(screen.getByText("Environment settings are still loading")).toBeVisible(); | ||
| expect(router.state.location.pathname).toBe("/"); | ||
|
|
||
| await retry.click(); | ||
| await expect.element(retry).toBeVisible(); | ||
| expect(router.state.location.pathname).toBe("/"); | ||
|
|
||
| await act(() => appAtomRegistry.set(configVisible, true)); | ||
| await vi.waitFor(() => expect(router.state.location.pathname).toMatch(/^\/draft\//)); | ||
| const draftId = DraftId.make( | ||
| decodeURIComponent(router.state.location.pathname.split("/").at(-1)!), | ||
| ); | ||
| expect(useComposerDraftStore.getState().getDraftSession(draftId)?.envMode).toBe("worktree"); | ||
| }); |
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
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.
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.