Split input/editor.rs
Status: Open — Phase 2, confirmation needed
Problem
Section titled “Problem”src/console/manager/input/editor.rs is 3955L total (was ~3796L at original analysis). It handles keyboard dispatch for all editor tabs (General, Mounts, Agents, Secrets) and is one of the biggest concentrated editor-state files.
Its render counterpart src/console/manager/render/editor.rs is now 3231L (was ~1682L — nearly doubled). Both files should be split together as a paired operation.
Proposed split
Section titled “Proposed split”src/console/manager/input/editor/ mod.rs ← re-exports, handle_editor_key dispatcher, handle_editor_modal dispatcher general.rs ← General tab key handlers (~100L) mounts.rs ← Mounts tab key handlers (~150L) agents.rs ← toggle_agent_allowed, toggle_default_agent, open_agent_override_picker (~80L) secrets.rs ← Secrets tab key handlers (~500L — the AI-generated section)The render counterpart would split similarly:
src/console/manager/render/editor/ mod.rs ← re-exports, render_editor dispatcher general.rs ← General tab rendering mounts.rs ← Mounts tab rendering agents.rs ← Agents tab rendering secrets.rs ← Secrets tab renderingKey technical details
Section titled “Key technical details”handle_editor_key— main dispatcher; stays inmod.rshandle_editor_modal— modal commit handling; stays inmod.rs- Both functions dispatch to tab-specific helpers; the helpers move to per-tab files
- After split, helper imports such as
super::super::agent_allow::allows_all_agentsshould switch to a stable absolute path (crate::console::manager::agent_allow::allows_all_agents) becauseeditor/becomes one level deeper
Duplication found within this file
Section titled “Duplication found within this file”config_with_agentstest helper is defined identically 4 times acrossrender/editor.rs(3 copies) andinput/editor.rs(1 copy) — extract to shared test utility- Breadcrumb rendering logic at
render/editor.rs:1427-1455(push_op_breadcrumb_spans) is fully duplicated inline at lines 1058–1091 insidesecrets_key_row_spans— the inline version should call the shared function - The file crosses the console/runtime boundary at 2 production-code sites:
crate::runtime::register_agent_repo(line ~1445) andcrate::runtime::RepoError(lines ~1536-1547)
What needs confirmation
Section titled “What needs confirmation”Should handle_editor_modal stay in mod.rs or move to a modal.rs sub-file? This depends on its size post-split and whether it’s a “modal concern” or a “dispatch concern”.
Auditability gain
Section titled “Auditability gain”To audit “did the AI correctly implement the Secrets tab?”, a reviewer reads only secrets.rs instead of scanning ~3955L of mixed-tab production code.
- Complete Phase 1.5 TUI rendering DRY extractions first (named styles,
titled_blockhelper). - Complete snapshot tests item first (regression net).
- Create
src/console/manager/input/editor/andsrc/console/manager/render/editor/directories. - Move each tab’s handlers to the appropriate file, keeping
mod.rsas the dispatcher. - Fix import paths (the
super::super::depth changes). - Verify
cargo nextest runpasses.