Skip to content

feat(cli): emit session queue state for remote clients - #12297

Merged
iscekic merged 5 commits into
mainfrom
feature/mobile-session-message-queue
Jul 22, 2026
Merged

feat(cli): emit session queue state for remote clients#12297
iscekic merged 5 commits into
mainfrom
feature/mobile-session-message-queue

Conversation

@iscekic

@iscekic iscekic commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a new Kilo-owned bus event, session.queue.changed { sessionID, queued: MessageID[] }, carrying the authoritative FIFO snapshot of user-message IDs enqueued behind a running turn but not yet started. This lets remote clients (mobile) show a "Queued" indicator on follow-up messages sent while an agent session is busy.

  • KiloSessionPromptQueue (prompt-queue.ts) tracks a per-session ordered waiting list: pushes on enqueue-while-busy, shifts on slot-start-running, clears on cancel/version bump — publishing the event at each transition.
  • New snapshot(sessionID) accessor exposes the current waiting list.
  • remote-sender.ts's replay() now always sends the current queue snapshot (including empty) to a (re)subscribing client, so reconnects reconcile away stale badges.
  • No changes to the general event forwarder — session.queue.changed already carries sessionID in a shape extractSessionId recognizes.

Companion PR

cloud: normalizes this event into the shared SDK's pendingMessages state and renders the mobile "Queued" badge.

Testing

  • bun test ./test/kilocode/session-prompt-queue.test.ts ./test/kilocode/sessions/remote-sender.test.ts — 69/69 passing
  • bun run typecheck (from packages/opencode/) — clean
  • Changeset added (minor)

Note: the full bun test run from packages/opencode/ exhibits pre-existing, non-deterministic flakiness in unrelated test files (npm-publish retry timing, SessionImportService, worktree indexing, BackgroundProcess timing, and one real-provider session-prompt integration test) across repeated runs with different failures each time — none of these touch this PR's changed files. The touched test files pass deterministically in isolation and combined, repeatedly.

Non-goals

Per-message dequeue/edit/reorder API; no session-ingest/relay changes (forwarding is automatic and unchanged).

@iscekic iscekic self-assigned this Jul 16, 2026
Comment thread packages/opencode/src/kilocode/session/index.ts Outdated
Comment thread packages/opencode/src/kilocode/session/index.ts Outdated
Comment thread packages/opencode/src/kilocode/session/prompt-queue.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Since the last review (3474e50275), two commits landed: a merge of origin/main (959fdfcd89) and a follow-up chore (3e26a426fa, "remove kilocode_change markers from kilo-owned files").

  • The chore commit strips kilocode_change markers from event.ts, index.ts, and prompt-queue.ts (all under packages/opencode/src/kilocode/session/) and from remote-sender.ts (under packages/opencode/src/kilo-sessions/). Per script/check-opencode-annotations.ts, both kilocode-named and kilo--prefixed directories are marker-exempt, so this correctly resolves the earlier human comment questioning why remote-sender.ts needed markers — no fork-hygiene issue.
  • The upstream merge forced a conflict resolution in remote-sender.test.ts: the removed createExit helper (deleted upstream in the TUI refactor) is replaced with an inline idempotent memoized exit closure. It faithfully preserves the "cleans up once" semantics the test asserts, and lives in a test/kilocode/ path (marker-exempt, minor mechanical adaptation, not new PR logic).

All three previously-flagged style suggestions (const-only ctx via iife(), logged Bus.publish failure, startsImmediately naming) remain resolved.

Files Reviewed (2 files changed since last review)
  • packages/opencode/src/kilo-sessions/remote-sender.ts - marker removal only
  • packages/opencode/src/kilocode/session/event.ts - marker removal only
  • packages/opencode/src/kilocode/session/index.ts - marker removal only
  • packages/opencode/src/kilocode/session/prompt-queue.ts - marker removal only
  • packages/opencode/test/kilocode/session-prompt-queue.test.ts - marker removal only
  • packages/opencode/test/kilocode/sessions/remote-sender.test.ts - marker removal + merge-forced test adaptation
Previous Review Summaries (4 snapshots, latest commit 3474e50)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 3474e50)

Status: No Issues Found | Recommendation: Merge

The latest commit (3474e50275) is an empty CI-retrigger commit (no file changes vs. the previously reviewed 868d37db3a). This PR's core files (event.ts, index.ts, prompt-queue.ts, session-prompt-queue.test.ts, the changeset, remote-sender.ts) are unchanged — no new PR-authored logic to review.

All three earlier style suggestions remain resolved from the prior review (const-only ctx via iife(), logged Bus.publish failure, startsImmediately naming).

Files Reviewed (no new PR changes since last review)
  • packages/opencode/src/kilocode/session/index.ts - unchanged since last review
  • packages/opencode/src/kilocode/session/prompt-queue.ts - unchanged since last review
  • packages/opencode/src/kilo-sessions/remote-sender.ts - unchanged since last review

