Skip to content

Selecting unavailable source can show chunks from fallback demo source #130

Description

@suguanYang

Summary

Clicking a source that is missing, failed, or not ready can show chunks from a different ready source. In the observed staging case, clicking ncc2022-volume-one compressed.pdf led the chunk panel to request and display NVDA Q1 FY27 Earnings Call Transcript.pdf.

Evidence

Recent staging request after the reported click:

2026-07-05 22:31:48 CST
GET /api/sources/demo-financial-nvda-q1-fy27-earnings-call/chunks -> 200

The NVDA demo endpoint returns chunks with source title NVDA Q1 FY27 Earnings Call Transcript.pdf.

Code Path

useWorkspaceSourceWorkflow exposes selectedSourceId: resolvedSelectedSourceId rather than the raw clicked id.

workspaceSourceState.getResolvedSelectedSourceId(...) falls back to getFirstReadySourceId(sources) when the selected source is not found or not ready.

route-listing.ts orders visible demo sources before workspace sources, so a ready demo source can become the fallback.

Expected Behavior

Clicking a non-ready, failed, or stale source should keep the user focused on that source and show its processing/error/unavailable state. It should not silently select another source and display unrelated chunks.

Suggested Fix

Separate raw selected source id from resolved queryable chunk source id, or make source resolution return an explicit unavailable state instead of falling back to the first ready source for direct user selection.

Verification

Add a client state/hook test: when selectedSourceId points to a non-ready source and other ready demo sources exist, the selected source title remains the clicked source and no unrelated demo chunk request is made.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions