Skip to content

feat(documents): edit a document in place and save it to the project - #3003

Draft
camielvs wants to merge 1 commit into
cvs/document-file-dropfrom
cvs/editable-documents
Draft

camielvs wants to merge 1 commit into
cvs/document-file-dropfrom
cvs/editable-documents

Conversation

@camielvs

@camielvs camielvs commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #2978 (cvs/document-file-drop), which this branch is based on. Review only the top commit.

Intent

Let anyone with a project edit its documents where they already read them — in the Tangent right-hand panel and on the project page — instead of having to delete and re-add a document to change a line. The next PR in the stack (#3004) uses the same editor for code.

Current behavior

A document opened from the Resources window in Tangent, or selected on the project page, is shown in a read-only code viewer. The only document that can be changed after it is added is the project's Instructions, through its own dialog. Everything else is fixed once created.

What changes

A document now opens in a code editor (the same Monaco editor the Add a document dialog uses after #2978) with a small header: the document's name, an Unsaved changes note while you type, and Discard / Save buttons. ⌘S / Ctrl+S saves too. Saving writes the text back to the document in the project; anything else stored in the document's payload is left untouched.

Edits are kept in the editor, not in the shared data cache, so the editor behaves sensibly when an agent changes the same document:

  • While you have typed nothing, the editor simply follows whatever is saved — an agent's update appears as soon as the resource list refreshes.
  • Once you have typed, a save made elsewhere is announced in a banner: Save replaces that version with yours; Discard loads it.
  • Text typed while your own save is in flight is kept rather than overwritten when the save lands.
  • Typing the text back to exactly what is saved disables Save again.

In Tangent, a document tab now stays mounted while another tab is active, so an unsaved draft survives switching tabs. A successful save also seeds the document's cached copy with the server's response, so the editor does not flash the old text between the save and the refetch.

On the project page, selecting a different document opens it in a fresh editor, so a draft typed into one document can never be shown against, or saved into, another.

Both surfaces (Tangent workarea and project page preview) use one DocumentEditor component.

How to test

  1. Open a project in Tangent and, in the Resources window, click a document. It should open in the right-hand panel as an editor with the document's name in the header and Save disabled.
  2. Type something. Unsaved changes should appear and Save / Discard should enable.
  3. Press ⌘S (or Ctrl+S). The browser's save-page dialog should not open; Unsaved changes should clear and Save should disable. Reload the page and reopen the document: the new text should be there.
  4. Type again, then click Discard. The text should return to what is saved.
  5. Type again, switch to another workarea tab (a pipeline, say), and switch back. Your unsaved text should still be there.
  6. With the document open and nothing typed, ask the agent to change the document (or PATCH it through the API) and have it call refresh_project_resources. The editor should show the new text without a banner.
  7. Type something, then have the document changed elsewhere as in step 6. A banner should appear saying the document was changed elsewhere. Click Discard: the editor should show the other version and the banner should go away.
  8. Open the project's page (not Tangent) and select a document under Resources. The Resource preview column should show the same editor, and saving should work the same way.
  9. Still on the project page, select a second document, then the first again, and type into it without saving. Select the second document: it should show its own text, not what you typed, and Save should be disabled.
  10. Select a pipeline or a run in the same column. Those previews should be unchanged.

Automated: the new DocumentEditor.test.tsx covers each editor behaviour above with a mocked editor; ProjectResourcePreview.test.tsx checks that selecting another document opens a fresh editor; documentKind.test.tsx is updated. vitest for the touched folders, tsc and knip pass, and eslint and prettier pass on the touched files. The UI steps have not been walked through in a browser.

Related Issue and Pull requests

Stacked on #2978. Next in the stack: #3004, code as its own kind of document.

Type of Change

  • New feature

Line Breakdown

Category Added Removed
Production code 178 42
Tests 311 44
Total 489 86

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Additional Comments

  • Not done here, worth deciding: nothing asks before unsaved edits are dropped — not when a workarea tab is closed (the workarea registry has no close hook today), and not when another resource is selected on the project page. There is also no success toast: the Unsaved changes label clearing and Save disabling are the feedback.
  • A document whose payload has no content string (for example {}) opens as an empty editor rather than the previous "nothing written in it" message, so it can be written into.
  • "Changed elsewhere" is detected by comparing the saved text with the text at the moment editing began, not by timestamps, so a change to only the document's name does not trigger the banner.

@camielvs
camielvs requested a review from a team as a code owner November 5, 2026 18:56
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🎩 Preview

A preview build has been created at: cvs/editable-documents/2ea79b1

A document opened in the Tangent workarea or selected on the project page
is now a Monaco editor with Save and Discard, not a read-only viewer. Save
writes the body back to the resource's payload (Cmd/Ctrl+S too), keeping
any other payload keys. The draft lives in the component rather than the
query cache, so while nothing has been typed the editor follows a save made
elsewhere (e.g. by an agent), and once something has, that save is
announced with a choice to overwrite or discard into it.

The document workarea kind now stays mounted while inactive so an unsaved
draft survives a tab switch, and a successful update seeds the resource's
query cache so the editor does not flash the old body before the refetch.

On the project page the editor is keyed by the resource, so selecting
another document opens a fresh editor instead of carrying the previous
document's draft over, where Save would have written it into the wrong row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@camielvs
camielvs marked this pull request as draft November 5, 2026 23:38
@camielvs
camielvs force-pushed the cvs/editable-documents branch from 37f1855 to 2ea79b1 Compare November 6, 2026 00:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant