Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ export function getChatLandingInitialDataLoading({
localMachineStateAttempted,
hasSelectableMachine,
}: ChatLandingInitialDataLoadingArgs): boolean {
if (isRuntimeInitializing || !isDocMetaCacheReady || !localMachineStateAttempted) {
if (isRuntimeInitializing || !localMachineStateAttempted) {
return true;
}

return isVisibleMachinesLoading && !hasSelectableMachine;
return (!isDocMetaCacheReady || isVisibleMachinesLoading) && !hasSelectableMachine;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Source the early machine outside the scoped visibility gate

On both local and cloud /$workspaceName/chat routes, ChatLanding is under WorkspaceRouteTargetProvider (routes/$workspaceName.tsx:95-102), and its selectableMachines comes from useVisibleMachineMetas, whose enabled flag is supplied by useResolvedWorkspaceScope (use-visible-machine-metas.ts:48-56). That scope remains disabled until docMetaScope.ready (use-resolved-workspace-scope.ts:28-49), which flips true alongside docMetaCacheReady only after the metadata scan (atoms/doc-meta.ts:813-830); while disabled, the visibility hook exposes no machines. Therefore hasSelectableMachine cannot be true during the !isDocMetaCacheReady window, so this new exception is unreachable in the shipped routes and the picker still waits for the full scan. The early selectable state needs to come from a source that is available before this scope-ready gate.

AGENTS.md reference: AGENTS.md:L129-L134

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as-is. ChatLanding sits under WorkspaceRouteTargetProvider, and useVisibleMachineMetas is disabled until docMetaScope.ready (resolveWorkspaceDataScope requires that). While disabled the visibility index is empty, so hasSelectableMachine cannot be true in the !isDocMetaCacheReady window. Reading the singleton machine cache before that gate would break the workspace-switch invariant. The Convex visibility fail-open after doc-meta is ready is the path that actually fires. Expanding this PR to a second machine source is out of scope.

}

export function getChatLandingLocalProjectAvailability({
Expand Down
14 changes: 13 additions & 1 deletion packages/components/tests/chat-landing-derived.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ describe('getChatLandingInitialDataLoading', () => {
localMachineStateAttempted: true,
hasSelectableMachine: true,
})
).toBe(true);
).toBe(false);

expect(
getChatLandingInitialDataLoading({
Expand All @@ -429,6 +429,18 @@ describe('getChatLandingInitialDataLoading', () => {
).toBe(true);
});

it('keeps loading while doc metadata is pending and no selectable machine exists', () => {
expect(
getChatLandingInitialDataLoading({
isRuntimeInitializing: false,
isVisibleMachinesLoading: false,
isDocMetaCacheReady: false,
localMachineStateAttempted: true,
hasSelectableMachine: false,
})
).toBe(true);
});

it('continues initial loading while machine visibility is pending and no local option exists', () => {
expect(
getChatLandingInitialDataLoading({
Expand Down
Loading