Skip to content

fix(session-ingest): preserve attachment capability in live heartbeats - #4671

Merged
iscekic merged 2 commits into
mainfrom
fix/mobile-remote-capability-heartbeat
Jul 22, 2026
Merged

fix(session-ingest): preserve attachment capability in live heartbeats#4671
iscekic merged 2 commits into
mainfrom
fix/mobile-remote-capability-heartbeat

Conversation

@iscekic

@iscekic iscekic commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • project each CLI connection capability onto every live sessions.heartbeat session row
  • preserve true, false, and absent capability semantics
  • keep live heartbeat behavior aligned with activeSessions.list

Why

The merged remote-attachment flow initially enables the mobile paperclip from the active-session snapshot, then the next live heartbeat disables it because the SDK reads capability from each session row while session-ingest only sent it at the envelope level.

Companion CLI PR: Kilo-Org/kilocode#12394

Verification

  • 573 session-ingest tests
  • session-ingest typecheck
  • session-ingest lint
  • git diff --check
  • independent review: no findings

@iscekic iscekic self-assigned this Jul 22, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental commits switch buildRemoteAttachmentParts to derive the download presign's messageUuid from submission.wire.path instead of submission.messageUuid, correctly matching the R2 key segment used at upload time (uploadOne presigns with messageUuid: path, not the independently-generated messageUuidRef); the accompanying test update verifies the corrected call, and no defects were found in the changed lines.

Files Reviewed (2 files)
  • apps/mobile/src/components/agents/mobile-session-manager-helpers.ts
  • apps/mobile/src/components/agents/mobile-session-manager.test.ts
Previous Review Summary (commit 59c9562)

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

Previous review (commit 59c9562)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the heartbeat capability-projection change in UserConnectionDO.ts and its accompanying tests; the per-row spread mirrors the existing aggregateSessions() truthy-object pattern and correctly preserves true/false/absent capability semantics with no defects found in the changed lines.

Files Reviewed (2 files)
  • services/session-ingest/src/dos/UserConnectionDO.ts
  • services/session-ingest/src/dos/UserConnectionDO.test.ts

Reviewed by claude-sonnet-5 · Input: 62 · Output: 8.2K · Cached: 2M

Review guidance: REVIEW.md from base branch main

@iscekic

iscekic commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

(bot) @kilocode-bot please re-review latest head 4ed258a. Local E2E found and fixed a distinct upload-path/message-UUID R2 key mismatch, with a regression using intentionally different IDs.

@iscekic

iscekic commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

(bot) Final local iOS E2E passed on exact head 4ed258a655a9e364639c21809ac33fe1a9793e4c with Kilo CLI head 6750e1c9425c16ee7a2700f7bf3d259d118b0326: capability remained available after heartbeat, logo.png uploaded, download presigning used the matching upload path, the CLI materialized it, and Auto Efficient / Qwen 3.7 Plus described it successfully. All 16 checks pass; Kilobot reports no issues and there are no unresolved threads.

@kilo-code-bot kilo-code-bot Bot left a comment

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.

Re-review @ 4ed258a

Recommendation: ✅ Merge

Re-reviewed the full diff at the latest head. The new second commit adds a genuine bug fix + regression test on top of the already-clean heartbeat change. Both areas look correct.

1. R2 key mismatch fix — correct ✅

apps/mobile/src/components/agents/mobile-session-manager-helpers.ts now presigns downloads with submission.wire.path instead of submission.messageUuid.

Tracing the key construction confirms this is the right fix:

  • Upload (upload-task.tsgetAttachmentUploadUrlgenerateCloudAgentAttachmentUploadUrl) builds the key as ${userId}/cloud-agent/${messageUuid}/${attachmentId}.${suffix}, where the messageUuid segment is passed as path (i.e. pathRef.current).
  • Download (getAttachmentDownloadUrlgenerateCloudAgentAttachmentDownloadUrl) builds ${userId}/cloud-agent/${messageUuid}/${filename}.

In use-agent-attachment-upload.ts, pathRef and messageUuidRef are two independent Crypto.randomUUID() values. The upload always used path, but the download helper was passing the unrelated messageUuid, so the middle key segment never matched and the presigned GET pointed at a nonexistent object. Switching the download to submission.wire.path makes the download key segment identical to the upload key segment. The filename (file.remoteName = remoteFilename = <attachmentId>.<ext>, the basename of the upload key) already matched, so the full key now reconciles. Fix is correct and minimal.

2. Regression test — exercises the bug and would have caught it ✅

mobile-session-manager.test.ts now uses intentionally distinct IDs: messageUuid: 'msg-uuid' vs wire.path: 'upload-path', and asserts every mutate call carries messageUuid: 'upload-path'. Against the pre-fix code (which passed submission.messageUuid), the assertion would have received 'msg-uuid' and failed — so it genuinely reproduces the original mismatch. The previous test used path: 'msg-uuid' (equal to messageUuid), which is exactly why the bug slipped through. Good regression coverage.

3. Heartbeat capability-projection change — still correct & untouched ✅

git diff between the two commits shows the second commit touches only the two mobile files. The UserConnectionDO.ts per-row projection and its test are unchanged from the previously-approved commit. The projection still preserves true / false (truthy object → spread) and absent (undefined → omitted) semantics, consistent with the rewritten DO test.

4. Verification

  • UserConnectionDO.test.ts — 143/143 pass
  • mobile-session-manager.test.ts — passes; full mobile suite 1591/1591 pass
  • The 2 failing services/session-ingest/src/routes/api.test.ts cases are unrelated 5s-timeout flakes on the R2-offload queue path (file untouched by this PR, times out in the constrained sandbox)
  • Remaining oxlint findings on the changed files are type-info-dependent no-unsafe-* noise on the standard vi.mocked(...) mock chain (present pre-PR; resolved with typed linting in CI)

Both the R2 key mismatch fix and its regression test are correct and sufficient.

@kilo-code-bot

kilo-code-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Re-review posted: APPROVED on head 4ed258a6.

Summary: the R2 key mismatch fix is correct (download now presigns with wire.path instead of the independent messageUuid, matching the upload key), the regression test genuinely catches the bug with distinct IDs, and the heartbeat capability-projection logic from earlier commits is untouched and still correct. Only unrelated flaky timeouts elsewhere. Recommendation: merge.

@iscekic
iscekic merged commit fca772a into main Jul 22, 2026
20 checks passed
@iscekic
iscekic deleted the fix/mobile-remote-capability-heartbeat branch July 22, 2026 14:00
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