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
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1673,9 +1673,10 @@ same action on that session. The presentations are:
can still require action in Codex.
The selected session also offers a follow-up composer here when the shared
server confirms it is ready for input and the complete context plus composer
fit. Only one inline composer is available at a time. Click its input line or
press `Enter` to focus, then `Enter` to send; `Esc` leaves the editor without
changing the row view. Drafts wrap and scroll within spare space, preserving
fit. Only one inline composer is available at a time. Click its input, the
blank row above it, or the hints below it to focus, or press `Enter`.
Press `Enter` to send; `Esc` leaves the editor without changing the row view.
Drafts wrap and scroll within spare space, preserving
the context above. Resizing to hide the composer releases keyboard focus;
enlarge the window and refocus to continue the draft. Approval requests and
structured questions do not use this inline composer; use full detail instead.
Expand Down Expand Up @@ -1876,9 +1877,10 @@ On tall terminals, full detail retains the summary and attention strip. When
space becomes limited, the summary disappears first, then the attention strip.
The budget reserves the actual approval/composer control rows and useful text
space; long drafts, wrapped controls and translated labels are taken into account.
In full detail, clicking anywhere across the bottom three rows of the detail panel
focuses an available composer without sending text. Footer controls outside the
panel and approval controls keep their existing behaviour.
In full detail, clicking the composer, the dark blank row directly above it, or
the hint row below it focuses the editor without sending text. The bottom border
still accepts focus clicks outside any buttons. Footer and approval controls keep
their existing behaviour.
The overview keeps its compact summary and reserves one attention row to preserve
session content. Existing footer, approval, dismiss and editor click targets use
the same layout as rendering. Keyboard navigation and approval confirmations
Expand Down
1 change: 1 addition & 0 deletions internal/ui/monitor_command_popup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestMonitorCommandPopupPreservesContextComposerAndRowMode(t *testing.T) {
if !strings.Contains(out, "CONVERSATION STAYS VISIBLE") || !strings.Contains(out, "Medium") || f.calls != 0 {
t.Fatalf("submenu replaced context or applied a command: %s", out)
}
assertDarkComposerSpacer(t, m, before.x, before.width, before.y+before.height)
if lipgloss.Width(out) > m.width || lipgloss.Height(out) > m.height {
t.Fatalf("popup exceeds viewport at %v mode %d", size, mode)
}
Expand Down
10 changes: 3 additions & 7 deletions internal/ui/monitor_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,9 @@ func (m Model) monitorContextAt(x, y int) string {
if hit := m.monitorNavigationHit(g.contentWidth, m.monitorContextDetail, true, x, y); hit != "" {
return hit
}
if rows := m.monitorPromptRows(g.contentWidth, g.meterHeight); rows > 0 && m.monitorPromptOffer().Token != "" {
_, _, controlY := monitorContextBodyLayout(g.meterHeight, rows)
inEditor := y >= controlY+m.monitorPromptHeaderRows() && y < controlY+rows-1 && x >= 2 && x < g.contentWidth-2
// Include the full-width bottom three rows of the detail frame,
// without taking clicks from the global footer below it.
inBottom := y >= g.meterHeight-3 && y < g.meterHeight && x >= 0 && x < g.contentWidth
if inEditor || inBottom {
if m.monitorPromptOffer().Token != "" {
if controls := m.layoutDetailControlsBase(g.contentWidth, g.meterHeight); controls.kind == "prompt" &&
m.monitorPromptHit(g.contentWidth, g.meterHeight, controls.rows, x, y) {
return "prompt"
}
}
Expand Down
17 changes: 11 additions & 6 deletions internal/ui/monitor_context_modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func (m Model) renderExpandedContext(width, height int, s monitorSession, colors
buttons := m.expandedApprovalButtons(width, height, s)
n := 0
controls := ""
composer := false
if len(buttons) > 0 {
n = buttons[len(buttons)-1].y + 1
controls = m.renderMonitorApprovalControls(width, height, colors)
Expand All @@ -292,6 +293,7 @@ func (m Model) renderExpandedContext(width, height int, s monitorSession, colors
if rows := m.monitorPromptRows(width, height); rows > 0 {
n = rows
controls = m.renderMonitorPrompt(width, height, colors)
composer = true
}
}
if dots := m.sessionActivityDots(s); n == 0 && dots != "" && height >= 5 && width >= 7 {
Expand All @@ -312,6 +314,12 @@ func (m Model) renderExpandedContext(width, height int, s monitorSession, colors
withoutTask.preview.CurrentTask, withoutTask.preview.LatestGuidance = "", ""
lines = m.expandedContextLines(width, withoutTask)
}
if composer && textRows <= 5 && len(lines) > 1 && s.preview.Kind == codex.SessionContextReply &&
(m.monitorCommands.open || m.suggestionsActive()) {
// The row title and telemetry already identify the session. Give
// the first text row to its reply when a compact slash popup opens.
lines = lines[1:]
}
if hasWorkingCommand(s.preview) {
lines = m.workingContextLines(s.preview, max(width-4, 1), max(textRows, 1), false)
}
Expand Down Expand Up @@ -419,12 +427,9 @@ func (m Model) expandedContextAt(x, y int) string {
mw, cw, _ := monitorSessionColumnWidths(a.width)
x -= mw + 1
y -= rowY
if s.id == m.monitorContextTarget() && m.monitorPromptOffer().Token != "" {
if rows := m.monitorPromptRows(cw, heights[i]); rows > 0 {
_, _, cy := monitorContextBodyLayout(heights[i], rows)
if y >= cy+m.monitorPromptHeaderRows() && y < cy+rows-1 && x >= 2 && x < cw-2 {
return "prompt"
}
if s.id == m.monitorContextTarget() && !m.monitorApprovalHasOutcome() && m.monitorPromptOffer().Token != "" {
if rows := m.monitorPromptRows(cw, heights[i]); rows > 0 && m.monitorPromptHit(cw, heights[i], rows, x, y) {
return "prompt"
}
}
if hit := monitorButtonAt(m.expandedApprovalButtons(cw, heights[i], s), heights[i], x, y); hit != "" {
Expand Down
6 changes: 4 additions & 2 deletions internal/ui/monitor_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,10 @@ func (m Model) detailPage(width, height, controls int) monitorDetailPage {
}
// Keep a blank before the first heading if it fits. For an already
// scrolling document, keep it on roomy viewports but not on short ones.
if n < len(doc) && doc[n] == (detailLine{}) && len(doc) > p.rows &&
(p.rows < 8 || len(doc)-1 == p.rows) {
// A short viewport with a slash popup uses that row for reply text.
compactPopup := p.rows < 8 && (m.monitorCommands.open || m.suggestionsActive())
if n < len(doc) && doc[n] == (detailLine{}) &&
(compactPopup || len(doc) > p.rows && (p.rows < 8 || len(doc)-1 == p.rows)) {
doc = append(doc[:n], doc[n+1:]...)
}
p.document = spaceCommandReview(doc, p.rows, false)
Expand Down
31 changes: 25 additions & 6 deletions internal/ui/monitor_inline_prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,49 @@ func TestInlineMonitorPromptClicksAndSend(t *testing.T) {
w, h := m.monitorPromptSize()
rows := m.monitorPromptRows(w, h)
placeholder := ansi.Truncate(i18n.Text("[ Click here or press Enter to write ]"), max(w-4, 1), "")
if rows != 2 || !strings.Contains(ansi.Strip(m.render()), placeholder) {
if rows != 3 || !strings.Contains(ansi.Strip(m.render()), placeholder) {
t.Fatalf("missing inline composer at width %d", width)
}
g := m.dashboardLayout()
a := m.monitorArea(g.contentWidth, g.meterHeight)
mw, _, _ := monitorSessionColumnWidths(a.width)
_, _, cy := monitorContextBodyLayout(h, rows)
y := g.meterY + a.topHeight + a.gap - 1 + cy
assertDarkComposerSpacer(t, m, mw+5, w-4, y)
for x := mw + 5; x < mw+3+w-2; x++ {
if got := m.monitorContextAt(x, y); got != "prompt" {
t.Fatalf("width %d click %d,%d = %q", width, x, y, got)
}
}
next, _ := m.Update(tea.MouseClickMsg{X: mw + 5, Y: y, Button: tea.MouseLeft})
m = next.(Model)
if !m.monitorPrompt.input.Focused() || m.monitorContextDetail != "" {
t.Fatal("composer click navigated instead of focusing")
hintY, left := y+rows-1, mw+3
for x := left; x < left+w; x++ {
if got := m.monitorContextAt(x, hintY); got != "prompt" {
t.Fatalf("width %d hint click %d,%d = %q", width, x, hintY, got)
}
}
for _, x := range []int{left - 1, left + w} {
if m.monitorContextAt(x, hintY) == "prompt" {
t.Fatalf("hint click leaked outside the detail pane at %d,%d", x, hintY)
}
}
copyX, copyY := renderedTextStart(t, m, benchmarkDetailCopyLabel)
if copyY != hintY+1 || m.monitorContextAt(copyX, copyY) != "copy:root-one" {
t.Fatal("composer hint displaced or intercepted Copy")
}
base := m
for _, clickY := range []int{y, hintY} {
next, _ := base.Update(tea.MouseClickMsg{X: mw + 5, Y: clickY, Button: tea.MouseLeft})
m = next.(Model)
if !m.monitorPrompt.input.Focused() || m.monitorContextDetail != "" || c.answers != nil {
t.Fatalf("click at row %d did not just focus the inline composer", clickY)
}
}
m, _ = promptKey(m, 't', "t")
m, cmd := promptKey(m, tea.KeyEnter, "")
if cmd == nil || !m.monitorPrompt.busy {
t.Fatal("inline Enter did not send")
}
next, _ = m.Update(cmd())
next, _ := m.Update(cmd())
m = next.(Model)
if len(c.answers) != 1 || c.answers[0] != "t" || m.monitorPrompt.input.Focused() {
t.Fatal("inline send destination/content or focus incorrect")
Expand Down
26 changes: 22 additions & 4 deletions internal/ui/monitor_prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ func (m Model) monitorPromptOffer() codex.SessionPromptOffer {
return o
}

const monitorComposerSpacerRows = 1

func (m Model) monitorPromptRows(width, height int) int {
if s, ok := m.contextDetailSession(); ok {
if _, pending := m.sessionProfile(s); pending {
Expand All @@ -137,10 +139,10 @@ func (m Model) monitorPromptRows(width, height int) int {
if m.monitorPromptOffer().Token != "" || m.monitorPrompt.session == m.monitorContextTarget() && (m.monitorPrompt.busy || m.monitorPrompt.notice != "" && !sentNotice(m.monitorPrompt.notice)) {
p := m.monitorPrompt
headerRows := m.monitorPromptHeaderRows()
rows := 2 + headerRows
rows := 2 + headerRows + monitorComposerSpacerRows
if (p.input.Focused() || p.input.Value() != "") && !p.busy {
p.input.configure(width, m.monitorPromptEditorHeight(width, height))
rows = p.input.Height() + 1 + headerRows
rows = p.input.Height() + 1 + headerRows + monitorComposerSpacerRows
}
if m.monitorContextDetail == "" {
s, ok := m.contextDetailSession()
Expand All @@ -164,6 +166,21 @@ func (m Model) monitorPromptHeaderRows() int {
return 0
}

func (m Model) monitorPromptHit(width, height, rows, x, y int) bool {
if x < 0 || x >= width {
return false
}
_, _, top := monitorContextBodyLayout(height, rows)
spacer := top + m.monitorPromptHeaderRows()
hint := top + rows - 1
// The whole hint row focuses either composer. Full detail also accepts
// clicks on the spacer and bottom border outside their explicit buttons.
if y == hint || m.monitorContextDetail != "" && (y == spacer || y >= height-3 && y < height) {
return true
}
return x >= 2 && x < width-2 && y >= spacer && y < hint
}

func (m Model) monitorComposerActivity() string {
if m.monitorPromptOffer().TurnID != "" {
if s, ok := m.contextDetailSession(); ok {
Expand All @@ -176,7 +193,7 @@ func (m Model) monitorComposerActivity() string {
// Inline drafts grow only into spare space, then scroll inside the editor;
// they never displace the source context. Full detail keeps its usual viewport.
func (m Model) monitorPromptEditorHeight(width, height int) int {
extra := 1 - m.monitorPromptHeaderRows()
extra := 1 - m.monitorPromptHeaderRows() - monitorComposerSpacerRows
if m.monitorContextDetail == "" {
if s, ok := m.contextDetailSession(); ok {
return min(height+extra, max(8, height+3+extra-len(m.expandedContextLines(width, s))))
Expand Down Expand Up @@ -281,7 +298,8 @@ func (m Model) renderMonitorPrompt(width, height int, colors palette) string {
if scheduling && !m.hasGoalResume() {
footer = m.renderScheduleToggleHint(width, hint, false, hintStyle, colors)
}
body := strings.Join(inputLines, "\n") + "\n" + footer
// Keep this row unstyled so the frame paints the normal dark background.
body := "\n" + strings.Join(inputLines, "\n") + "\n" + footer
if header != "" {
body = colors.label().Render(ansi.Truncate(header, max(width-4, 1), "…")) + "\n" + body
}
Expand Down
37 changes: 33 additions & 4 deletions internal/ui/monitor_prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMonitorPromptPlaceholderComposerBackground(t *testing.T) {
t.Fatal("composer has no background")
}
for x := 0; x < width-4; x++ {
cell := cells.CellAt(x, 0)
cell := cells.CellAt(x, monitorComposerSpacerRows)
if cell == nil || cell.Style.Bg == nil {
t.Fatalf("theme %d width %d: missing placeholder background at %d", theme, width, x)
}
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestMonitorPromptQuestionsAndSecret(t *testing.T) {
m.monitorSessionData[0].preview.InputToken = c.offer.Token
m.focusMonitorPrompt()
question := strings.Split(ansi.Strip(m.renderMonitorPrompt(120, 30, paletteFor(m.theme))), "\n")
if len(question) != 3 || !strings.Contains(question[0], "REPLY 1/2") || !strings.Contains(question[0], "Pick one") || m.monitorPromptHeaderRows() != 1 {
if len(question) != 4 || question[1] != "" || !strings.Contains(question[0], "REPLY 1/2") || !strings.Contains(question[0], "Pick one") || m.monitorPromptHeaderRows() != 1 {
t.Fatal("structured question lost its heading or answer progress")
}
m.monitorPrompt.input.SetValue("not offered")
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestMonitorPromptResponsiveClickTargets(t *testing.T) {
continue
}
_, _, y := monitorContextBodyLayout(g.meterHeight, rows)
y += g.meterY + 1
y += g.meterY
for x := 4; x < g.contentWidth; x++ {
if m.monitorContextAt(x, y) != "prompt" {
t.Fatalf("miss %s %v %d,%d", lang, size, x, y)
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestMonitorPromptWrapsAndGrowsUpward(t *testing.T) {
t.Fatal("wrapping altered the submitted text")
}
m.monitorPrompt.input.SetValue("short")
if m.monitorPromptRows(g.contentWidth, g.meterHeight) != 2 {
if m.monitorPromptRows(g.contentWidth, g.meterHeight) != 3 {
t.Fatal("editor failed to shrink")
}
}
Expand All @@ -300,6 +300,14 @@ func TestMonitorDetailBottomRowsFocusComposer(t *testing.T) {
m.height = height
g := m.monitorDashboardLayout()
copyX, copyY := renderedTextStart(t, m, benchmarkDetailCopyLabel)
composerY := g.meterY + g.meterHeight - 3
assertDarkComposerSpacer(t, m, 4, g.contentWidth-4, composerY-1)
for _, x := range []int{2, 4, 1 + g.contentWidth} {
n, _ := m.Update(tea.MouseClickMsg{X: x, Y: composerY - 1, Button: tea.MouseLeft})
if !n.(Model).monitorPrompt.input.Focused() || c.answers != nil {
t.Fatalf("spacer click at %d,%d should focus without sending", x, composerY-1)
}
}
for y := g.meterY + g.meterHeight - 3; y < g.meterY+g.meterHeight; y++ {
for x := 2; x < 2+g.contentWidth; x++ {
want := "prompt"
Expand Down Expand Up @@ -327,6 +335,27 @@ func TestMonitorDetailBottomRowsFocusComposer(t *testing.T) {
}
}

func assertDarkComposerSpacer(t *testing.T, m Model, x, width, y int) {
t.Helper()
screen := uv.NewScreenBuffer(m.width, m.height)
uv.NewStyledString(m.render()).Draw(&screen, image.Rect(0, 0, m.width, m.height))
colors := paletteFor(m.theme)
if m.monitorContextDetail == "" {
colors.primary = colors.accent // the selected overview row uses its accent as primary
}
for col := x; col < x+width; col++ {
spacer := screen.CellAt(col, y)
if spacer == nil || strings.TrimSpace(spacer.Content) != "" {
t.Fatalf("expected a blank row above the composer at %d,%d, got %v", col, y, spacer)
}
assertBackground(t, spacer.Style.Bg, colors.background)
// A CJK glyph's trailing cell does not carry its own style.
if col == x || screen.CellAt(col-1, y+1).Width < 2 {
assertBackground(t, screen.CellAt(col, y+1).Style.Bg, monitorComposerBackground(colors))
}
}
}

func TestMonitorPromptResizeAndWrappedSubmission(t *testing.T) {
m, c := promptTestModel()
m.focusMonitorPrompt()
Expand Down
24 changes: 20 additions & 4 deletions internal/ui/monitor_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,34 @@ func TestNativeQueuePlacementAndClickSurfaces(t *testing.T) {
if activityY != queueY-1 || strings.Count(strings.Join(lines, "\n"), monitorDotWave(m.phase)) != 1 {
t.Fatal("task activity must appear exactly once immediately above follow-ups")
}
if inline && !strings.Contains(lines[queueY], "1–1") {
t.Fatal("wide row didn't collapse queue")
if inline {
want := "1–1"
if size == [2]int{80, 32} {
want = "open follow-ups"
}
if !strings.Contains(lines[queueY], want) {
t.Fatalf("%v wide row lost its responsive queue: %q", size, lines[queueY])
}
}
g := m.monitorDashboardLayout()
composerX, composerWidth := 4, g.contentWidth
if inline {
left, width, _ := monitorSessionColumnWidths(g.contentWidth)
composerX, composerWidth = left+5, width
}
assertDarkComposerSpacer(t, m, composerX, composerWidth-4, composerY-1)
if m.monitorContextAt(composerX, composerY-1) != "prompt" {
t.Fatal("queue intercepted the composer spacer")
}
// Composer remains anchored at its existing position.
w, h := m.monitorPromptSize()
rows := m.monitorPromptRows(w, h)
if rows != 3 && !m.monitorPrompt.input.Focused() {
if rows != 4 && !m.monitorPrompt.input.Focused() {
t.Fatal("queue changed composer size")
}
m.monitorQueue.items = nil
withoutQueue := strings.Split(ansi.Strip(m.render()), "\n")
if withoutQueue[composerY] != lines[composerY] || !strings.Contains(withoutQueue[composerY-1], monitorDotWave(m.phase)) {
if withoutQueue[composerY] != lines[composerY] || !strings.Contains(withoutQueue[composerY-2], monitorDotWave(m.phase)) {
t.Fatal("moving animation shifted composer or lost its no-queue placement")
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/ui/monitor_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (m *Model) openSchedule() tea.Cmd {
}
p := scheduleUI{queue: q, polling: m.scheduleUI.polling, drafts: m.scheduleUI.drafts, open: true, session: id, input: newMonitorEditor(), hours: 1, date: time.Now().Add(time.Hour).Truncate(time.Minute)}
g := m.monitorDashboardLayout()
p.composerRows = max(2, m.monitorPromptRows(g.contentWidth, g.meterHeight))
p.composerRows = max(2, m.monitorPromptRows(g.contentWidth, g.meterHeight)-monitorComposerSpacerRows)
if m.monitorPrompt.session == id {
p.input = m.monitorPrompt.input
}
Expand Down Expand Up @@ -299,7 +299,7 @@ func (m Model) updateSchedule(msg tea.Msg) (Model, tea.Cmd, bool) {
if click.X < 2 || click.X >= g.contentWidth-2 {
return m, nil, true
}
if localY >= layout.composerY && localY < layout.composerY+layout.composerRows {
if localY >= layout.composerY-monitorComposerSpacerRows && localY < layout.composerY+layout.composerRows {
p.focus = 0
return m, p.input.Focus(), true
}
Expand Down
3 changes: 2 additions & 1 deletion internal/ui/monitor_schedule_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ func (m Model) schedulePaneLayout(width, height int) schedulePaneLayout {
l.indices = append(l.indices, row)
}
l.composerRows = min(max(p.composerRows, 2), max(height-5, 1))
l.textRows, _, l.composerY = monitorContextBodyLayout(height, l.composerRows)
l.textRows, _, l.composerY = monitorContextBodyLayout(height, l.composerRows+monitorComposerSpacerRows)
l.composerY += monitorComposerSpacerRows
l.scroll = min(max(p.scroll, 0), max(len(l.indices)-l.textRows, 0))
return l
}
Expand Down
5 changes: 3 additions & 2 deletions internal/ui/monitor_schedule_pane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ func TestSchedulePaneScrollAndHitTargets(t *testing.T) {
if !actionVisible {
t.Fatal("keyboard focus left action offscreen")
}
// Clicking composer focuses it without changing the scroll/trigger.
m, _, _ = m.updateSchedule(tea.MouseClickMsg{X: 6, Y: g.meterY + l.composerY + 1, Button: tea.MouseLeft})
// Clicking the dark spacer focuses the anchored composer without changing the form.
assertDarkComposerSpacer(t, m, 4, g.contentWidth-4, g.meterY+l.composerY-1)
m, _, _ = m.updateSchedule(tea.MouseClickMsg{X: 6, Y: g.meterY + l.composerY - 1, Button: tea.MouseLeft})
if m.scheduleUI.focus != 0 || !m.scheduleUI.input.Focused() {
t.Fatal("anchored composer click missed")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/monitor_schedule_toggle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestScheduleToggleRenderedHoverAndClicks(t *testing.T) {
} else {
rows := m.monitorPromptRows(g.contentWidth, g.meterHeight)
_, _, cy := monitorContextBodyLayout(g.meterHeight, rows)
if y != g.meterY+cy+rows-1 || rows != 2 {
if y != g.meterY+cy+rows-1 || rows != 3 {
t.Fatal("idle composer retained a heading or misplaced schedule button")
}
}
Expand Down
Loading
Loading