Skip to content

fix(cloud-agent): preserve attachments during offline-first session creation - #8446

Merged
eshurakov merged 3 commits into
mainfrom
kilo/blissful-island-kzn
Oct 21, 2026
Merged

eshurakov merged 3 commits into
mainfrom
kilo/blissful-island-kzn

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

  • Fix a race introduced by offline-first new-session creation: the composer called clearAttachments() immediately after createLocalSession(), releasing and deleting pending uploads before asynchronous prepareSession could link them.
  • Keep uploaded files owned by the local session through navigation, preparation, and retry. Component unmount still cleans up preview URLs without releasing submitted files.
  • Remove the now-unnecessary attachment UUID reset; navigation unmounts the panel and its creation guard prevents duplicate submissions.
  • Add behavioral regression coverage for personal and organization chats using the real new-session panel and upload hook, with mocked network boundaries. Verify attachment references survive handoff and no pending-upload release occurs on submit or unmount.

Verification

  • Regression reproduced before the fix: both personal and organization cases released the uploaded object prematurely.
  • 29 tests passed across NewSessionPanel.attachment-handoff.test.ts, useCloudAgentAttachmentUpload.test.ts, and ChatInput.finalize.test.ts. Used a database-independent Jest configuration because the default global setup requires PostgreSQL unavailable in this sandbox.
  • Formatting and focused oxlint passed; git diff --check passed.
  • Full web TypeScript check did not finish within the sandbox limit of 210 seconds.
  • Independent code review found no material issues.

Scope

  • No changes to attachment validation, upload limits, or server-side linking and cleanup policies.
  • No deployed/browser end-to-end upload was exercised.

@kilo-code-bot

kilo-code-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The follow-up correctly closes the discard leak: uploads are released only after a definitively failed creation, with ambiguity, in-progress polling, retries, and restored sessions conservatively excluded, and the new object keys match the server's ${userId}/cloud-agent/${path}/${file} format.

Assumptions: [INFERENCE] The new provider and request tests were not executed in this read-only review; correctness was validated by reading the provider, request helper, storage schema, upload hook, and both releasePendingUploads routers. The unrelated concurrency assertion loosening in kilo-pass-org/consumption.test.ts was accepted as an intentional race fix per the PR's test commit.

Files Reviewed (7 files)
  • apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx
  • apps/web/src/components/cloud-agent-next/local-sessions/LocalSessionsProvider.tsx
  • apps/web/src/components/cloud-agent-next/local-sessions/local-session-request.ts
  • apps/web/src/components/cloud-agent-next/local-sessions/local-session.ts
  • apps/web/src/components/cloud-agent-next/local-sessions/LocalSessionsProvider.test.ts
  • apps/web/src/components/cloud-agent-next/local-sessions/local-session-request.test.ts
  • apps/web/src/lib/kilo-pass-org/consumption.test.ts
Previous Review Summary (commit d3dfb53)

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

Previous review (commit d3dfb53)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The handoff fix is correct and well covered; the one gap is that uploads are now owned by a local session whose discard path never releases them, leaving R2 objects and pending-ledger rows to the 24-hour reaper.

Assumptions: [INFERENCE] The new regression test was not executed in this read-only review; it was validated by reading the component, upload hook, local-session provider, and prepareSession router path it exercises. No deployed/browser upload was exercised, as the PR states.

Overview

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

SUGGESTION

File Line Issue
apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx 1142 Discarding or silently dropping a failed local session never releases its pending uploads, so R2 objects and cloud_agent_pending_uploads rows persist until the 24-hour reaper. releasePendingUploads is safe here because it only claims pending rows.
Files Reviewed (2 files)
  • apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx - 1 issue
  • apps/web/src/components/cloud-agent-next/NewSessionPanel.attachment-handoff.test.ts - no issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 79.1K · Output: 19.3K · Cached: 2.5M

Review guidance: REVIEW.md from base branch main

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