@@ -66,6 +66,28 @@ const AGENT_LABELS: Record<AgentType | 'all', string> = {
6666
6767type DateGroup = 'Today' | 'Yesterday' | 'This Week' | 'Older'
6868
69+ function getAgentResumeCommand ( agentType : AgentType , sessionId : string ) : string {
70+ switch ( agentType ) {
71+ case 'claude-code' :
72+ return `claude --resume ${ sessionId } `
73+ case 'opencode' :
74+ return `opencode --session ${ sessionId } `
75+ case 'codex' :
76+ return `codex resume ${ sessionId } `
77+ }
78+ }
79+
80+ function getAgentNewCommand ( agentType : AgentType ) : string {
81+ switch ( agentType ) {
82+ case 'claude-code' :
83+ return 'claude'
84+ case 'opencode' :
85+ return 'opencode'
86+ case 'codex' :
87+ return 'codex'
88+ }
89+ }
90+
6991function getDateGroup ( dateString : string ) : DateGroup {
7092 const date = new Date ( dateString )
7193 const now = new Date ( )
@@ -355,14 +377,11 @@ export function WorkspaceDetail() {
355377
356378 const terminalMode : TerminalMode | null = useMemo ( ( ) => {
357379 if ( ! sessionParam && ! agentParam ) return null
358- if ( agentParam === 'codex' ) {
359- return { type : 'terminal' , command : sessionParam ? `codex resume ${ sessionParam } ` : 'codex' , runId : runIdParam ?? undefined }
360- }
361380 if ( agentParam && sessionParam ) {
362- return { type : 'terminal' , command : ` ${ agentParam } resume ${ sessionParam } ` }
381+ return { type : 'terminal' , command : getAgentResumeCommand ( agentParam as AgentType , sessionParam ) }
363382 }
364383 if ( agentParam ) {
365- return { type : 'terminal' , command : agentParam , runId : runIdParam ?? undefined }
384+ return { type : 'terminal' , command : getAgentNewCommand ( agentParam as AgentType ) , runId : runIdParam ?? undefined }
366385 }
367386 return null
368387 } , [ sessionParam , agentParam , runIdParam ] )
@@ -381,13 +400,25 @@ export function WorkspaceDetail() {
381400
382401 setSearchParams ( ( prev ) => {
383402 const next = new URLSearchParams ( prev )
384- const resumeMatch = mode . command . match ( / ^ ( \S + ) \s + r e s u m e \s + ( \S + ) / )
385- if ( resumeMatch ) {
386- next . set ( 'agent' , resumeMatch [ 1 ] )
387- next . set ( 'session' , resumeMatch [ 2 ] )
403+ const claudeMatch = mode . command . match ( / ^ c l a u d e \s + - - r e s u m e \s + ( \S + ) / )
404+ const opencodeMatch = mode . command . match ( / ^ o p e n c o d e \s + - - s e s s i o n \s + ( \S + ) / )
405+ const codexMatch = mode . command . match ( / ^ c o d e x \s + r e s u m e \s + ( \S + ) / )
406+ if ( claudeMatch ) {
407+ next . set ( 'agent' , 'claude-code' )
408+ next . set ( 'session' , claudeMatch [ 1 ] )
409+ next . delete ( 'runId' )
410+ } else if ( opencodeMatch ) {
411+ next . set ( 'agent' , 'opencode' )
412+ next . set ( 'session' , opencodeMatch [ 1 ] )
413+ next . delete ( 'runId' )
414+ } else if ( codexMatch ) {
415+ next . set ( 'agent' , 'codex' )
416+ next . set ( 'session' , codexMatch [ 1 ] )
388417 next . delete ( 'runId' )
389418 } else {
390- next . set ( 'agent' , mode . command )
419+ const agentMap : Record < string , AgentType > = { claude : 'claude-code' , opencode : 'opencode' , codex : 'codex' }
420+ const agent = agentMap [ mode . command ] || mode . command
421+ next . set ( 'agent' , agent )
391422 next . delete ( 'session' )
392423 if ( mode . runId ) {
393424 next . set ( 'runId' , mode . runId )
@@ -535,7 +566,7 @@ export function WorkspaceDetail() {
535566
536567 const handleResume = ( session : SessionInfo ) => {
537568 const resumeId = session . agentSessionId || session . id
538- setTerminalMode ( { type : 'terminal' , command : ` ${ session . agentType } resume ${ resumeId } ` } )
569+ setTerminalMode ( { type : 'terminal' , command : getAgentResumeCommand ( session . agentType , resumeId ) } )
539570 if ( name ) {
540571 api . recordSessionAccess ( name , session . id , session . agentType ) . catch ( ( ) => { } )
541572 queryClient . invalidateQueries ( { queryKey : [ 'sessions' , name ] } )
@@ -544,7 +575,7 @@ export function WorkspaceDetail() {
544575
545576 const handleNewSession = ( agentType : AgentType = 'claude-code' ) => {
546577 const sessionId = `${ agentType } -${ Date . now ( ) } `
547- setTerminalMode ( { type : 'terminal' , command : agentType , runId : sessionId } )
578+ setTerminalMode ( { type : 'terminal' , command : getAgentNewCommand ( agentType ) , runId : sessionId } )
548579 }
549580
550581 if ( isLoading ) {
0 commit comments