feat: link files & folders to the global AI chat#9520
Open
Guilhem-lm wants to merge 6 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e UI Persistence (survive reload, scoped to session.id): - IndexedDB store (attachedFilesDB) holding Blob snapshots (every browser) and re-grantable File System Access directory handles (capable browsers) - restore on session activation; re-grant locked handles on the next send; flush in-memory items when the session persists; GC on session delete - capability via feature-detection (fsAccess), never UA sniffing - folders auto-refresh (live re-enumerate + reconcile) on each send @-mention file picker: - Files branch in ChatContextPicker (new DrillPicker architecture); a linked folder's files render as a nested directory tree, picking inserts @filename - attached-file mentions highlight in the input just like context mentions UI polish: - file/folder chips reuse the context-element chip style (icon -> X on hover) - file + context badges sit above the fork/draft bar - disabled dropdown items can surface an explanatory tooltip (DropdownV2Inner) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploying windmill with
|
| Latest commit: |
35de6e3
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://768e546a.windmill.pages.dev |
| Branch Preview URL: | https://glm-add-files-to-ai-chat.windmill.pages.dev |
…jects Two seam fixes from an architecture pass, no behaviour change: - addFolder(dirHandle) now enumerates internally (same junk-filtered walk used on restore/refresh), so callers never pre-enumerate. The dead drop-walkers (collectDroppedEntries, filterFolderPickerFiles) are deleted; isIgnoredPath/MAX_FOLDER_FILES move next to enumerateDir in fsAccess. - The store exposes `folders` (name + aggregate status + children) and `standalone` as derived views, so the bar, the @-menu picker, the folder chip and the system-prompt roster stop re-grouping the flat row list and re-deriving folder status. Placeholder rows (isFolderRoot) become an implementation detail; the roster renders a locked folder as one line. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
In GLOBAL mode selected context already appears as a highlighted @mention in the input (deleting the mention deselects), so the hoisted badge row above the chat duplicated it. File chips keep their row — attachments aren't represented in the input. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- requestReadPermission/queryReadPermission never reject (the spec rejects with SecurityError when user activation is missing — now mapped to denied/prompt), and sendRequest wraps attachment upkeep in try/catch, so a permission hiccup can never silently swallow a Send. - regrantLocked expands before dropping the locked placeholder: when the re-granted directory is gone from disk, the folder now shows "unavailable" instead of vanishing into a zombie that resurrects locked on the next reload. - addFolder: re-picking a locked/unavailable folder relinks it (natural recovery gesture); a genuine second folder with the same basename gets a visible "already linked" rejection instead of a silent no-op. - fileEngine: readFile clamps its byte slice to maxChars*4 before decoding and streamLines caps its per-line buffer, so newline-sparse files (minified JS, single-line JSONL) can't materialize unbounded strings; corrected the scan-cap comment's claim about catastrophic backtracking. 4 new unit tests (41 total). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Lets users attach files and link folders to the global AI chat (sessions). Attached content is not inlined into the prompt context — instead the assistant gets
search_files/read_filetools plus an auto-injected roster, so it pulls exactly the lines it needs across many/large files without blowing up the context window.Everything is frontend-only and nothing is uploaded to a server:
Highlights
+menu or by drag-and-drop. Junk (node_modules, dotfiles) is skipped; a folder collapses to a single chip.@-menu file picker — attached files are pickable from@, and a linked folder's files render as a nested directory tree. Picking inserts an@filenamemention.@filenamementions highlight in the input just like context mentions.Screenshots
@-menu — a linked folder's files as a nested tree (chips above match the context chips):@filenamementions highlight in the input like context mentions (@legacy.tsis not attached, so it stays plain):How it works
fileEnginebuilds a line-offset index and lazily slices files (operates onBlob, soFile | Blobboth work — no full-content reads).fileToolsexposessearch_files(regex) andread_file(line ranges) to the assistant; a compact roster is appended to the system message.attachedFilesDB(idb) stores Blob snapshots + re-grantable FS-Access handles keyed bysession.id— restore on session activation, re-grant locked handles on send, flush on persist, GC on session delete. Capability via feature-detection (fsAccess), never UA sniffing. Folders re-enumerate + reconcile each send so renames/adds/deletes are picked up.@-menu integrates as aFilesbranch in the unifiedDrillPicker(ChatContextPicker).Testing
fileEngine,fsAccess,attachedFilesDB,attachedFiles(incl. folder refresh diffing) andfolderDrop.@-menu nested tree, persistence round-trip, and mention highlighting.Frontend-only; GLOBAL chat (sessions) only. No backend/OpenAPI changes.
🤖 Generated with Claude Code