release: session archive side effects + stopSandboxOnArchive (#578)

Merged
SW
6mo ago
+163-0

Promotes test to main. Headline change:

  • #578 — feat(sessions): archive side effects + stopSandboxOnArchive. PR brought to parity with open-agents on snapshot fallback preservation and lifecycle_error cleanup; live verified on preview.

Also includes other commits already merged to test.


Summary by cubic

Promotes test to main. Adds reliable session archive/unarchive lifecycle handling with deferred sandbox teardown and a 409 guard while a sandbox is pausing. Also brings recent chat workflow, credits, chats API, and session-create improvements.

  • Sessions lifecycle and sandbox management

    • PATCH /api/sessions/{sessionId} applies ARCHIVE_LIFECYCLE_PATCH/UNARCHIVE_LIFECYCLE_PATCH to set lifecycle fields synchronously.
    • Defers sandbox stop with after() from next/server, running stopSandboxOnArchive to stop and clear runtime state; preserves snapshot as a fallback and only nulls it after a successful stop; on stop failure, writes lifecycle_error and clears runtime state if no snapshot exists.
    • Rejects unarchive with 409 when the sandbox is still pausing and no snapshot is available via isSandboxPausing + isUnarchiveConflict.
    • Tests updated to mock after() and stopSandboxOnArchive.
  • Other updates

    • Chat workflow: persists assistant message per step, charges credits atomically with audit via RPC, and auto-commits/pushes after natural finishes (including persisting the commit data chunk on the message).
    • Sessions create: automatically provisions a workspace repo on GitHub (recoupable/<accountId> or org), adds organizationId, and removes cloneUrl and branch from the request.
    • Chats API: migrates GET/PATCH/DELETE for session chats with camelCase responses.

Summary by CodeRabbit

  • New Features

    • Added session archive and unarchive functionality with lifecycle state management.
    • Implemented automatic sandbox cleanup and resource management when sessions are archived.
  • Improvements

    • Prevents unarchive conflicts by detecting when sandboxes are pausing, returning appropriate conflict responses until the pause completes.

Review Change Stack