Repository navigation
feat(project-files): let Chat read and write Project files - #9034
mzxchandra wants to merge 20 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
f7da653 to
8e82431
Compare
dc1b9e6 to
d66d69d
Compare
- Keep prepareProjectsForAccountDeletion returning the Project IDs to delete. The object return added an unused storageCleanupEventIds field; the durable cleanup outbox already processes those events, so restore the staging contract and its stronger integration assertions. - Exempt lib/mothership/generated from the relative-import convention. contracts:sync copies those wire contracts verbatim and byte-checks them, so their sibling imports must stay relative; drop their baseline rows. - Re-record the files page module-count baseline for the Project browser. - Type the test fixtures that regressed, including a queue-recovery fixture that persisted the invalid completion status 'success'.
Staging now holds resource-delegated Chat principals to content admission, so a Project callback read with no gate was refused and the sandbox got a 503. Run Project callbacks under the same workbench session gate as workspace callbacks (the gate's workspace is optional, since Projects have none) and share the withheld-result handling. The Project CLI read suite now runs reads under the tool executor's registry gate, as Chat does.
The chat resources API stored a Project-owned tab without checking the projects flag. Refuse new Project tabs while Projects are off; removing or reordering stored tabs stays possible so they can be cleaned up. Also drop the projects flag check in list_user_projects that could never run (listProjects already refuses while the flag is off) and the content delivery barrel export left unused by the shared sandbox delivery helper.
The Project files UI will be built for the project-first redesign, so this PR keeps only the backend and Chat transport behind the projects flag. Restore the workspace Files page, file viewer, Chat resource panel, add-resource and mention entries, and their client query hooks and owner adapters to staging. The previous tip is tagged project-files-ui-seed for that UI work. Kept: the shared ChatContext wire type (Project contexts and file owners reach the Chat server) and its exhaustive kind registry entry. Also drop the UI-only browser constants and response types nothing uses now, restore the files page module-count baseline, and type the use-chat fixtures that returned with the staging test.
Project grep and text reads admitted every Project artifact as opaque bytes, so any file carrying a secret was refused to Chat instead of having the secret masked, unlike the same file in a workspace. Share one text extraction core between workspace text reads and private file observation: parse, redact before a line window can cut a secret, then slice. Project text reads now go through readProjectFileText, which admits the source and every rendered input as complete text and returns text only. The complete artifact read stays private to that use case, so bytes never leave under a complete label; readProjectFileArtifact keeps admitting opaque bytes, and visual reads of a secret still refuse.
…s-product-v2 # Conflicts: # apps/sim/lib/mothership/request/application/recover-stream.ts
|
@cubic-dev-ai review this PR |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 116 files
Confidence score: 3/5
- In
workspace.ts, organization-target workbench receipts may not be scoped and audited to the selected workspace when the chat provides onlychatOrganizationId. PassorganizationId: context.chatOrganizationId ?? context.organizationId.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/mothership/agent-cli/workspace.ts">
<violation number="1" location="apps/sim/lib/mothership/agent-cli/workspace.ts:59">
P2: Organization-target workbench receipts are scoped and audited to the selected workspace when the chat provides only `chatOrganizationId`. Pass `organizationId: context.chatOrganizationId ?? context.organizationId` so receipts retain organization scope across targets and audit records identify the owning organization.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
…tory #9057 hid the projects group from --help and `sim cli` search until launch, and the inventory printer dropped every hidden command, so the Mothership worker lost the Project file commands it routes --project to. List a hidden top-level group that is only unpublished, marked `unpublished`, so the worker can route to it once Sim enables Projects for a turn; other hidden commands stay out, and --help is unchanged.
- Dispatch CLI services before file-owner adapters, so a service that carries a file owner gets the services validation instead of a bridge error. The unreachable Project-side service check is removed. - Check caller-chosen names on Project file renames and folder create and update with the same secret-provenance gate as create and upload, including workbench history for sandbox callbacks. - Move first-message file panel resolution into resolveFileAttachment and replace the mock-only post test with a database-backed check of the saved tab.
|
@greptileai review |
|
@cubic-dev-ai review |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 125 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
# Conflicts: # scripts/check-source-conventions.ts
- The chat resource store now keys tabs with the chat's workspace as the fallback scope, so an unscoped tab and the same tab addressed by that workspace merge instead of duplicating. Upsert, remove and reorder all use the same identity. - Project file renames and folder writes recheck cancellation after the name check and never forward a cancelled write. - Leave the .claude and .cursor import rules to staging, whose source conventions check now exempts generated contract copies itself.
|
@cubic-dev-ai review this PR |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 122 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
- Parse Project file renames and folder writes with their route contracts under the inline body limit before the name check, so an oversized body is refused instead of buffered. Only those routes copy the request. - Treat an equal file owner as unchanged when merging chat tabs, so a repeated upsert stays a no-op.
|
@cubic-dev-ai review this PR |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 122 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 122 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
Summary
Lets Chat read, search, write, upload and copy Project files, on top of the Project files backend that #9015 through #9019 merged.
Everything stays behind the
projectsflag, which turns on only after the project-first redesign ships its Project files UI.Scope: backend and Chat transport only.
The Project file browser and other Project UI were removed from this PR, because the redesign will build that surface project-first rather than inside the workspace Files page.
The removed UI is preserved at the
project-files-ui-seedtag for that work.The only client change left is the shared
ChatContextwire type (Project contexts and file owners) and its kind registry entry.What Chat can do with Project files
projects list) and target one explicitly per command with--project <id>.Secret handling matches workspace files
readProjectFileTextadmits the source and every rendered input ascompletetext and returns text only, so bytes never leave under acompletelabel.readProjectFileArtifactstill admitsopaquebytes, so visual and byte reads of a file with a secret are still refused.Flag gating
list_user_projects, Project file use cases, and sandbox callbacks.list_user_projectsthat could never run was removed.Pairing with simstudioai/mothership#594
This PR and the worker companion merge back to back, Sim first.
Sim sends file-owner hints only when the worker's health check advertises the file-owner protocol, so merging Sim first changes nothing at runtime.
The worker byte-checks Sim's copies of the generated contracts, so the pair must land together; the companion pin will point at this PR's head on
staging.Type of Change
Testing
Reviewers: focus on
readProjectFileTextand the artifact view factory inartifacts.ts, the sharedextractFileTextFromBytes, and the Project sandbox callback gate.Checklist
🤖 Generated with Claude Code