Skip to content

Maintain one editable pending Session message - #1647

Merged
gjkim42 merged 1 commit into
mainfrom
agent/edit-queued-session-messages
Aug 12, 2026
Merged

gjkim42 merged 1 commit into
mainfrom
agent/edit-queued-session-messages

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:

Maintains at most one pending Session message while a turn is active. Additional submissions append their text and attachments to that message, and the combined message runs as the next turn after active work completes.

The web client provides inline Edit, Save, and Cancel controls for the pending message. Edits are revision-checked, persisted in the Session journal, reflected in connected terminal clients, and recovered after a runtime restart. Journals containing multiple accepted but unstarted turns are consolidated into one pending message during recovery.

Which issue(s) this PR is related to:

N/A

Special notes for your reviewer:

Edit replaces the pending text while a normal submission appends to it. Existing attachments remain attached, and optimistic revisions prevent a stale client from overwriting a newer update.

Does this PR introduce a user-facing change?

Combine follow-up Session submissions into one editable pending message that runs after active work completes.

@github-actions github-actions Bot added kind/feature Categorizes issue or PR as related to a new feature needs-triage needs-priority needs-actor release-note labels Aug 12, 2026
@gjkim42
gjkim42 marked this pull request as ready for review August 12, 2026 12:57

@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 13 files

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

Re-trigger cubic

Comment thread internal/sessionserver/web/styles.css Outdated
@gjkim42 gjkim42 changed the title Allow editing queued Session messages Maintain one editable pending Session message Aug 12, 2026
@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-334562a50549 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: Maintains at most one editable pending Session message — follow-up submissions merge into it, edits are revision-checked and journaled, and recovery consolidates multiple unstarted turns into one pending message.

Findings Overview

Priority Count File:Line Summary
P0 0 — none
P1 0 — none
P2 0 — none
P3 2 internal/sessionserver/web/styles.css:279 Pending-edit textarea missing from the mobile 16px font-size rule
P3 internal/cli/session_terminal.go:319 Plain terminal silently drops user.message.updated events

Findings

Web client

  • [P3] internal/sessionserver/web/styles.css:279 — .pending-message-input is a textarea with font-size: 12px, but it is not included in the mobile media-query rule at styles.css:391 that bumps .composer textarea and the other inputs to 16px. On iOS Safari, focusing the pending-message edit field will trigger the automatic page zoom that rule exists to prevent. Add .pending-message-input to that selector list.

CLI

  • [P3] internal/cli/session_terminal.go:319 — the plain (non-TTY) terminal handles user.message but has no case for user.message.updated, so a follow-up submission while a turn is active — which now emits only an update event instead of a new user.message — produces no live output, and the combined pending text is never echoed (it only appears in the Pending message: section on reconnect). Before this change the queued message was echoed via user.message. Consider printing the updated pending text, mirroring the TUI's EventUserMessageUpdated handling in session_terminal_tui.go.

Suggestions (optional)

  • [P3] internal/sessionserver/web/app.js (renderPendingUser) — when a user.message.updated event arrives while the edit textarea is open (e.g., another client merges a follow-up), renderPendingMessageContent replaces the editor and discards the user's in-progress edit text. The stale expectedRevision would correctly reject a subsequent Save, but preserving the open editor (or at least the typed text) with a refreshed revision would avoid losing local input.

Key takeaways

  • The server-side concurrency is well designed: submitMu consistently guards pendingTurn across submit/edit/take/restore, the capacity-1 turn channel cannot deadlock on the push-back paths, and takePendingTurn ensures the executed turn always carries the latest merged text.
  • Recovery correctly consolidates journals with multiple unstarted turns (pre-upgrade journals, or a crash between turn pickup and turn.started) into one pending message, with deterministic ordering and merged completion events that keep history projection clean.
  • Test coverage is strong across layers: revision-conflict and late-edit error paths, merge-of-submissions, journal recovery consolidation, history projection, TUI, and web client editing all have positive-path tests.

@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 17 files (changes from recent commits).

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

Re-trigger cubic

Comment thread internal/sessionserver/web/app.js
@gjkim42
gjkim42 force-pushed the agent/edit-queued-session-messages branch from b69d159 to 9b83294 Compare August 12, 2026 14:23
@gjkim42
gjkim42 added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit 95e76db Aug 12, 2026
17 checks passed
@gjkim42
gjkim42 deleted the agent/edit-queued-session-messages branch August 12, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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