Repository navigation
Conversation
🎩 PreviewA preview build has been created at: |
maxy-shpfy
reviewed
Nov 2, 2026
camielvs
force-pushed
the
cvs/document-file-drop
branch
from
November 2, 2026 21:32
01cbab4 to
6eed9fc
Compare
camielvs
force-pushed
the
cvs/document-file-drop
branch
2 times, most recently
from
November 2, 2026 23:45
73ba5f6 to
76e3b2e
Compare
maxy-shpfy
reviewed
Nov 3, 2026
maxy-shpfy
reviewed
Nov 3, 2026
maxy-shpfy
reviewed
Nov 3, 2026
maxy-shpfy
reviewed
Nov 3, 2026
camielvs
force-pushed
the
cvs/document-file-drop
branch
from
November 3, 2026 17:11
76e3b2e to
92cefc8
Compare
1 of 3 tasks
The Add a document dialog had two plain fields, so the only way to add an existing file was to paste it in. Long content also pushed the dialog off the page: the textarea grew to fit every line, down and sideways. A dashed strip above Title now takes a dropped file, or a browsed one. The whole form accepts the drop, so a near miss doesn't open the file in the tab. The file's name becomes the title unless one was typed, and its text becomes the content. Only UTF-8 text up to 1 MB is accepted; anything else says why and leaves the fields alone. Content is now the shared code editor in a fixed-height box, with word wrap, so long files scroll and long lines wrap. It highlights by the title's extension, the same rule the document viewers use, which is why a dropped file keeps its extension in the title. Both document dialogs are wider to give the editor room. CodeEditor takes an options override for the editor's aria label and placeholder. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The app already reads uploaded files four ways, and none checks that a file is text or caps its size. Only part of the document reader was about documents, so the general part moves out where the other file pickers can adopt it. readTextFile in src/utils/textFile.ts reads a file as strict UTF-8 under an optional byte limit. It returns a reason rather than a message, so each caller words its own errors. documentFile.ts keeps what is about documents: the 1 MB limit, the messages and the title. useFileDrop moves to src/hooks with its own tests; the form's tests keep only what the form adds on top. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
readTextFile in src/utils duplicated readTextFromFile in src/utils/dom.ts, and it and useFileDrop each had one caller. useFileDrop moves back next to DocumentForm, and textFile.ts goes away. readTextFromFile becomes the strict reader: it decodes UTF-8 with fatal errors and refuses NUL bytes, throwing NotTextFileError so the documents reader can word its own message. The .yaml check that lived inside it moves to readYamlFromFile, which the two canvas drop handlers now call, so they still refuse other files. They also gain the text check, and a file the browser can't read now rejects instead of never settling. The 1 MB limit stays in documentFile.ts, now checked before reading. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each read filled the form when it finished. If an earlier file finished after a later one, the title stayed the later file's while the content became the earlier file's. Only the latest read now fills the form, and Add stays disabled until it finishes, so the draft can't be added while it is about to change. Local files read instantly, but files kept in a cloud drive can take seconds to download first. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
camielvs
force-pushed
the
cvs/document-file-drop
branch
from
November 3, 2026 23:45
a003c45 to
e1caf41
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
You can now add a document from a file: drop one onto the Add a document dialog, or click browse. Its name becomes the Title and its text the Content. The Content field is now the shared code editor, so long files scroll and long lines wrap instead of pushing the dialog off the page.
File drop
Code editor
CodeEditor(Monaco) in a fixed-height box styled like an input, with word wrap and line numbers.languageFor, the same rule the document viewers use when a saved document is shown later. That's why a dropped file keeps its extension in the title (train.py, nottrain), and why the Title placeholder is nowmodel-card.md.CodeEditortakes an optionaloptionsprop that overrides its defaults; it's used here for the aria label and placeholder. Other callers are unchanged.sm:max-w-4xl(896px) instead of 512px, to give the editor room.Shared helpers
readTextFileinsrc/utils/textFile.tsreads a file as strict UTF-8 under an optional byte limit. It returns a reason (too_large,not_textorunreadable) instead of a message, so each caller words its own errors.useFileDropinsrc/hooks/handles dragging and dropping a file onto any element, and reports while a file is over it.Analytics
projects.add_document_from_file_completedfires withmethod: "drop" | "browse". The file name is never sent.projects.add_document_browse_file.click.Related Issue and Pull requests
None.
Type of Change
Line Breakdown
Checklist
Test Instructions
.md,.yamlor.pyfile anywhere on the form. Title should become the file name, and Content the file's text, highlighted for that language.Additional Comments
DialogContent'ssm:max-w-*replaces itsmax-w-[calc(100%-2rem)]margin. Every large dialog in the app already does this.🤖 Generated with Claude Code
future follow-up: standardize our various file picker workflows into a filepicker component.