11import type { ControlPlaneProxyClient } from '@/client-shared/api/proxy.js' ;
22import { ClientSharedSessionActivityService } from '@/client-shared/services/session-activities/index.js' ;
3+ import type { ClientSharedSessionPlan } from '@/client-shared/services/session-activities/index.js' ;
34import { ClientSharedSessionMessageService } from '@/client-shared/services/session-messages/index.js' ;
45import {
56 SessionActivityService ,
@@ -65,6 +66,7 @@ export type ControlPlaneSessionStoreSnapshot = {
6566 cancelling : boolean ;
6667 streamConnected : boolean ;
6768 liveStatus ?: string ;
69+ activePlan ?: ClientSharedSessionPlan ;
6870 latestUpdate ?: ControlPlaneSessionLatestUpdate ;
6971 slashCommandCatalog ?: ControlPlaneSlashCommandCatalog ;
7072 commandResults : ControlPlaneSlashCommandResult [ ] ;
@@ -92,6 +94,8 @@ const INITIAL_SNAPSHOT: ControlPlaneSessionStoreSnapshot = {
9294 * This is the non-React counterpart to web-v2's focused session hooks: it loads
9395 * the selected workspace/session, subscribes to live updates, keeps transient
9496 * conversation messages coherent, and exposes terminal intent methods.
97+ * Shared activity policy stays in client-shared; this store owns only cli-v2
98+ * state mutation and terminal workflow coordination.
9599 */
96100export class ControlPlaneSessionStore {
97101 private readonly api : ControlPlaneSessionApiService ;
@@ -192,6 +196,7 @@ export class ControlPlaneSessionStore {
192196 runtimeContext : undefined ,
193197 pendingApproval : null ,
194198 liveStatus : undefined ,
199+ activePlan : undefined ,
195200 latestUpdate : undefined ,
196201 error : undefined ,
197202 loading : true ,
@@ -243,6 +248,7 @@ export class ControlPlaneSessionStore {
243248 submitting : true ,
244249 running : true ,
245250 error : undefined ,
251+ activePlan : undefined ,
246252 liveStatus : current . streamConnected
247253 ? 'Heddle is working...'
248254 : 'Heddle is working... reconnecting live stream if needed.' ,
@@ -487,6 +493,7 @@ export class ControlPlaneSessionStore {
487493 private async continueSession ( workspaceId : string , sessionId : string ) : Promise < void > {
488494 this . setSnapshot ( {
489495 running : true ,
496+ activePlan : undefined ,
490497 liveStatus : 'Heddle is continuing from the current transcript...' ,
491498 } ) ;
492499 await this . api . continueSession ( workspaceId , sessionId ) ;
@@ -500,6 +507,7 @@ export class ControlPlaneSessionStore {
500507 await this . api . sendPromptAsync ( { workspaceId, sessionId, prompt } ) ;
501508 this . setSnapshot ( {
502509 running : true ,
510+ activePlan : undefined ,
503511 liveStatus : this . snapshotValue . streamConnected
504512 ? 'Heddle is working...'
505513 : 'Heddle is working... reconnecting live stream if needed.' ,
@@ -567,6 +575,12 @@ export class ControlPlaneSessionStore {
567575 onPendingApprovalChanged : ( ) => {
568576 void this . refreshPendingApproval ( event . sessionId ) ;
569577 } ,
578+ onPlanUpdated : ( plan ) => {
579+ this . setSnapshot ( { activePlan : plan } ) ;
580+ } ,
581+ onPlanCleared : ( ) => {
582+ this . setSnapshot ( { activePlan : undefined } ) ;
583+ } ,
570584 onLiveStatus : ( statusActivity , liveStatus ) => {
571585 const latestUpdate = SessionActivityService . resolveLatestUpdate ( statusActivity ) ;
572586 if ( liveStatus === undefined && latestUpdate === undefined ) {
@@ -683,6 +697,7 @@ export class ControlPlaneSessionStore {
683697 this . setSnapshot ( {
684698 submitting : false ,
685699 liveStatus : undefined ,
700+ activePlan : undefined ,
686701 latestUpdate : {
687702 label : 'Run finished' ,
688703 tone : 'success' ,
0 commit comments