Skip to content

feat: automatic project owner enrolment for new threads - #1

Open
matthewcosier wants to merge 1 commit into
mainfrom
feat/project-owner-threads
Open

matthewcosier wants to merge 1 commit into
mainfrom
feat/project-owner-threads

Conversation

@matthewcosier

@matthewcosier matthewcosier commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Problem

Long-lived coordinator threads manage multiple worker threads, answer their questions, and review their results. Today, starting a new thread in a project and handing it to that coordinator requires dragging the thread into the coordinator's composer and sending a manual handover message. Asking the coordinator to start the thread instead stalls quick tasks behind whatever long turn the coordinator is currently running.

Change

Adds a per-project ownerThreadId binding and server-side automatic enrolment for new user-started threads:

  • Contracts (packages/contracts):
    • Added optional ownerThreadId to Project, OrchestrationProjectShell, ApplicationProjectMetaUpdatedPayload, and ProjectMutation's project.update variant. Deliberately omitted ownerThreadId from ProjectUpdatePayload so MCP t3_project_update cannot claim project ownership.
    • Added managedByThreadId to OrchestrationV2AppThread, OrchestrationV2ThreadShell, thread.create, and thread.metadata.update, plus skipOwnerEnrolment on thread.create and OrchestrationV2ThreadLaunchInput.
    • Added "managed_thread" to OrchestrationV2NotificationSource (enrolled, question, approval, run_completed, owner_assigned, owner_replaced).
  • Server (apps/server):
    • Migration 120_ProjectionProjectsOwnerThread adds owner_thread_id (with partial index) on projection_projects, wired through ProjectStore, ProjectCommands, ProjectMutation, and ProjectService (validating that candidate owners are active, unsettled, non-delegated threads).
    • ThreadLaunchService auto-enrols fresh user-started (web / mobile) threads atomically on thread.create, skipping opt-out (skipOwnerEnrolment), reused, agent/MCP, delegated, linked, workflow, imported, scheduled, and self threads.
    • ws.ts strips client-supplied managedByThreadId on thread.create and non-null managedByThreadId on thread.metadata.update (allowing only null to detach).
    • ManagedThreadAppContext injects reversible appContext owner notes on turn start and steer without prompt rewriting.
    • ProjectOwnerReactor handles enrolment notices (first user message with link, title, first message preview, and DispatchModeLimit read-only notice when managed thread modes exceed the owner's), pending user_input question wakes and ProviderRequestKind approval notices (with queued wake cancellation on resolution), idle run_completed notices, owner replacement transfer of active unsettled managed threads (leaving settled/archived threads untouched), and owner retirement cleanup (thread.settled, thread.archived, thread.deleted) without waking the retired owner.
    • Orchestrator upgrades managed_thread notices to non-interrupting mid-turn steer_active alongside delegated_task, and drops stale queued managed_thread question/approval wakes once detached or resolved.
  • Client runtime, Web/Desktop, and Mobile (packages/client-runtime, apps/web, apps/mobile):
    • Added Set as owner of… thread action submenu (recent 10 projects with checkmarks plus Search projects… opening a searchable CommandDialog picker styled with ProjectFavicon and selection badges) and Detach from {owner} action, mirrored in the Command Palette.
    • Added a dismissible Managed by {owner} composer banner on new drafts in owned projects so users can opt out (Start unmanaged) before sending.
    • Kept sidebar layout, nesting, and row badges untouched; updated TimelineWorkEntryRow to label managed-thread notification links Open thread instead of Open subagent, and updated exhaustive notification source switches in client-runtime, web, and mobile.

Screenshots

Step Screenshot
Thread actions Set as owner of… submenu Set as owner of submenu
Searchable project owner picker Searchable project owner picker
New draft composer enrolment banner with opt-out Composer enrolment banner
Managed thread Detach from {owner} menu action Detach from owner
Owner thread automatic enrolment and idle notices Owner thread notices

Hit every surface

  • Contracts and schema boundary (MCP t3_project_update excluded; WS client managedByThreadId stripped)
  • SQLite migration, projection stores, ThreadLaunchService, ProjectOwnerReactor, ManagedThreadAppContext, Orchestrator
  • Client runtime commands, models, owner-menu ordering helper, exhaustive activity switches
  • Web/Desktop thread menus, Command Palette, searchable project owner picker dialog, composer opt-out banner, timeline notification links, i18n catalogs
  • Mobile thread activity switch and automatic server-side enrolment for mobile-launched threads

Verification

  • vp fmt and vp lint across all changed/new files (0 errors)
  • typecheck across @t3tools/contracts, @t3tools/client-runtime, t3, @t3tools/web, @t3tools/desktop, @t3tools/mobile
  • vp run knip:check:files, vp run knip:check:exports, vp run i18n:check, React Compiler coverage
  • Unit and integration tests: ProjectOwnerReactor.test.ts, ProjectStore.test.ts, ProjectCommands.test.ts, ProjectService.test.ts, ProviderTurnControlService.test.ts, ProviderTurnStartService.test.ts, projectOwner.test.ts, threadActionMenu.logic.test.ts, useThreadActionMenu.test.ts, ChatView.browser.test.tsx
  • Real-app Playwright e2e scenario (scripts/scenarios/project-owner-auto-enrolment.e2e.ts) passing against isolated server, SQLite, web app, and dev replay provider

Built with Gemini 4 Neon / Antigravity

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XXL labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant