Skip to content

Extract agent session management, run-manager, and usage stats to @studio/common#3987

Open
youknowriad wants to merge 4 commits into
trunkfrom
extract-agent-sessions
Open

Extract agent session management, run-manager, and usage stats to @studio/common#3987
youknowriad wants to merge 4 commits into
trunkfrom
extract-agent-sessions

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Proposed Changes

Behavior-preserving refactor. Moves the agent-session backend into transport-agnostic modules under @studio/common so the desktop app and the upcoming studio ui local web server share one implementation:

  • ai/sessions/manage — session listing + creation (hydrated with star/archive + site placement)
  • ai/sessions/run-manager — the agent run lifecycle (fork CLI, relay events, interrupt policy)
  • ai/sessions/placement — which local site a session owns (app.json)
  • ai/sessions/agent-stats + lib/app-bump-stats — Studio Code usage stats
  • lib/error-reporting — SDK-agnostic Sentry reporting helper

The desktop side now delegates: ai-agent/run-manager, ai-session-placement, bump-stats, and the session IPC handlers. Adds @sentry/core + atomically to tools/common. No user-facing change.

Independent of the site-operations PR; based on trunk. Part of splitting the studio ui proof-of-concept (#3953).

Testing Instructions

  • npm run typecheck clean for tools/common, apps/studio, apps/cli.
  • npm test -- tools/common/ai/sessions/tests/ (17 tests pass).
  • Smoke: start a new chat (with and without a site), send a prompt, interrupt a run, star/archive a session.

Pre-merge Checklist

  • Verify agent runs, session create/list, and usage-stat bumping still work in the desktop app.

…udio/common

Moves session listing/creation (manage), the agent run lifecycle (run-manager), site placement (placement), Studio Code usage stats (agent-stats + app-bump-stats), and a Sentry reporting helper (error-reporting) into transport-agnostic @studio/common modules. Desktop's ai-agent/run-manager, ai-session-placement, bump-stats, and the session IPC handlers now delegate to them. Adds @sentry/core + atomically to tools/common. No behavior change; this is the shared backend the studio ui local server will reuse. Part of splitting #3953.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wpmobilebot

wpmobilebot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 78783f2 vs trunk

app-size

Metric trunk 78783f2 Diff Change
App Size (Mac) 1315.58 MB 1315.64 MB +0.07 MB ⚪ 0.0%

site-editor

Metric trunk 78783f2 Diff Change
load 774 ms 771 ms 3 ms ⚪ 0.0%

site-startup

Metric trunk 78783f2 Diff Change
siteCreation 6480 ms 6517 ms +37 ms ⚪ 0.0%
siteStartup 6550 ms 6556 ms +6 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

youknowriad and others added 3 commits June 29, 2026 13:14
…ents

Deletes the desktop src/lib/ai-session-placement re-export and points its importers at @studio/common/ai/sessions/placement directly; trims the app-bump-stats header to its behavioral notes and fixes a stale recordAgentSend comment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- run-manager routing: key the desktop binding by the unique runId (carried on both RunManagerOutput kinds) instead of sessionId, fixing two races where an interrupt-then-restart or a rejected concurrent start on the same session silenced a run's events.
- agent-stats: report weekly/monthly unique-stat bump failures to Sentry via the shared captureException instead of swallowing them (matches the app-wide convention); make getPlatformMetric module-private.
- bump-stats: lastBumpStatsProvider is now module-private with an accurate comment (the shared agent stats use appBumpStatsProvider, not this).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

2 participants