Files
gnoma/internal/stream/event.go
T
vikingowl 6c70a2ceaf fix: TUI overflow, scrollable header, tool output, git branch
- Fixed: chat content no longer overflows past allocated height.
  Lines are measured for physical width and hard-truncated to
  exactly the chat area height. Input + status bar always visible.
- Header scrolls with chat (not pinned), only input/status fixed
- Git branch in status bar (green, via git rev-parse)
- Alt screen mode — terminal scrollback disabled
- Mouse wheel + PgUp/PgDown scroll within TUI
- New EventToolResult: tool output as dimmed indented block
- Separator lines above/below input, no status bar backgrounds
2026-04-03 15:53:42 +02:00

78 lines
1.5 KiB
Go

package stream
import (
"encoding/json"
"fmt"
"somegit.dev/Owlibou/gnoma/internal/message"
)
// EventType discriminates streaming events.
type EventType int
const (
EventTextDelta EventType = iota + 1
EventThinkingDelta
EventToolCallStart
EventToolCallDelta
EventToolCallDone
EventToolResult // tool execution output
EventUsage
EventError
)
func (et EventType) String() string {
switch et {
case EventTextDelta:
return "text_delta"
case EventThinkingDelta:
return "thinking_delta"
case EventToolCallStart:
return "tool_call_start"
case EventToolCallDelta:
return "tool_call_delta"
case EventToolCallDone:
return "tool_call_done"
case EventToolResult:
return "tool_result"
case EventUsage:
return "usage"
case EventError:
return "error"
default:
return fmt.Sprintf("unknown(%d)", et)
}
}
// Event is a single streaming event from a provider.
type Event struct {
Type EventType
// TextDelta, ThinkingDelta
Text string
// ToolCallStart: ID + Name set
// ToolCallDelta: ID + ArgDelta set
// ToolCallDone: ID + Args set (complete JSON)
ToolCallID string
ToolCallName string
ArgDelta string // partial JSON fragment
Args json.RawMessage // complete arguments (on Done)
// ToolResult: tool name + output
ToolName string
ToolOutput string
// Usage
Usage *message.Usage
// Error
Err error
// StopReason — set on the final event of a stream
StopReason message.StopReason
// Model — set on first event if available
Model string
}