Skip to content

feat(session-ingest): push notifications for remote session attention signals#4445

Open
eshurakov wants to merge 1 commit into
mainfrom
likeable-dreadnought
Open

feat(session-ingest): push notifications for remote session attention signals#4445
eshurakov wants to merge 1 commit into
mainfrom
likeable-dreadnought

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

The session-ingest service now sends a mobile push to the session owner when a remote root session needs attention — either the assistant just finished a turn (status → idle) or the session is waiting on user input (status → question/permission). This closes the loop for users running sessions from VS Code or the Agent Manager, who otherwise have no signal that their session is ready for them.

Architectural changes:

  • SessionIngestDO.ingest() now returns attentionSignals alongside changes. On an idle transition (with a prior status already stored), it pairs the transition with the most recent completed assistant message and builds a push-ready text excerpt from that turn's ingested text parts. Needs-input transitions emit a signal without an excerpt.
  • New session-ingest-attention.ts owns status classification, completed-assistant-message detection (validated via zod), and excerpt assembly with whitespace collapse + 100-char truncation to fit push payloads.
  • New remote-session-notifications.ts owns eligibility (root sessions from vscode/agent-manager only), subscriber suppression, push body construction, and the dispatch coroutine. The push reuses the completed status enum for needs-input signals because the notifications service ignores status and extending the enum would break a notifications worker deployed with the old schema.
  • UserConnectionDO exposes hasSessionSubscribers(sessionId) so pushes are suppressed when the user already has the session open in the web app.
  • queue-consumer collects signals across ingest chunks and dispatches them via ctx.waitUntil after committing. On the failure path it flushes partial metadata changes AND dispatches signals from already-committed chunks, because a committed status transition will not re-emit on retry.
  • New @kilocode/notifications workspace dependency and a NOTIFICATIONS service binding (entrypoint NotificationsService) wired in wrangler.jsonc and declared in notifications-binding.ts.

Verification

  • No manual verification was performed in this session. The change is Worker/Durable-Object logic that requires a deployed session-ingest + notifications service stack and a real push provider to exercise end-to-end; unit and integration tests cover detection, eligibility, suppression, and partial-flush-on-failure behavior.
  • [ ]

Visual Changes

N/A

Reviewer Notes

  • First-status guard: a completed signal is only emitted when the DO already had a prior status stored (hadPriorStatus). This prevents a full-history backfill of an already-idle session from pushing about an old turn.
  • Partial flush on failure: when a later ingest chunk fails after an earlier chunk committed, signals from the committed chunk are still dispatched (mirrors the existing partial-metadata flush), since retry won't re-emit the persisted status transition. Covered by a 129-item chunk-cap test.
  • Best-effort dispatch: dispatch runs in ctx.waitUntil and swallows/logs errors; a push failure never blocks ack'ing or retrying the queue message.
  • Bounded scan: findLastCompletedAssistantMessageId scans the 50 newest message rows; R2-offloaded message rows (inline '{}') are skipped.
  • Subscribers check: hasSessionSubscribers is called per-signal against UserConnectionDO; the stub is created via getUserConnectionDO(env, { kiloUserId }).

@kilo-code-bot

kilo-code-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The latest changes replace web-view push suppression with a presence-based check and add local-CLI-activity suppression, but the previously flagged eligibility gap (local terminal CLI sessions still qualify for pushes, not just VS Code/Agent Manager sessions) remains unresolved since isEligibleForRemoteSessionAttention was not touched in this update.

Overview

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

WARNING

File Line Issue
services/session-ingest/src/remote-session-notifications.ts 15 Eligibility check still doesn't restrict pushes to VS Code/Agent Manager sessions; unchanged in this update (previously reported)
Files Reviewed (16 files, incremental)
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx - no issues
  • apps/web/src/hooks/useCliSessionPresence.ts - no issues
  • packages/event-service/package.json - no issues
  • packages/event-service/src/__tests__/presence.test.ts - no issues
  • packages/event-service/src/presence.ts - no issues
  • packages/notifications/src/rpc-schemas.ts - no issues
  • services/notifications/src/lib/cloud-agent-session-push.ts - no issues
  • services/notifications/src/lib/notifications-service-cloud-agent.test.ts - no issues
  • services/session-ingest/src/dos/UserConnectionDO.test.ts - no issues
  • services/session-ingest/src/dos/UserConnectionDO.ts - no issues
  • services/session-ingest/src/queue-consumer.test.ts - no issues
  • services/session-ingest/src/queue-consumer.ts - no issues
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues
  • services/session-ingest/src/remote-session-notifications.ts - 1 issue (carried forward, unchanged code)
  • services/session-ingest/src/types/user-connection-protocol.test.ts - no issues
  • services/session-ingest/src/types/user-connection-protocol.ts - no issues

