Repository navigation
Conversation
🎩 PreviewA preview build has been created at: |
d6d8ca5 to
e22b957
Compare
37f1855 to
2ea79b1
Compare
Code is now added as its own kind of document: a document row with
`metadata: { type: "code" }`, so no API change. Both Add menus (Tangent's
Resources window and the project page) offer "Add code" next to "Add a
document"; the same form asks for a filename instead of a title, and the
editor highlights the code by that name.
Code is listed with a FileCode icon and a "Code" label, and opens in the
same document tab and editor a document uses. `languageFor` now knows the
common source-file extensions Monaco ships highlighters for.
The form, both dialogs and both menus share one `DocumentKind` from
resourceDescriptor, and `documentResourceInput` takes it in place of a
separate code builder. Analytics keep the existing `add_document_*`,
`save_document` and `discard_document_edits` events and tell the two
apart with a `kind` field.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e22b957 to
9bfed76
Compare
2ea79b1 to
17c99f6
Compare
camielvs
left a comment
There was a problem hiding this comment.
🤖 This is an AI-generated code review comment.
2 findings, inline below (both Low). Across the stack: if the ⌘S analytics gap on #3003 gets a projects.save_document_completed event, that event should carry kind like the others in this PR.
| namePlaceholder: "model-card.md", | ||
| contentPlaceholder: "What this document records", | ||
| }, | ||
| code: { |
There was a problem hiding this comment.
🤖 This is an AI-generated code review comment.
In code mode, the drop hint and file error still talk about a title and a document. KIND_COPY changes the label to Filename. But the drop hint in DocumentFileDropZone.tsx:45 still says "Drop to fill in the title and content", and a non-text file is rejected with "Only text can be added as a document." (documentFile.ts:12). Consider adding a dropHint here, passed through to DocumentFileDropZone, and a read error that doesn't depend on the kind (e.g. "Only text files can be added.").
| xml: "xml", | ||
| graphql: "graphql", | ||
| proto: "protobuf", | ||
| dockerfile: "dockerfile", |
There was a problem hiding this comment.
🤖 This is an AI-generated code review comment.
Dockerfile only works because a name without a dot is treated as its own extension. When there is no dot, name.split(".").pop() returns the whole name. That is how Dockerfile resolves, and the new test locks it in. But with the new short keys, one-word document titles now get highlighted as code ("Go", "R", "C", "Swift"). Meanwhile the common Dockerfile.dev and Dockerfile.prod fall back to plain text. Suggestion: first look up the basename in a small filename table (dockerfile, dockerfile.*), and use the extension table only when the name contains a dot.
Stacked on #3003 (editable documents), which this branch is based on. Review only the top commit.
Intent
Let people keep code alongside a project's other documents: add it from the same Add menus, and read and edit it in the same editor, highlighted as code.
Current behavior
Everything added through Add a document is a document with a title. A
.pyfile can be pasted in, but nothing marks the row as code, so it is listed and badged like prose.What changes
A new Add code entry sits next to Add a document in the Add menu of Tangent's Resources window, and a Code entry next to Document in the project page's Add menu. Both open the same form (drop a file, browse, or type), but ask for a Filename (for example
train.py) instead of a Title, and highlight the content by that filename's extension.To the API the row is still a document (
entity: "document"); it is markedmetadata: { type: "code" }where a document has{ type: "document" }, so there is no backend change. This is the same waylocal_pipelineandinstructionsrows are already told apart.Once added, code:
languageFornow knows the common source-file extensions Monaco ships highlighters for (Ruby, Go, Rust, Java, C/C++, R, Julia, HTML/CSS,Dockerfile,.ipynbas JSON, and so on), which also improves highlighting of existing documents with those names.Analytics: code reuses the existing
projects.add_document_*,projects.save_documentandprojects.discard_document_editsevents, which now carrykind: "document"orkind: "code".How to test
train.py.train.pyas the filename and a line of Python as the content. The content should highlight as Python. Click Add..rbor.gofile onto either dialog. The filename should fill in and the content should highlight in that language.Automated: tests cover the form's two kinds, both Add menus, the Resources window opening code in a document tab, the
kindon the editor's Save event,documentKindOfanddocumentResourceInput, andlanguageFor. The fullvitestsuite (488 files),tscandknippass, andeslintandprettierpass on the touched files. The UI steps have not been walked through in a browser.Related Issue and Pull requests
Stacked on #3003, which is based on
masternow that #2978 is merged.Follow-up, not in this PR: teach the agent tooling in tangent-shell / tangent-shell-shopify that a document with
type: "code"is code, so agents find, read and update it through the project resources API in oasis-backend like any other document. The API itself needs no change, because a resource'sdatatakes any JSON object.Type of Change
Line Breakdown
Checklist
Additional Comments
codeis a descriptor type, not a new API entity: a newProjectResourceEntitymember would mean a backend change and regenerated types, and nothing here needs one.