Skip to content

Perf: coalesce runtime state snapshots#13

Open
MacHatter1 wants to merge 1 commit into
ObservedObserver:mainfrom
MacHatter1:agent/coalesce-runtime-snapshots
Open

Perf: coalesce runtime state snapshots#13
MacHatter1 wants to merge 1 commit into
ObservedObserver:mainfrom
MacHatter1:agent/coalesce-runtime-snapshots

Conversation

@MacHatter1

Copy link
Copy Markdown
Contributor

Summary

Reduce redundant runtime snapshot construction and state broadcasts in the Electron runtime.

Why

Runtime commands were cloning and projecting the complete runtime state multiple times before a single command finished. The renderer could then receive repeated full snapshots for the same transaction, increasing main-process work, IPC payload churn, and React state replacement.

A small baseline measurement on an empty runtime showed one provider update constructing 3 snapshots, averaging 886 bytes each (2,658 bytes total).

What changed

  • Centralise runtime.state broadcasts behind a transaction-aware helper.
  • Queue at most one runtime-state broadcast marker per control transaction.
  • Resolve all deferred state-bearing events from one final commit-time snapshot.
  • Apply the same behaviour on the commit-state error path.
  • Preserve existing event shapes and command result payloads.
  • Add a regression test covering snapshot-call reduction and state-event delivery.

Validation

  • npm run test:kernel — 539 tests passed; all kernel smoke checks passed.
  • npm run test:ci — lint, full build, and 187 graph-core tests passed. Existing lint warnings remain.
  • npm run check:electron — passed.
  • npm run acceptance:electron — TypeScript source, compiled Electron entry, declarations, and smoke imports verified.
  • Direct Electron validation:
    • Opened the workflow composer.
    • Changed the Coder provider from Claude Code to Codex and confirmed the Codex profile appeared.
    • Saved a workflow with a prompt and Codex selections.
    • Closed and reopened it from the saved-workflow catalogue.
    • Confirmed the prompt, provider/profile selections, workspace, runtime settings, review instruction, blocking policy, and lap limit were restored.
    • Removed the temporary test workflow afterwards.

Scope

This is intentionally limited to snapshot/broadcast churn. It does not change the public runtime event or command-result API.

@MacHatter1
MacHatter1 marked this pull request as ready for review July 22, 2026 10:08
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