pnpm-lock.yaml was skipped (generated file).

Fix these issues in Kilo Cloud

Previous Review Summaries (2 snapshots, latest commit e9f3fd2)

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

Previous review (commit e9f3fd2)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental changes replace the platform-based push eligibility check with an active-CLI-heartbeat check that no longer restricts remote-session attention pushes to VS Code/Agent Manager sessions, broadening pushes to local terminal CLI sessions as well.

Overview

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

WARNING

File Line Issue
services/session-ingest/src/remote-session-notifications.ts 12 Eligibility check dropped the createdOnPlatform restriction; the new hasActiveCliSession gate doesn't restore it, so local terminal CLI sessions now also receive push notifications
Files Reviewed (8 files, incremental)
  • services/notifications/src/index.ts - logging only, no issues
  • services/notifications/src/lib/cloud-agent-session-push.ts - logging only, no issues
  • services/session-ingest/src/dos/UserConnectionDO.test.ts - no issues
  • services/session-ingest/src/dos/UserConnectionDO.ts - no issues
  • services/session-ingest/src/queue-consumer.test.ts - no issues
  • services/session-ingest/src/queue-consumer.ts - no issues
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues
  • services/session-ingest/src/remote-session-notifications.ts - 1 issue

pnpm-lock.yaml was skipped (generated file).

Fix these issues in Kilo Cloud

Previous review (commit 552691c)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the new remote-session attention-push pipeline (SessionIngestDO signal detection, queue-consumer dispatch/partial-flush-on-failure, remote-session-notifications eligibility/body-building, and the UserConnectionDO subscriber check) with high confidence and found no security, correctness, or breaking-change issues in the changed code.

Files Reviewed (14 files)
  • services/session-ingest/package.json
  • services/session-ingest/src/dos/SessionIngestDO.ts
  • services/session-ingest/src/dos/UserConnectionDO.test.ts
  • services/session-ingest/src/dos/UserConnectionDO.ts
  • services/session-ingest/src/dos/session-ingest-attention.test.ts
  • services/session-ingest/src/dos/session-ingest-attention.ts
  • services/session-ingest/src/env.ts
  • services/session-ingest/src/notifications-binding.ts
  • services/session-ingest/src/queue-consumer.test.ts
  • services/session-ingest/src/queue-consumer.ts
  • services/session-ingest/src/remote-session-notifications.test.ts
  • services/session-ingest/src/remote-session-notifications.ts
  • services/session-ingest/test/integration/session-ingest-do.test.ts
  • services/session-ingest/wrangler.jsonc

Generated files (pnpm-lock.yaml, worker-configuration.d.ts) were skipped.


Reviewed by claude-sonnet-5 · Input: 58 · Output: 13.1K · Cached: 1.6M

Review guidance: REVIEW.md from base branch main

@eshurakov eshurakov force-pushed the likeable-dreadnought branch from 552691c to e9f3fd2 Compare July 8, 2026 19:28
};

/** Only root sessions (no parent) can be eligible for attention pushes. */
export function isEligibleForRemoteSessionAttention(session: RemoteSessionInfo): boolean {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: Eligibility check no longer restricts pushes to remote (VS Code / Agent Manager) sessions

isEligibleForRemoteSessionAttention dropped the createdOnPlatform check that previously limited eligibility to vscode/agent-manager root sessions. The new hasActiveCliSession gate added in dispatchRemoteSessionAttentionSignal (below) doesn't restore that restriction: UserConnectionDO.hasActiveCliSession returns true for any connected CLI reporting the session in its heartbeat, including a plain local cli session run directly in a user's own terminal. As a result, users actively working in a local terminal session will now also receive mobile push notifications on every idle/needs-input transition, which contradicts this PR's stated goal of closing the loop only for sessions started from VS Code or the Agent Manager.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

… signals

Detect completed assistant turns and needs-input status transitions during
ingest and dispatch a mobile push to the session owner for remote (vscode,
agent-manager) root sessions. Pushes are suppressed when the user already
has the session open in the web app (UserConnectionDO.hasSessionSubscribers).

- SessionIngestDO emits AttentionSignal(s) on idle/question/permission
  transitions, pairing completed turns with the just-finished assistant
  message excerpt. First-ever status writes are skipped to avoid pushing
  about an old turn on full-history backfill.
- queue-consumer collects signals across chunks and dispatches them via a
  NOTIFICATIONS service binding; partial flush on failure preserves
  signals from already-committed chunks.
- Adds @kilocode/notifications dependency and wrangler NOTIFICATIONS binding.
@eshurakov eshurakov force-pushed the likeable-dreadnought branch from e9f3fd2 to 2362a7a Compare July 9, 2026 09:51
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.

1 participant