Previous review (commit 868d37d)

Status: No Issues Found | Recommendation: Merge

All three previous suggestions were addressed in 173ba94:

  • ctx now uses the iife() helper to stay const-only (packages/opencode/src/kilocode/session/index.ts)
  • The Bus.publish failure is now logged via log.warn("queue changed publish failed", { err }) instead of being silently swallowed (packages/opencode/src/kilocode/session/index.ts)
  • waitingBefore renamed to startsImmediately, matching its actual meaning (packages/opencode/src/kilocode/session/prompt-queue.ts)

The latest commit (868d37db3a) is a merge of unrelated upstream changes (remote slash commands, bidi markdown fix) into the branch. This PR's core files (event.ts, index.ts, prompt-queue.ts, session-prompt-queue.test.ts, the changeset) are byte-identical to the previously reviewed commit — no new PR-authored logic to review.

Files Reviewed (no new PR changes since last review)
  • packages/opencode/src/kilocode/session/index.ts - unchanged since last review
  • packages/opencode/src/kilocode/session/prompt-queue.ts - unchanged since last review
  • packages/opencode/src/kilo-sessions/remote-sender.ts - diff is entirely unrelated merged-in feature (feat(cli): support remote slash commands and session creation #12224), not PR-authored

Previous review (commit 173ba94)

Status: No Issues Found | Recommendation: Merge

All three previous suggestions were addressed in 173ba94:

  • ctx now uses the iife() helper to stay const-only (packages/opencode/src/kilocode/session/index.ts)
  • The Bus.publish failure is now logged via log.warn("queue changed publish failed", { err }) instead of being silently swallowed (packages/opencode/src/kilocode/session/index.ts)
  • waitingBefore renamed to startsImmediately, matching its actual meaning (packages/opencode/src/kilocode/session/prompt-queue.ts)

No new issues found in the incremental diff.

Files Reviewed (2 files changed since last review)
  • packages/opencode/src/kilocode/session/index.ts
  • packages/opencode/src/kilocode/session/prompt-queue.ts

Previous review (commit b888ed8)

Status: 3 Issues Found | Recommendation: Merge (non-blocking suggestions)

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/kilocode/session/index.ts 52 let ctx could use the existing iife() helper to stay const-only per style guide
packages/opencode/src/kilocode/session/index.ts 58 .catch(() => undefined) silently discards Bus.publish failures; consider logging via the file's existing log
packages/opencode/src/kilocode/session/prompt-queue.ts 176 waitingBefore variable name reads as the opposite of what it represents
Files Reviewed (7 files)
  • .changeset/queue-changed-snapshot.md
  • packages/opencode/src/kilo-sessions/remote-sender.ts
  • packages/opencode/src/kilocode/session/event.ts
  • packages/opencode/src/kilocode/session/index.ts - 2 issues
  • packages/opencode/src/kilocode/session/prompt-queue.ts - 1 issue
  • packages/opencode/test/kilocode/session-prompt-queue.test.ts
  • packages/opencode/test/kilocode/sessions/remote-sender.test.ts

All changed logic sits in Kilo-owned paths (kilocode/ or properly kilocode_change-marked in kilo-sessions/remote-sender.ts), FIFO ordering and event-suppression logic is covered by thorough new tests exercising the real implementation (no mocks in the core queue tests), and a changeset is present. No bugs, race conditions, or fork-hygiene issues found in the changed code.


Reviewed by claude-sonnet-5 · Input: 24 · Output: 6.3K · Cached: 664.3K

Review guidance: REVIEW.md from base branch main

@iscekic
iscekic force-pushed the feature/mobile-session-message-queue branch from b888ed8 to 173ba94 Compare July 17, 2026 00:40
…n-message-queue

# Conflicts:
#	packages/opencode/test/kilocode/sessions/remote-sender.test.ts
@iscekic

iscekic commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

(bot) Closing and reopening to re-trigger a stuck Kilo Code Bot review check suite (queued with no progress for 3+ hours after the origin/main merge push, while newer PRs' suites completed normally in the same window).

@iscekic iscekic closed this Jul 17, 2026
@iscekic iscekic reopened this Jul 17, 2026
Comment thread packages/opencode/src/kilo-sessions/remote-sender.ts Outdated
…ickydisk hang for 5 consecutive runs on the previous head)
iscekic added 2 commits July 21, 2026 00:04
…n-message-queue

# Conflicts:
#	packages/opencode/test/kilocode/sessions/remote-sender.test.ts
@iscekic
iscekic merged commit bcff5cb into main Jul 22, 2026
30 checks passed
@iscekic
iscekic deleted the feature/mobile-session-message-queue branch July 22, 2026 11:42
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
* feat(cli): emit session queue state for remote clients

* chore: retrigger CI (HttpApi exerciser stuck on a Blacksmith cache/stickydisk hang for 5 consecutive runs on the previous head)

* chore(cli): remove kilocode_change markers from kilo-owned files
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