Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(mobile): subagent visibility with agents sheet and liveness #6616

Closedamanthanvi(GitHub profile, opens in a new tab)wants to merge 23 commits intomain fromrefs/pull/6616/headopened View on GitHub

A mobile thread whose parent turn spawned background agents could look finished while child work was still live. This adds batched spawn summaries, liveness-driven Working state on thread lists and detail, an Agents sheet with per-agent status/details, and a guarded Stop flow.

The refreshed server path advertises guarded-interrupt capability explicitly and fails closed when unavailable. Guard validation, provider lifecycle generations, session replacement, rollback, interactive responses, Stop, and delayed ingestion/failure writes are serialized or CAS-protected end to end. ACP prompts become cancellable before lifecycle release, queued prompts are tombstoned on Stop, and stale completions cannot revive stopped or replaced work. Legacy unguarded interrupt behavior remains available only to callers that explicitly use it; mobile never falls back to it for guarded Stop.

session.updatedAt remains the user-visible state-change edge. Guarded Stop uses a separate durable providerLifecycleUpdatedAt token projected from the provider lifecycle, so completion/error timestamps and provider CAS revisions cannot diverge. Background liveness preserves main's status-free-progress no-resurrection rule while retaining task/agent anchors and tombstones across replay and revert.

Closes #6402

Mobile examples: Agents sheet · background indicator + Stop · thread list Working.

Implemented by GPT-5.6 Sol (xhigh) via the Codex CLI, orchestrated and reviewed by Claude Fable 5 (Claude Code), with Claude Opus 5 run monitoring.


Note

Medium Risk Changes interrupt/stop semantics and projection liveness reconciliation; mobile fails closed without guardedInterrupt, but wrong lifecycle or revert handling could show incorrect working state or stop outcomes.

Overview Adds mobile subagent visibility so threads no longer look idle while background work continues. The work log now shows batched spawn summary rows (tap opens Agents) instead of raw per-task lifecycle noise, and thread list/detail surfaces working / monitoring from backgroundLiveness, with stale liveness cleared on cached shell load and suppressed after terminal session states.

New Agents roster and detail screens (stack routes + deep links) list workflows, phases, and direct spawns with status, usage, and activity; cold-start navigation handles deep links without a back stack.

Stop for background work is gated on server guardedInterrupt: confirmation dialogs, disabled controls while config or an interrupt is in flight, command-correlated resolution from provider.turn.interrupt.resolved, and no unguarded interrupt fallback on mobile.

Server-side in this diff: advertises guardedInterrupt, wires ThreadBackgroundLiveness into projection (rebuild on thread.reverted, bootstrap reconciliation), and defers turn interruption settlement for guarded interrupts until the resolved activity arrives; sessions persist providerLifecycleUpdatedAt for guard inputs.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7fa3bdb90d28bf7fcd2514d6fd2accd4e7f88e3e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add subagent visibility with Agents sheet, background liveness, and guarded interrupts

  • Mobile: Introduces Agents roster and detail screens (ThreadAgentsSheet.tsx), new 'Working' and 'Monitoring' thread statuses derived from background liveness, and subagent spawn-batch summarization in the work log
  • Server: ProviderService now serializes all thread-affecting operations via per-thread lifecycle locks and turn-start markers; guarded interrupts check expectedTurnId/expectedSessionUpdatedAt atomically against provider state and emit resolution receipts via RuntimeReceiptBus
  • Server: ThreadBackgroundLiveness tracks bounded activity anchors per live agent, uses tombstones with TTL to prevent task resurrection from trailing progress, and supports rebuildThreadLiveness for revert/bootstrap reconciliation
  • Contracts/Persistence: Adds guardedInterrupt capability flag, providerLifecycleUpdatedAt session field, migrations 41 (ProjectionSyncedClientPreferences) and 42 (ProjectionThreadSessionProviderLifecycle), and listByActivityIds query for fetching live-task anchor activities
  • Behavioral Change: ProviderService.listSessions now reports updatedAt as the lifecycle snapshot timestamp rather than the adapter's raw value; thread.session.set with mismatched expectedSessionUpdatedAt returns no events; respondToRequest/respondToUserInput return ProviderSessionNotFoundError when inactive instead of recovering; cached shell snapshots force backgroundLiveness to null on load; ACP prompt calls can be cancelled prior to dispatch on scope closure; ProviderRuntimeIngestion maps task.progress to synthetic stable activity ids (task-progress:<threadId>:<taskId> or task-usage:...)
Macroscope summarized 7fa3bdb.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 65fc837b-220c-461a-94b0-b8b20910bbff

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/df511ba4888044651c735109ab0bf03c0bbe3ad1/packages/client-runtime/src/state/threads.ts#L609

      provider.turn.interrupt.resolved can report an incorrect turn duration: when latestTurn.completedAt contains a mid-turn checkpoint timestamp, this branch preserves that earlier value instead of recording the interrupt resolution time. The resolution is the terminal edge, so set completedAt to activity.createdAt unconditionally.

      ✅ Resolved in c47681f33fee7926757882c68fbb044cea1b48af

    4. Pull request overview

      Adds end-to-end mobile subagent visibility parity by surfacing spawn batches, background liveness (“Working/Monitoring”), and a dedicated Agents roster/detail UI, while also tightening server/client interrupt semantics via optional CAS guards and improving cold-start liveness reconstruction.

      Changes:

      • Mobile: introduce Agents sheet + agent detail, spawn-batch summary rows in the work log, and background liveness indicators (plus guarded “Stop background work” UX).
      • Server: add guarded interrupt plumbing + receipts, liveness rebuild on revert, and bounded live-agent lifecycle anchors so cold-start pagination still shows running batches.
      • Shared/runtime: extend the subagent fold with batch counts and uncapped roster option (web default remains capped).

      Reviewed changes

      Copilot reviewed 47 out of 47 changed files in this pull request and generated 1 comment.

      Show a summary per file
      FileDescription
      packages/contracts/src/orchestration.tsAdds optional interrupt preconditions and guard decision payload fields to orchestration schemas.
      packages/contracts/src/orchestration.test.tsTests decoding of additive interrupt guard fields without breaking legacy commands.
      packages/client-runtime/src/state/threads.tsMerges older pages and now sorts merged activity rows canonically (see blocking comment about toSorted).
      packages/client-runtime/src/state/threads-pagination.test.tsAdds pagination tests to ensure retained anchors merge in correct order.
      packages/client-runtime/src/state/threadReducer.tsAvoids optimistic interrupt projection for guarded interrupts; stamps interrupted state from resolution activity.
      packages/client-runtime/src/state/threadReducer.test.tsVerifies guarded vs legacy interrupt behavior and resolution-driven interruption.
      packages/client-runtime/src/state/subagentRuntime.tsExtends fold to include batch counts, optional uncapped roster, and activity truncation metadata.
      packages/client-runtime/src/state/subagentRuntime.test.tsTests roster cap parameterization, batch counts, and truncation flag behavior.
      docs/user/agents.mdDocuments the new Agents surface and guarded Stop behavior for users.
      apps/server/src/orchestration/ThreadBackgroundLiveness.tsTracks richer live-agent anchor IDs, adds tombstones, supports rebuild after revert, and exposes anchor getters.
      apps/server/src/orchestration/ThreadBackgroundLiveness.test.tsTests live anchor retention, tombstone behavior, and injected clock expiry.
      apps/server/src/orchestration/Services/RuntimeReceiptBus.tsAdds a typed receipt for provider interrupt resolution outcomes (including work-changed/no-session).
      apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.tsChanges session.updatedAt to state-change edge stamp; threads activity ingestion records activityId for liveness anchoring.
      apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.tsTests updatedAt no longer changes on heartbeat-like state updates mid-turn.
      apps/server/src/orchestration/Layers/ProviderCommandReactor.tsImplements guarded interrupt validation/publishing, appends resolution activity, and emits receipts.
      apps/server/src/orchestration/Layers/ProviderCommandReactor.test.tsAdds tests for stale guards, queued revalidation, and success resolution outcomes/receipts.
      apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.tsAdds bounded lookup of live-agent lifecycle rows by IDs to supplement windowed thread detail on cold start.
      apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.test.tsTests inclusion/capping of live-agent anchors and ordering guarantees.
      apps/server/src/orchestration/Layers/ProjectionPipeline.tsRebuilds liveness after prune/revert; stamps interrupted turns via resolution activity; avoids optimistic interrupt for guarded path.
      apps/server/src/orchestration/Layers/ProjectionPipeline.test.tsAdds revert+liveness preservation tests; updates layers to ensure liveness service wiring.
      apps/server/src/orchestration/Layers/OrchestrationEngine.test.tsUpdates layer wiring to ensure consistent liveness dependency injection.
      apps/server/src/orchestration/Layers/CheckpointReactor.test.tsUpdates layer wiring similarly for checkpoint-related tests.
      apps/server/src/orchestration/decider.tsStamps guardDecision from current session state when interrupt command includes guards.
      apps/server/src/orchestration/decider.settled.test.tsTests guardDecision stamping behavior for matched vs work-changed.
      apps/mobile/src/Stack.tsxRegisters new ThreadAgents and ThreadAgentDetail routes with deep links.
      apps/mobile/src/lib/threadActivity.tsReplaces agent lifecycle rows with spawn-batch summaries; adds memoized fold + persistent CTA grouping.
      apps/mobile/src/lib/threadActivity.test.tsAdds extensive tests for spawn-batch grouping, visibility/pinning, and memoization behavior.
      apps/mobile/src/features/threads/ThreadRouteScreen.tsxAdds guarded Stop flow with command correlation, in-flight dedupe, and resolution detection.
      apps/mobile/src/features/threads/threadPresentation.tsAdds background liveness status resolution (Working vs Monitoring) for thread pills.
      apps/mobile/src/features/threads/threadPresentation.test.tsTests liveness suppression on terminal sessions and correct prioritization vs errors.
      apps/mobile/src/features/threads/threadListV2.tsThread list status now incorporates background liveness (working/monitoring).
      apps/mobile/src/features/threads/threadListV2.test.tsTests thread list status/shelving behavior with liveness and explicit settle overrides.
      apps/mobile/src/features/threads/ThreadFeed.tsxWires “Open Agents” action through feed rendering for spawn summary rows.
      apps/mobile/src/features/threads/ThreadDetailScreen.tsxAdds background banner + Stop action, disables stop while in-flight, and passes stop disabling to composer/cards.
      apps/mobile/src/features/threads/ThreadComposer.tsxDisables Stop UI while a stop request is in-flight.
      apps/mobile/src/features/threads/ThreadAgentsSheet.tsxNew Agents roster + agent detail sheets with workflow grouping, phases, usage, and recent activity.
      apps/mobile/src/features/threads/threadAgentsNavigation.tsNew cold-start navigation helpers and unavailable-agent presentation logic.
      apps/mobile/src/features/threads/threadAgentsNavigation.test.tsTests cold-start action routing and unavailable-agent presentation behavior.
      apps/mobile/src/features/threads/thread-work-log.tsxMakes spawn summary rows tappable CTAs that open Agents.
      apps/mobile/src/features/threads/thread-list-v2-items.tsxAdds “Monitoring” status label styling in list rows.
      apps/mobile/src/features/threads/PendingUserInputCard.tsxDisables Stop button when stop is in-flight.
      apps/mobile/src/features/threads/backgroundWorkStop.tsNew guarded Stop helpers: confirmation, interrupt input builder, resolution finder, and in-flight guard with timeout.
      apps/mobile/src/features/threads/backgroundWorkStop.test.tsTests guarded vs legacy inputs, resolution correlation, dedupe, timeout fallback, and generation safety.
      apps/mobile/src/features/threads/agentPresentation.tsNew presentation derivations for mobile Agent row/detail models from shared fold/panel model.
      apps/mobile/src/features/threads/agentPresentation.test.tsTests workflow phases, usage/elapsed formatting, large rosters, and truncation labeling.
      apps/mobile/src/connection/environment-cache-store.tsClears cached backgroundLiveness on shell load to avoid stale “Working/Monitoring” indicators.
      apps/mobile/src/connection/environment-cache-store.test.tsTests background liveness is nulled when loading cached shell snapshots.

      💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Skipped

      Macroscope did not run approvability analysis for this PR. Diff is too large for automated approval analysis, so this PR cannot be approved automatically.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Fixed. An interrupted turn now records the provider.turn.interrupt.resolved activity timestamp as its terminal completedAt value unconditionally (packages/client-runtime/src/state/threadReducer.ts:609).

    7. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    8. Effect Service Conventions review: the service definitions, layers, and dependency acquisition in this PR look conventional (ThreadBackgroundLiveness keeps the inline Context.Service interface with make/layer, and the new clock is acquired via yield* Clock.Clock in the layer rather than closed over). The findings below are all against the change-discipline rule "preserve useful comments, invariants, and specification documentation while moving code": several helpers were relocated verbatim but lost the invariants that documented them.

      Posted via Macroscope — Effect Service Conventions

Sign in to join this conversation.