Repository navigation
Studio: share attached files across a project - #8756
Conversation
Files attached inside a chat that belongs to a project were indexed at thread scope only, so a new chat in the same project could not see them: thread_A docs: ['notes.txt'] thread_B docs: [] # same project project docs : [] The composer had no way to attach to the project at all. Project sources existed, but only behind the Sources tab on the project page, so a file dropped into a project chat was silently private to that chat. Project chats now file attachments against the project by default, with a Project / This chat switch on the composer, and the bar lists the project's existing sources next to the chat's own. Retrieval already combined both scopes, so nothing changed server side. Two related fixes: resolveProjectId read the thread row without awaiting the write that initialize() starts and does not await, so a fresh chat's first message could conclude it had no project and drop the project's sources, instructions and sandbox. A failed lookup returns no project; only a confirmed-absent row falls back to the composer's project. The bar read the global activeProjectId, which the chat page updates only after its own async lookup, so during a navigation it still named the project the user had just left. It now resolves the project from the displayed chat's own row. Project sources retrieve whenever the project has them, Docs pill or not, so with the pill off they are listed read-only rather than letting the model answer from files the user cannot see.
…roject Moving the open chat to another project updates its row and activeProjectId without changing the thread id, so the composer kept resolving the old project and would have filed new attachments there. The lookup now re-runs on that change and re-reads the row. The composer's documents bar and the project's Sources panel are separate hook instances over the same scope and are mounted together on the project landing page, so a file added in one stayed invisible to the other and did not count towards the composer's indexing gate. Every project-source mutation already funnels through invalidateProjectSources, so that now emits an event both instances refresh on. resolveProjectId read activeProjectId after awaiting the thread row. A send survives navigation, so a first message in one project could adopt the project the user moved to while the lookup was in flight. It is read before the await now.
|
All three were real. Fixed in ab916dc. Moving the open chat between projects (P1). Confirmed in Sources panel and composer out of sync (P1). Confirmed: Fallback read after the await (P1). Correct, and it defeats the point of the guard I had just added. Checks: 2302 frontend tests pass, typecheck and build clean, lint at parity with Still not verified: none of this has been clicked through in a browser. |
A run resolves the project separately for the sandbox, the RAG scope and the instructions. While a fresh thread's row is still being written all three take the composer fallback, so navigating between those calls could combine one project's sandbox with another's instructions. The fallback is answered once per pending thread and reused until the row lands. Changing activeProjectId starts the re-read but left the previous answer usable until it completed, so an attachment in that window still targeted the old project. The answer is now tagged with the activeProjectId it was produced for, so a change makes it unresolved immediately. The read-only project source list shown with the Docs pill off was uncapped, so a linked folder with many files could grow the composer through the viewport. Same max-h-24 and scrolling as the editable list.
|
Three of the four hold. Fixed in c80ac7d. One originating project per run (P1). Correct. My previous fix only made a single lookup atomic; the run resolves the project three times (sandbox session, RAG scope, project instructions) and a fresh thread whose row has not landed takes the composer fallback in each. Navigating between them really could pair one project's sandbox with another's instructions. The fallback is now answered once per pending thread and reused until the row lands, at which point the row wins and the entry is dropped. Stale scope during re-resolution (P1). Correct, and it undercut the fix it was reviewing: the dependency triggered a re-read but the previous answer stayed actionable until it completed, so a fast attach in that window still went to the old project. The answer now carries the Cap the inherited list (P2). Correct. The editable list uses Browser document drops (P2). The observation is accurate but I do not think the change belongs in this PR, so I have left it.
Routing web document drops into RAG means deciding which MIME types stop being inline attachments, changing behaviour for every chat rather than project chats, and picking what a drop should do when the Docs pill is off. That is a platform-consistency change worth doing on its own, not a rider on project file sharing. Happy to open a follow-up if you agree with the direction. Checks: 2302 frontend tests, typecheck and build clean, lint one error better than |
…per chat A project source mutation invalidates before and after itself, so each one starts two list requests. They were unsequenced, so an earlier response landing last put the pre-mutation list back: the composer's bar showed no sources and reported nothing indexing, opening the send gate on a file still being indexed. refresh now publishes only the newest request. The attach menu presented itself as a per-chat choice but wrote the single persisted setting, so picking This chat in one chat redirected every other chat in the project and every later session. The choice is now an override kept per chat, with the saved setting as the default behind it, and a pick made before the chat has an id follows it once it does. Settings copy says default rather than per chat.
|
Both correct. Fixed in de3dda3. Unsequenced source refreshes (P1). Confirmed.
Attach override was global (P2). Correct, and my own Settings copy claimed otherwise: it said "Change it per chat from the attach menu" while the menu wrote the single persisted key. Picking This chat in one chat redirected every other project chat and every later session. The choice is now an override kept per chat, with the saved setting as the default behind it. A pick made before the chat has an id follows it once the thread materialises, so choosing This chat on the project landing page and then attaching still scopes to the chat that gets created. The Settings row is described as the default now. One judgement call worth flagging: the override is session-scoped rather than persisted. Persisting it per chat means a field on the thread record, which is a schema change well outside this PR. The menu always shows the target in force before you attach, so the reload case is visible rather than silent, and the blast radius is now one chat instead of all of them. Say the word if you would rather have the schema change. Checks: 2305 frontend tests, typecheck, build and locale parity clean. |
…in send Clearing the scope started no replacement request, so a list response still in flight for the old project published into the new one. The scope-change effect now takes a ticket on the way out. A chat is created by sending a message as often as by attaching a file, and only the attach path adopted the target chosen before the chat existed. The id arriving as a prop adopts it too, and a chat that already made its own choice keeps it.
|
Both correct. Fixed in a904de0. A response for a cleared scope still published (P1). Confirmed. The scope-change effect clears the list and then starts a replacement request only The effect now takes a ticket on the way out, before clearing, so a response for the old scope can never outrank it. Pinned by a test that resolves a request after its scope has been cleared, plus a check that the effect keeps doing it. The pending attach target was only adopted on one path (P2). Correct. The id arriving as a prop now adopts it too, on the null to real transition. A chat that already has its own override keeps it, so an adoption that fires for some other reason cannot overwrite a real choice. Checks: 2311 frontend tests, typecheck, build and lint at parity with Still not verified: none of this has been clicked through in a browser. |
…d scopes The row lookup returning null meant both no project and not read yet, so a quick attach in that window filed the file into the chat. Unresolved is now distinct: the attach controls hold and a desktop drop stays in the store until the row has been read. The composer project is captured before the run's first await, so hydration or a model load cannot let navigation change which project the send belongs to. A composer abandoned before it became a chat no longer leaves its attach choice for the next new chat to inherit. Where the vector extension cannot load, project sources are not requested and a superseded refresh no longer toasts, so opening a project chat is quiet.
|
All five hold. Fixed in 8f55faa. The project was sampled after the pre-stream awaits (P1). Correct, and it is the part my earlier fix did not reach: it made a single lookup atomic and then answered the fallback once per thread, but the map is only seeded by the first Attaching before the chat's project is known (P2). Correct. One deliberate exception. A rejected lookup still resolves to "no project" rather than staying held. It is not proof of no project, but the alternative is an attach button disabled for the rest of the session, and filing into the chat is the choice that cannot leak a file into a project it does not belong to. An abandoned pending choice (P2). Correct. Picking a target in a fresh composer and then navigating away without sending or attaching left the entry under the singleton key for the next new chat to read as its own. The composer drops an unclaimed choice when it goes away. Adoption already removes the key, so this only ever clears one that no chat took. Project sources requested where RAG cannot run (P2). Correct, and worth fixing on both sides. The composer now opens no project scope once availability has been measured as unavailable, so a host without the extension does not issue one doomed request per project chat opened. The toast is also suppressed for that measured failure, which covers the first request as well, since Failures from superseded refreshes (P2). Correct: the generation check guarded the publish but not the Checks: 2318 frontend tests, typecheck, build and lint at parity with Still not verified: none of this has been clicked through in a browser. |
The Sources panel invalidates before its POST as well as after, so the composer's refresh returned the pre-upload list and it reported nothing indexing for however long the upload took. A send could go out that the file could not reach. Project uploads in flight are published per project, so the instance that is not doing the upload gates from the moment it starts rather than from the moment a row appears. The composer reads indexing from the hooks now instead of from the rows they have listed.
|
Correct. Fixed in f83e74c.
Project uploads in flight are now published per project, incremented before the first await and decremented in the same The composer passes its project scope to Checks: 2320 frontend tests, typecheck, build and lint at parity with Still not verified: none of this has been clicked through in a browser. |
A folder sync reports at start and completion only, and the rows it creates appear as it runs, so the start refresh returned before there was anything to see and the composer stayed sendable and stopped polling for the whole job. The upload counter is now a project work counter in rag-api, and a tracked sync job counts as work on its project. Every path out of a job ends in a release or an abort, so an unmount, a scope change or an unlink cannot leave the count standing.
|
Correct. Fixed in cd7ffbd. Confirmed in The upload counter added last round is now a project work counter in The leak was the thing to get right, since a count left standing would gate the composer for the rest of the session. Every path out of a tracked job ends in either Checks: 2320 frontend tests, typecheck, build, lint errors at parity with Still not verified: none of this has been clicked through in a browser. |
Folder gating followed the component that started the sync, so leaving the Sources tab aborted its event stream and released the gate while the backend job carried on. It follows the job now, bounded so a job that never reports a terminal state cannot gate a project for the session. A list slower than the four second poll retired itself: each tick took a newer ticket before the previous response landed, so nothing ever published, the row being watched never reached completed, and a queued send waited on it forever. A tick is skipped while one is still out. Reopening a project whose job is already running lists nothing yet and counts no work of its own, so the gate now holds until that first list lands. Invalidations cross tabs. A CustomEvent reaches only the tab that fired it, so a second tab kept listing the sources it saw first.
|
All four hold. Fixed in 34afdcb. Folder gating released on unmount (P1). Correct, and it is the flip side of the leak I was guarding against last round. Leaving Sources for Chats unmounts The poll retiring itself (P1). Correct, and worse than a missed refresh. With list requests slower than the four second interval, every tick took a newer ticket before the previous response landed, so the sequence gate dropped all of them. The composer does not own the indexing job's stream, so the list is how it learns the row completed: The first list of a reopened project (P1). Correct. A project reopened while one of its jobs is already running lists nothing yet, and no upload of this instance's is counted, so the gate was open until the running row arrived. The gate now holds until that first list lands. Invalidations across tabs (P2). Correct. Both tabs are looking at the same project, and a The work counter is deliberately not broadcast. A count is per tab and a tab that closes mid-upload would leave the other one gated with nothing to release it. Checks: 2323 frontend tests, typecheck, build and lint errors at parity with Still not verified: none of this has been clicked through in a browser. |
Three gaps in the composer's "sources still settling" gate. A superseded list request cleared the loading flag, so the composer could report the list as known while the request that would publish it was still out. Only the newest request clears it now. A delete was not counted as work on the project. The chip goes at once but the source is there until the DELETE returns, and the probe is invalidated after that, so a send in between could still retrieve it. Work in flight did not cross tabs. Only the invalidation did, so a second tab kept sending through an upload running in the first. Work now broadcasts as well, with a deadline on what another tab reports so a tab closed mid-upload cannot gate the project for the session.
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…settings and the project attachment target
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Splits #8751 in two. This is the project files half; per-model chat parameters are in #8757.
From feedback on Studio chat:
The problem
A file attached inside a chat that belongs to a project is indexed at thread scope, so no other chat in the project can see it:
The composer's Docs bar only ever had two scopes,
threadandkb, so there was no way to attach a file to the project from a chat and no sign that the file you just dropped was chat-private. Project sources did exist, but only through the separate Sources tab on the project page.The change
Project chats now file new attachments against the project by default, with a
Project / This chatmenu on the composer for per-chat overrides. The bar also lists the project's existing sources inline (folder glyph) beside the chat's own documents, so inherited context is visible instead of merely in effect.Retrieval already combined project and thread scopes server side (
core/rag/tool.py), so the mechanism works end to end once the upload lands in the right place:Three related fixes found along the way
A fresh chat's first message could lose its project entirely.
initialize()starts the thread row write without awaiting it, so the first send could read ahead of its own row, conclude the chat had no project, and drop the project's sources, instructions and sandbox from exactly the message the project was opened to ask.resolveProjectIdnow falls back to the composer's project for a confirmed-absent row, and never for incognito threads, which are deliberately unpersisted. A failed lookup returns no project rather than adopting whichever project was last open.The bar read the global
activeProjectId.chat-page.tsxupdates that only after its own asyncgetStoredChatThread, so during a navigation away from a project chat it still named the project the user had just left, and a quick drop could land in it. The bar now resolves the project from the displayed chat's own row and suppresses the project affordances while that is unresolved.Project sources were invisible with the Docs pill off.
chat-adapter.tsgates retrieval onragEnabled || projectRagEnabled, so project files reach the model whenever the project has them, but the bar returned null and showed nothing. Those sources are now listed read-only in that state. The attach controls stay behind the pill, since thread scope is inert there. The KB gate is aligned with the adapter too: an active KB replaces the project scope, but a KB preference left over while the pill is off does not.Testing
Frontend tests, typecheck, build and locale parity all pass, and lint matches
main. The project scoping was verified end to end over the API and against the RAG scope resolver.Not verified: the composer menu, the inline chips and the read-only project sources row have not been clicked through in a browser.
Note on merging
Touches four files that #8757 also touches (the runtime store, the settings tab, the settings search index and
en.ts), in each case adding adjacent lines at the same anchor. Whichever lands second needs a trivial keep-both rebase. I confirmed the two branches combine to exactly the content of #8751, differing only in the order of the two settings rows.