Skip to content

Display and manage pending Session messages - #1648

Merged
gjkim42 merged 1 commit into
mainfrom
agent/render-pending-message-multiline
Aug 12, 2026
Merged

gjkim42 merged 1 commit into
mainfrom
agent/render-pending-message-multiline

Conversation

@gjkim42

@gjkim42 gjkim42 commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind feature

What this PR does / why we need it:

Improves the single pending Session message in three ways:

  • Preserves line breaks in the web pending-message card, so combined follow-up submissions remain readable.
  • Adds Remove beside Edit in the web client.
  • Lets terminal UI users press Up on an empty composer to recall and edit the pending message. Submitting the recalled message empty removes it, without adding a slash command.

Edits and removals use the pending message revision to reject stale requests. Removal is persisted as a dedicated event, frees the pending slot immediately, prevents the buffered turn from reaching the provider, and remains removed after runtime recovery.

Which issue(s) this PR is related to:

N/A

Special notes for your reviewer:

The removal path covers both a turn still buffered in the runtime channel and the race where the dispatcher has received the turn but has not started it. Removed messages are omitted from conversation history.

Validated with make test and make verify.

Does this PR introduce a user-facing change?

Display combined pending Session messages on multiple lines and allow them to be edited or removed before they start.

@gjkim42
gjkim42 marked this pull request as ready for review August 12, 2026 15:27

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/sessionserver/server_test.go Outdated
@gjkim42

gjkim42 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

/kelos claude-review

@kelos-bot

kelos-bot Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Kelos Task Status

Task kelos-claude-reviewer-issue-comment-45718b9f3a31 has succeeded. ✅

@kelos-bot

kelos-bot Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Kelos Claude Reviewer Agent @gjkim42

Review Summary

Verdict: APPROVE
Overall correctness: patch is correct
Scope: Renders the pending Session message on multiple lines in the web client, adds a Remove action (web) and Up-arrow recall/edit/remove (terminal UI), backed by a new user.message.removed journal event with revision-checked removal that survives runtime recovery.

Findings Overview

Priority Count File:Line Summary
P0 0 — none
P1 0 — none
P2 0 — none
P3 1 internal/sessionserver/server_test.go:619 Test asserts the exact full CSS rule string, brittle to unrelated property edits

Findings

Tests

  • [P3] internal/sessionserver/server_test.go:619 — TestSessionPendingMessagePreservesLineBreaks matches the entire .pending-message-text rule verbatim, so any unrelated edit to that rule (a color or font-size tweak, property reordering) fails the test even while multiline rendering still works. Asserting the behavior-relevant fragments — that the rule contains white-space: pre-wrap and overflow-wrap: anywhere — would pin the fix without over-constraining the rest of the rule, consistent with the targeted-fragment style of neighboring tests in this file.

Suggestions (optional)

  • [P3] internal/cli/session_terminal_tui.go:577 — Once a pending message is recalled with Up, there is no way to leave edit mode without submitting: submitting the text unchanged works but bumps the revision, and clearing the composer and pressing Enter removes the message — the opposite of normal mode, where an empty submit is a no-op. Because edit-path submissions are not appended to m.history, an accidental removal loses the text irrecoverably (the web client guards this with a window.confirm dialog; the TUI has no equivalent). Consider letting Esc cancel a pending edit while one is active, or appending the removed text to input history as a recovery path.

Key takeaways

  • The dispatch race is handled correctly: takePendingTurn now reports whether the turn was still pending, so a turn removed after the dispatcher received it from the channel is skipped instead of run (internal/sessionruntime/server.go:426), and TestServerDoesNotRunPendingMessageRemovedAfterDispatch pins this. removePendingMessage mirrors finishTurn's outstanding/drain-report accounting under submitMu, so idle-drain and update reporting stay consistent when the pending slot is freed.
  • Removal is durable: recoverJournal treats user.message.removed as turn completion, the journal drops the turn from its unstarted-turn retention, and projectHistory marks the turn hidden — so a removed message neither resurrects after a runtime restart nor reappears in replayed history.
  • Revision checking is sound end to end: the server rejects stale or non-positive expectedRevision, the web client normalizes revision || 1 on every pending event, and the TUI normalizes with max(1, revision), so removal of a never-edited message (revision-0 journals included) works from both clients.

@gjkim42
gjkim42 force-pushed the agent/render-pending-message-multiline branch from 39a2800 to 1ed8bc2 Compare August 12, 2026 20:54
@gjkim42 gjkim42 changed the title Render pending Session messages as multiline Display and remove pending Session messages Aug 12, 2026
@github-actions github-actions Bot added the kind/feature Categorizes issue or PR as related to a new feature label Aug 12, 2026
@gjkim42
gjkim42 force-pushed the agent/render-pending-message-multiline branch from 1ed8bc2 to b8fd195 Compare August 12, 2026 21:25
@gjkim42 gjkim42 changed the title Display and remove pending Session messages Display and manage pending Session messages Aug 12, 2026
@gjkim42
gjkim42 enabled auto-merge August 12, 2026 21:25
@gjkim42
gjkim42 disabled auto-merge August 12, 2026 21:26
@gjkim42

gjkim42 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

/kelos claude-review

@gjkim42
gjkim42 force-pushed the agent/render-pending-message-multiline branch from b8fd195 to 8c42c34 Compare August 12, 2026 22:23
@gjkim42
gjkim42 added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit cea126c Aug 12, 2026
17 checks passed
@gjkim42
gjkim42 deleted the agent/render-pending-message-multiline branch August 12, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug kind/feature Categorizes issue or PR as related to a new feature needs-actor needs-priority needs-triage release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant