Skip to main content
Render an agent’s work from its ephemeral branch while the agent runs. Your product can show current and prior states without a second file store or diff service. This guide uses the branch layout from Store Session State.

Read the current diff

Compare the session branch with its normal base branch.
TypeScript
view.files contains the file changes and diff text. view.stats contains the file, line, and change totals. Use getBranchDiff() to filter the response to selected paths.

Read one file

Use the session branch for the latest content, or use a commit SHA for a fixed view.
TypeScript
For a fixed review link, store the state SHA and pass it as ref. The same SHA can also select a commit diff.
TypeScript

Refresh after each state

Use either of these refresh signals:
  1. Poll the session branch tip, then reload the diff when the SHA changes.
  2. Subscribe to push webhooks, validate each delivery, and reload the diff for the same repository and branch.
Treat the webhook as a signal. Read the branch again after each event. Do not use the event as your state store. See Webhooks for subscriptions, signatures, and retries.

Keep credentials on the server

Call Code Storage from your backend. Do not send your organization private key or a write token to the browser. Cache a diff by its head SHA when many viewers request the same state. A new state gets a new SHA and a new cache key.