Extract terminal file-upload logic into terminal-uploads.ts#796
Merged
Conversation
use-terminal.ts is a 916-line complexity hotspot. The self-contained drag/drop + paste upload orchestration (validation, upload loop, toast feedback) had no dependency on the terminal connection lifecycle, so it moves cleanly into a new terminal-uploads.ts module — continuing the established extraction pattern (terminal-socket.ts #659, terminal-surface.ts #664). Pure code move: the hook's uploadFiles callback now delegates to uploadTerminalFiles(). No behavior change. Hook shrinks 916 -> 867 lines and sheds the sonner/media-upload imports. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
What
Moves the self-contained file-upload orchestration out of the 916-line
use-terminal.tshook into a newapps/web/src/hooks/terminal-uploads.tsmodule. The hook'suploadFilescallback now delegates touploadTerminalFiles(agentId, files, setUploadingFiles).Why it's tech debt
use-terminal.tsis a flagged complexity hotspot. The drag/drop + clipboard-paste upload logic (file-type validation, the upload loop, and toast feedback) had no dependency on the terminal connection lifecycle — it only needed the connected agent id and the "uploading" state setter. Pulling it into a module continues the established extraction pattern already applied to this file (terminal-socket.ts#659,terminal-surface.ts#664) and keeps the hook body focused on the WebSocket/connection lifecycle.This is a pure behavior-preserving code move — the extracted function is byte-identical logic, and the hook sheds its
sonnerandmedia-uploadimports. Hook shrinks 916 → 867 lines.Not in scope
The backlog item's original framing ("split
use-terminal.tsinto focused connection/resize/reconnect/focus hooks") was deliberately not attempted — that logic is tightly coupled through ~15 shared refs and the subtle WebSocket reconnect lifecycle, so a hook split would be high-risk churn with no behavior change. This PR takes the safe, incremental slice instead. Pre-existing issues in the file are untouched.Validation
pnpm run check✓pnpm run finalize:web✓pnpm run test:e2e✓ (168 passed, 13terminal-livetests skipped as usual — they require a live tmux env)Queued for next run
Re-audit remaining complexity hotspots;
agents-view.tsx(1006 lines) is on the backlog but is a hot, frequently-changed file — verify no in-flight work before touching it.🤖 Generated with Claude Code