Skip to content

feat(tui): add /context inventory and /drop to remove attached files#3450

Open
Sayt-0 wants to merge 1 commit into
mainfrom
feat/context-inventory-drop
Open

feat(tui): add /context inventory and /drop to remove attached files#3450
Sayt-0 wants to merge 1 commit into
mainfrom
feat/context-inventory-drop

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Jul 3, 2026

Copy link
Copy Markdown
Member

Closes #3435

Summary

Adds an Aider-style context inventory to the TUI: a /context dialog listing every file currently entering the session context (attachments and prompt files) with per-item token estimates, plus the ability to drop attachments, interactively or via /drop <path>.

Issue expectations mapping

Issue expectation Implemented
List attached files and prompt files with a per-item token estimate /context dialog with "Attached files" and "Prompt files (agent config)" sections, ~N tokens per file (size/4, the same rule of thumb as the session truncation budget), plus a totals line
Allow removing an attachment from the session d/x/delete/backspace on the selected entry, or /drop <path> directly; /drop without argument opens the dialog
Removal API on Session.AttachedFiles Session.RemoveAttachedFile(absPath) bool, mutex-guarded, next to AddAttachedFile
Keep @ref completion consistent (editor.go) No editor change needed: @ completion lists workspace files (session-independent); re-mentioning a dropped file re-attaches it through the existing send path

Flow

/context ──► ShowContextDialogMsg ──► Session.AttachedFilesSnapshot()
                                      + App.CurrentAgentPromptFiles()   (local runtime only)
                                  ──► NewContextDialog(BuildContextFiles(...))

d (dialog) ─┐
/drop path ─┴► DropAttachedFileMsg ──► expand ~/$VAR + filepath.Abs
                                   ──► Session.RemoveAttachedFile()
                                   ──► SessionStore.UpdateSession()
                                   ──► notification toast

Notes

  • Prompt files are listed but not droppable: they are re-resolved from the agent config at every turn (add_prompt_files hook), so dropping one is refused with an info toast.
  • Prompt-file paths are resolved with the same lookup rules as the turn-start hook (promptfiles.PathsFromEnv), exposed through an optional runtime capability; remote runtimes simply omit the section.
  • Files deleted since attachment render as missing (no token estimate).
  • Dropped entries are persisted via SessionStore.UpdateSession so resumed sessions do not resurrect them.
  • Long lists use a sliding window that keeps the selection visible.

Testing

  • Unit tests: Session.RemoveAttachedFile (3 cases) and the context dialog (8 cases: entry building, empty state, sections/token rendering, navigation bounds, drop semantics, prompt-file refusal, selection clamping, close).
  • go build ./... and golangci-lint run: clean.
  • Full go test ./...: green except TestURLSource_Read_RejectsLocalAddresses (pkg/config), which fails identically on main in this environment (network-dependent, unrelated to this change).

List attached files and prompt files with per-item token estimates in a
new /context dialog, and allow dropping attachments from the session
(d key in the dialog, or /drop <path>). Adds Session.RemoveAttachedFile
and resolves the current agent's add_prompt_files entries through the
same lookup rules as the turn-start hook.

Closes #3435
@Sayt-0 Sayt-0 requested a review from a team as a code owner July 3, 2026 14:50
@Sayt-0 Sayt-0 added area/tui For features/issues/fixes related to the TUI area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/tui For features/issues/fixes related to the TUI kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tui): context inventory — list and remove attached/prompt files (/drop)

1 participant