08. Trust, History, and Compacting

Trust Is Treated as a Real Boundary

interactiveHelpers.tsx and components/TrustDialog/TrustDialog.tsx show that trust is not cosmetic. The app delays system context prefetch, full environment application, GrowthBook reinitialization, and some approvals until trust is accepted. The trust dialog also checks for hooks, MCP servers, helper commands, bash settings, and dangerous environment variables.

History Is Session Infrastructure, Not a Convenience Feature

history.ts uses JSONL logs, reverse readers, per-project filtering, paste references, lazy resolution, and session ordering. That means command history is used as structured session infrastructure, not just a line buffer.

Compacting Is an Operating Constraint

The files under services/compact/ show a dedicated subsystem for keeping long sessions alive. The compacting layer tracks token budgets, attachment reinjection, file restoration, partial compacting, post-compact cleanup, and retry limits.

This is one of the strongest lessons in the whole tree: once a product supports long sessions, prompt management becomes memory engineering.

AppState Explains Product Scope

state/AppStateStore.ts is worth reading because it reveals product ambition in one place: tasks, agent registry, MCP clients, plugin loading, remote sessions, bridge state, session URLs, teammate views, todo state, file history, permissions, and rich footer behavior.

Takeaway

The source is not only about “how to call tools.” It is about how to keep a long-lived, interactive, stateful developer product safe and usable after many turns, many files, many tools, and many session transitions.

Source Navigation

Recommended Source Files

  • source/components/TrustDialog/TrustDialog.tsx
  • source/history.ts
  • source/services/compact/compact.ts
  • source/services/compact/autoCompact.ts
  • source/services/compact/microCompact.ts

Next Files to Read

  • source/services/SessionMemory/sessionMemory.ts
  • source/services/compact/prompt.ts
  • source/services/compact/sessionMemoryCompact.ts