x: remove Ctrl+O tool output expansion feature (#13640)

This commit is contained in:
Parth Sareen
2026-01-07 15:34:08 -08:00
committed by GitHub
parent 12e2b3514a
commit e30e08a7d6
3 changed files with 11 additions and 57 deletions

View File

@@ -6,9 +6,6 @@ import (
var ErrInterrupt = errors.New("Interrupt") var ErrInterrupt = errors.New("Interrupt")
// ErrExpandOutput is returned when user presses Ctrl+O to expand tool output
var ErrExpandOutput = errors.New("ExpandOutput")
type InterruptError struct { type InterruptError struct {
Line []rune Line []rune
} }

View File

@@ -206,9 +206,6 @@ func (i *Instance) Readline() (string, error) {
buf.DeleteBefore() buf.DeleteBefore()
case CharCtrlL: case CharCtrlL:
buf.ClearScreen() buf.ClearScreen()
case CharCtrlO:
// Ctrl+O - expand tool output
return "", ErrExpandOutput
case CharCtrlW: case CharCtrlW:
buf.DeleteWord() buf.DeleteWord()
case CharCtrlZ: case CharCtrlZ:

View File

@@ -137,13 +137,6 @@ type RunOptions struct {
// YoloMode skips all tool approval prompts // YoloMode skips all tool approval prompts
YoloMode bool YoloMode bool
// LastToolOutput stores the full output of the last tool execution
// for Ctrl+O expansion. Updated by Chat(), read by caller.
LastToolOutput *string
// LastToolOutputTruncated stores the truncated version shown inline
LastToolOutputTruncated *string
} }
// Chat runs an agent chat loop with tool support. // Chat runs an agent chat loop with tool support.
@@ -446,25 +439,15 @@ func Chat(ctx context.Context, opts RunOptions) (*api.Message, error) {
toolSuccess: toolSuccess:
// Display tool output (truncated for display) // Display tool output (truncated for display)
truncatedOutput := ""
if toolResult != "" { if toolResult != "" {
output := toolResult output := toolResult
if len(output) > 300 { if len(output) > 300 {
output = output[:300] + "... (truncated, press Ctrl+O to expand)" output = output[:300] + "... (truncated)"
} }
truncatedOutput = output
// Show result in grey, indented // Show result in grey, indented
fmt.Fprintf(os.Stderr, "\033[90m %s\033[0m\n", strings.ReplaceAll(output, "\n", "\n ")) fmt.Fprintf(os.Stderr, "\033[90m %s\033[0m\n", strings.ReplaceAll(output, "\n", "\n "))
} }
// Store full and truncated output for Ctrl+O toggle
if opts.LastToolOutput != nil {
*opts.LastToolOutput = toolResult
}
if opts.LastToolOutputTruncated != nil {
*opts.LastToolOutputTruncated = truncatedOutput
}
// Truncate output to prevent context overflow // Truncate output to prevent context overflow
toolResultForLLM := truncateToolOutput(toolResult, opts.Model) toolResultForLLM := truncateToolOutput(toolResult, opts.Model)
@@ -690,11 +673,6 @@ func GenerateInteractive(cmd *cobra.Command, modelName string, wordWrap bool, op
var messages []api.Message var messages []api.Message
var sb strings.Builder var sb strings.Builder
// Track last tool output for Ctrl+O toggle
var lastToolOutput string
var lastToolOutputTruncated string
var toolOutputExpanded bool
for { for {
line, err := scanner.Readline() line, err := scanner.Readline()
switch { switch {
@@ -707,20 +685,6 @@ func GenerateInteractive(cmd *cobra.Command, modelName string, wordWrap bool, op
} }
sb.Reset() sb.Reset()
continue continue
case errors.Is(err, readline.ErrExpandOutput):
// Ctrl+O pressed - toggle between expanded and collapsed tool output
if lastToolOutput == "" {
fmt.Fprintf(os.Stderr, "\033[90mNo tool output to expand\033[0m\n")
} else if toolOutputExpanded {
// Currently expanded, show truncated
fmt.Fprintf(os.Stderr, "\033[90m %s\033[0m\n", strings.ReplaceAll(lastToolOutputTruncated, "\n", "\n "))
toolOutputExpanded = false
} else {
// Currently collapsed, show full
fmt.Fprintf(os.Stderr, "\033[90m %s\033[0m\n", strings.ReplaceAll(lastToolOutput, "\n", "\n "))
toolOutputExpanded = true
}
continue
case err != nil: case err != nil:
return err return err
} }
@@ -759,21 +723,17 @@ func GenerateInteractive(cmd *cobra.Command, modelName string, wordWrap bool, op
messages = append(messages, newMessage) messages = append(messages, newMessage)
opts := RunOptions{ opts := RunOptions{
Model: modelName, Model: modelName,
Messages: messages, Messages: messages,
WordWrap: wordWrap, WordWrap: wordWrap,
Options: options, Options: options,
Think: think, Think: think,
HideThinking: hideThinking, HideThinking: hideThinking,
KeepAlive: keepAlive, KeepAlive: keepAlive,
Tools: toolRegistry, Tools: toolRegistry,
Approval: approval, Approval: approval,
YoloMode: yoloMode, YoloMode: yoloMode,
LastToolOutput: &lastToolOutput,
LastToolOutputTruncated: &lastToolOutputTruncated,
} }
// Reset expanded state for new tool execution
toolOutputExpanded = false
assistant, err := Chat(cmd.Context(), opts) assistant, err := Chat(cmd.Context(), opts)
if err != nil { if err != nil {