Skip to content

Conversation

@stanislavHamara
Copy link
Contributor

@stanislavHamara stanislavHamara commented Jan 15, 2026

Kapture.2026-01-15.at.16.19.33.mp4

Implements a message queue in the TUI that allows users to enqueue up to 5 messages while the agent is busy processing. Queued messages are automatically sent when the previous message finishes, providing a smoother workflow without losing user input.

Changes

Core queue logic (pkg/tui/page/chat/chat.go):

  • Added queuedMessage struct and messageQueue field to chatPage
  • handleSendMsg() – queues messages when agent is busy, processes immediately when idle
  • processNextQueuedMessage() – pops and processes the next queued message (called when stream stops)
  • handleClearQueue() – clears all queued messages with Ctrl+X
  • syncQueueToSidebar() – syncs queue previews to sidebar display

Editor changes (pkg/tui/components/editor/editor.go):

  • Removed working guards that blocked sending – now delegates queuing decision to chatPage

Key binding (pkg/tui/tui.go, pkg/tui/messages/messages.go):

  • Added Ctrl+X binding to clear the message queue
  • Added ClearQueueMsg message type

Visual feedback:

  • Resize handle shows queue count: "Working… (3 queued)"
  • Sidebar displays "Queue (N)" section with truncated message previews
  • Notifications inform users: "Message queued (2 waiting) · Ctrl+X to clear"

Sidebar (pkg/tui/components/sidebar/sidebar.go):

  • Added SetQueuedMessages() method and queueSection() renderer
  • Queue section shows tree-style list of pending messages with clear hint

Behavior

  • Messages sent while agent is busy are queued (max 5)
  • When agent finishes, next queued message auto-starts
  • Esc cancels current stream but preserves the queue
  • Ctrl+X clears all queued messages
  • Queue full → warning notification, message rejected

Tests

  • pkg/tui/page/chat/queue_test.go – flow tests for queueing, rejection, clearing, FIFO order
  • pkg/tui/components/sidebar/queue_test.go – sidebar queue section renderingWIP

@stanislavHamara stanislavHamara marked this pull request as ready for review January 15, 2026 16:23
@stanislavHamara stanislavHamara requested a review from a team as a code owner January 15, 2026 16:23
Comment on lines +637 to +641
if queueLen == 1 {
notifyMsg = "Message queued (1 waiting) · Ctrl+X to clear"
} else {
notifyMsg = fmt.Sprintf("Message queued (%d waiting) · Ctrl+X to clear", queueLen)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just the else should be enough here

Comment on lines +654 to +655
queued := p.messageQueue[0]
p.messageQueue = p.messageQueue[1:]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: probably not a big deal, but since messageQueue is a list of structs with pointers the references to the underlying elements would remain alive.. maybe we should be zeroing out the p.messageQueue[0] after grabbing the first element

p.messageQueue[0] = queuedMessage{}


// Truncate message and add prefix
truncated := toolcommon.TruncateText(msg, maxMsgWidth)
lines = append(lines, prefix+styles.MutedStyle.Render(truncated))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that queued messages are something the user should be well aware of, I think here it'd be better if we kept the normal text style to increase contrast between the section title, the branches and the press ctr+x to clear. Similar to the agents section right below it

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants