Skip to content

feat: add fast existing-file edits and resilient previews - #199

Merged
iamjr15 merged 1 commit into
mainfrom
feat/fastapply-resilient-previews
Aug 9, 2026
Merged

feat: add fast existing-file edits and resilient previews#199
iamjr15 merged 1 commit into
mainfrom
feat/fastapply-resilient-previews

Conversation

@iamjr15

@iamjr15 iamjr15 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Show Working immediately after submission while preserving a single continuous elapsed timer into the real response.
  • Replace timestamp-based Daytona source sync with content-addressed, atomic, crash-safe synchronization and package transactions.
  • Add production Morph FastApply support for existing UTF-8 files through a bounded REST client and conflict-safe sandbox writes.

What's Included

Immediate run feedback

  • Adds a view-only pending assistant state before the first streamed response.
  • Prevents duplicate pending states during reconnects and keeps elapsed time stable.

Resilient sandbox synchronization

  • Uses SHA-256 content identity instead of comparing clocks across filesystems.
  • Makes file replacement atomic and handles file, directory, and symlink type changes.
  • Uses an OS lock and a three-way, conflict-aware package transaction that releases automatically after crashes.

Production FastApply

  • Adds a small first-party Morph REST package with strict validation, bounded bodies, timeouts, and transient retries.
  • Resolves the Morph credential lazily from Cloudflare Secrets Store inside the active run.
  • Adds fs_apply for existing text files and preserves fs_write for creation, binary data, and full replacements.
  • Commits generated edits with a compare-and-swap write so concurrent source changes cannot be overwritten.

Architecture

The agent reads an existing file from the sandbox, sends the original content plus a sparse edit to Morph, and commits the generated candidate only when the source hash still matches. Daytona local package execution now performs force-sync, command execution, and conflict-aware commit under one process lock. The web client renders submission feedback locally until the authoritative stream arrives.

Decisions Made

Decision Choice Alternatives considered Reasoning
Morph integration Bounded first-party REST client Pre-1.0 SDK Keeps the Worker dependency surface small and makes limits, validation, retries, and error redaction explicit.
Existing-file writes Compare-and-swap Unconditional overwrite Prevents stale model output from clobbering concurrent edits.
Source identity SHA-256 content hashes Cross-filesystem mtimes Clocks and timestamp granularity differ across Daytona object storage and native disk.
Package transaction One locked remote operation Prepare/commit/abort markers OS locks are released on process death and eliminate stale marker recovery.
Pending UI View-only synthetic assistant Persisted placeholder message Gives immediate feedback without corrupting durable chat history.

Edge Cases Handled

Scenario Handling
Equal-size edit with older mtime Content hashing still detects it.
Process crash during package command OS lock releases and durable source remains unchanged.
Concurrent file edit during FastApply Hash mismatch returns a retriable conflict.
Provider redirect or oversized response Request is rejected at the client boundary.
Reconnect with an existing assistant response Pending UI is not duplicated.

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm turbo build --force
  • pnpm deadcode
  • pnpm architecture:check
  • pnpm turbo skills:build
  • Deterministic synchronizer harness: content, deletion, retyping, transaction, conflict, and crash cases
  • Production Worker dry-run with the Morph Secrets Store binding
  • Production browser QA after merge and snapshot promotion

Adds immediate run feedback and bounded Morph FastApply.
Uses compare-and-swap writes plus content-addressed sandbox sync.
Makes package transactions crash-safe.
@iamjr15
iamjr15 merged commit aa11272 into main Aug 9, 2026
4 checks passed
@iamjr15
iamjr15 deleted the feat/fastapply-resilient-previews branch August 9, 2026 17:10
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