feat: /sessions expand subcommand with context window (F4 UX, Task 2.6.4) #15
Notifications
Due Date
No due date set.
Depends on
#5 feat: Implement Tantivy-based session index for full-text search
terraphim/agent-tasks
Reference: terraphim/agent-tasks#15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
The session-search spec UX example (F4 Interactive Mode) shows:
Today
SessionsSubcommandhasShow { session_id }which dumps the full session, but noExpandvariant that:1) or a session-id--context Nto show N surrounding messages around the matchThis is the canonical AI-agent flow after a robot-mode search: "show me result #1 with surrounding context". Without it, agents must re-fetch the full session and slice it themselves, defeating the purpose of a tight token budget.
Upstream: spec section "User Experience / Interactive Mode", Phase 2 Task 2.6.4.
Acceptance Criteria
SessionsSubcommand::Expand { target: String, context: Option<usize>, highlight: bool }targetaccepts either a UUID, a short hash prefix, or a#Nrank from the last searchcontextdefaults to 3, max 20ReplState(ring buffer of last N search responses keyed by rank index)RobotResponse { data: { session_id, matches: [{ message_id, role, content, timestamp, is_match }], context_before: N, context_after: N } }#Nwith no prior search returnsExitCode::ERROR_USAGE; unknown id returnsExitCode::ERROR_NOT_FOUNDcargo test -p terraphim_agent --features repl-sessionspassescargo clippy -p terraphim_agent --features repl-sessions -- -D warningspassesProposed Approach
terraphim_agentonly (commands.rs, handler.rs, repl state)resolve_expand_target(&self, target: &str)returning(SessionId, Option<MessageId>)SessionService::get_sessionandSession::messagesDependencies
Verification
Scope
Single PR. ~250-350 lines across parser + handler + state + tests.