Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1887,9 +1887,11 @@ come from Codex—not inactivity guesses—and do not replace WORKING, approvals
TURN COMPLETE. Unavailable refreshes mark retained observations **GOAL STALE**.
Terminal goal labels include Codex's reported pursuit duration when it fits,
for example `PURSUING GOAL // 1d 1h 23m`. Zero units are omitted; less than a
minute is shown as `<1m`. The duration is omitted before crowding other footer
controls, and stale observations do not show a duration. This is accumulated
wall-clock pursuit time recorded by Codex (including tool execution), not time
minute is shown as `<1m`. The full statusline and footer controls take priority:
the duration is omitted first, then the goal label if it still cannot fit,
rather than shortening the statusline to make room. Stale observations do not
show a duration. This is accumulated wall-clock pursuit time recorded by Codex
(including tool execution), not time
since the goal was created or a model-only thinking timer. It updates when Codex
reports accounting progress, not on a locally invented ticking clock. Codex
retains its goal accounting across Codexometer restarts; replacing the goal
Expand Down
6 changes: 4 additions & 2 deletions internal/ui/monitor_goal.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ func (m Model) monitorGoalFooter(width int, controls string, colors palette) str
if controls != "" {
available -= ansi.StringWidth(controls) + 2
}
if m.monitorStatusLineText(width, controls) != "" {
available -= 12
// Reserve the statusline as it would render without a goal. The optional
// duration/label must yield first, never shorten configured status fields.
if status := m.monitorStatusLineText(width, controls); status != "" {
available -= max(ansi.StringWidth(status), monitorStatusLineMinTextWidth)
}
goal := m.monitorGoalStatus(s, available, colors)
if goal == "" || ansi.StringWidth(goal) > available {
Expand Down
85 changes: 84 additions & 1 deletion internal/ui/monitor_goal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func TestMonitorGoalFooterDropsDurationBeforeStatus(t *testing.T) {
m := completedCopyModel()
m.setRowContext("root-one", contextFull)
m.monitorSessionData[0].goal = &codex.SessionGoal{Status: "active", TimeUsedSeconds: 91439}
m.monitorSessionData[0].latest = 1200
colors := paletteFor(m.theme)
label, timed := "PURSUING GOAL", "PURSUING GOAL // 1d 1h 23m"
for _, fields := range [][]string{{}, {"used-tokens"}} {
Expand All @@ -344,7 +345,7 @@ func TestMonitorGoalFooterDropsDurationBeforeStatus(t *testing.T) {
reserve += ansi.StringWidth(controls) + 2
}
if len(fields) > 0 {
reserve += 12
reserve += len("1.2K tokens")
}
for _, available := range []int{len(label) - 1, len(label), len(timed) - 1, len(timed), len(timed) + 20} {
width := reserve + available
Expand Down Expand Up @@ -399,6 +400,88 @@ func TestMonitorGoalFooterKeepsCopyTarget(t *testing.T) {
}
}

func TestMonitorGoalFooterPreservesActualStatusline(t *testing.T) {
for _, status := range []struct{ raw, text string }{
{"short", "short"},
{strings.Repeat("long-session-name-", 6), strings.Repeat("long-session-name-", 6)},
{strings.Repeat("作業", 12), strings.Repeat("作業", 12)},
{"\x1b[31mHighlighted name\x1b[0m", "Highlighted name"},
} {
m := completedCopyModel()
m.setRowContext("root-one", contextFull)
m.monitorStatusLine = []string{"thread-name"}
m.monitorSessionData[0].name = status.raw
m.monitorSessionData[0].goal = &codex.SessionGoal{Status: "active", TimeUsedSeconds: 91439}
colors := paletteFor(m.theme)
label, timed := "PURSUING GOAL", "PURSUING GOAL // 1d 1h 23m"
for _, controls := range []string{"", colors.label().Foreground(colors.primary).Render("[ (C)OPY ]")} {
// Existing footer layout keeps at least nine text cells even when
// a selected field is shorter; otherwise the statusline disappears.
reserve := max(ansi.StringWidth(status.text), 9) + 6
if controls != "" {
reserve += ansi.StringWidth(controls) + 2
}
for _, available := range []int{len(label) - 1, len(label), len(timed) - 1, len(timed)} {
width := reserve + available
footer := m.monitorGoalFooter(width, controls, colors)
if got := m.monitorStatusLineText(width, footer); got != status.text {
t.Fatalf("width %d goal shortened statusline: %q, want %q", width, got, status.text)
}
wantGoal := ""
if available >= len(timed) {
wantGoal = timed
} else if available >= len(label) {
wantGoal = label
}
want := wantGoal
if controls != "" {
if want != "" {
want += " "
}
want += ansi.Strip(controls)
}
if got := ansi.Strip(footer); got != want {
t.Fatalf("width %d footer = %q, want %q", width, got, want)
}
panel := frameSizedWithActions(width, 2, "DETAIL", "", footer, "", colors.primary, colors)
panel = m.withMonitorStatusLine(panel, width, footer, colors)
lines := strings.Split(ansi.Strip(panel), "\n")
line := lines[len(lines)-1]
if !strings.Contains(line, status.text) || want != "" && !strings.Contains(line, want) || ansi.StringWidth(line) != width {
t.Fatalf("footer content overlapped or overflowed: %q", line)
}
if controls != "" {
at := strings.Index(line, "[ (C)OPY ]")
if at < 0 || ansi.StringWidth(line[:at]) != width-ansi.StringWidth(controls)-2 {
t.Fatal("goal changed Copy's column:", line)
}
}
}
}
}
}

func TestMonitorGoalFooterYieldsToTruncatedStatusline(t *testing.T) {
m := completedCopyModel()
m.setRowContext("root-one", contextFull)
m.monitorStatusLine = []string{"thread-name"}
m.monitorSessionData[0].name = strings.Repeat("session-name-", 40)
m.monitorSessionData[0].goal = &codex.SessionGoal{Status: "active", TimeUsedSeconds: 91439}
colors := paletteFor(m.theme)
for _, width := range []int{40, 80, 120, 200} {
for _, controls := range []string{"", benchmarkDetailCopyLabel} {
before := m.monitorStatusLineText(width, controls)
if !strings.HasSuffix(before, "…") {
t.Fatal("fixture did not exercise an already-truncated statusline")
}
footer := m.monitorGoalFooter(width, controls, colors)
if footer != controls || m.monitorStatusLineText(width, footer) != before {
t.Fatalf("width %d displaced a full statusline with a goal", width)
}
}
}
}

func TestMonitorGoalStatusStaleAndSync(t *testing.T) {
m := completedCopyModel()
usage := codex.LiveUsageSnapshot{Sessions: []codex.LiveUsageSession{{ID: "root-one", Active: true, Goal: &codex.SessionGoal{Status: "active", Objective: "Goal"}}}}
Expand Down
4 changes: 3 additions & 1 deletion internal/ui/monitor_statusline.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ func (m Model) monitorPriorityFields(s monitorSession) ([]string, map[string]boo
return lines, selected
}

const monitorStatusLineMinTextWidth = 9

func (m Model) monitorStatusLineText(width int, copyLabel string) string {
end := width - 2
if copyLabel != "" {
end = width - ansi.StringWidth(copyLabel) - 3
}
if end < 12 {
if end < monitorStatusLineMinTextWidth+3 {
return ""
}
text := statusline.Text(m.monitorStatusLine, m.monitorStatusValues())
Expand Down
Loading