@@ -23,7 +23,10 @@ function requireInteractiveResumeTerminal() {
2323 }
2424}
2525
26- async function fetchResumeSessions ( opts : ResumeCliOptions ) {
26+ async function fetchResumeSessions (
27+ opts : ResumeCliOptions ,
28+ options : { agentId ?: string ; includeGlobal ?: boolean } = { } ,
29+ ) {
2730 const { GatewayChatClient } = await import ( "../tui/gateway-chat.js" ) ;
2831 const client = await GatewayChatClient . connect ( opts ) ;
2932 try {
@@ -42,7 +45,7 @@ async function fetchResumeSessions(opts: ResumeCliOptions) {
4245 finish ( ( ) => reject ( new Error ( reason || "Gateway connection closed" ) ) ) ;
4346 client . start ( ) ;
4447 } ) ;
45- return await loadRecentSessions ( client ) ;
48+ return await loadRecentSessions ( client , options ) ;
4649 } catch ( error ) {
4750 const [ { formatTuiErrorMessage } , { resolveGatewayDisconnectState } ] = await Promise . all ( [
4851 import ( "../tui/tui-formatters.js" ) ,
@@ -115,20 +118,29 @@ function formatResumeCandidate(candidate: SessionPickerChoice): string {
115118 return label === key ? key : `${ label } [${ key } ]` ;
116119}
117120
118- function resolveExplicitGlobalSessionKey ( query : string | undefined ) : string | undefined {
121+ function resolveExplicitGlobalSessionKey (
122+ query : string | undefined ,
123+ ) : { agentId : string ; key : string } | undefined {
119124 const parsed = parseAgentSessionKey ( query ) ;
120- return parsed ?. rest === "global" ? `agent:${ parsed . agentId } :global` : undefined ;
125+ return parsed ?. rest === "global"
126+ ? { agentId : parsed . agentId , key : `agent:${ parsed . agentId } :global` }
127+ : undefined ;
121128}
122129
123130/** Resolve or select one session and run the existing Gateway-backed TUI. */
124131export async function runResumeCommand ( query : string | undefined , opts : ResumeCliOptions ) {
125132 requireInteractiveResumeTerminal ( ) ;
126133 const trimmedQuery = query ?. trim ( ) ;
127- const explicitGlobalSessionKey = resolveExplicitGlobalSessionKey ( trimmedQuery ) ;
128- const sessions = explicitGlobalSessionKey ? [ ] : await fetchResumeSessions ( opts ) ;
134+ const explicitGlobalSession = resolveExplicitGlobalSessionKey ( trimmedQuery ) ;
135+ const sessions = await fetchResumeSessions (
136+ opts ,
137+ explicitGlobalSession
138+ ? { agentId : explicitGlobalSession . agentId , includeGlobal : true }
139+ : undefined ,
140+ ) ;
129141 let sessionKey : string | null ;
130- if ( explicitGlobalSessionKey ) {
131- sessionKey = explicitGlobalSessionKey ;
142+ if ( explicitGlobalSession ) {
143+ sessionKey = explicitGlobalSession . key ;
132144 } else if ( trimmedQuery ) {
133145 const resolution = resolveResumeSession ( sessions , trimmedQuery ) ;
134146 if ( resolution . kind !== "match" ) {
0 commit comments