@@ -279,6 +279,14 @@ export const Toolbar = ({
279279 } ) ;
280280 } ;
281281
282+ const handleCloseOtherFiles = ( fileId : string ) => {
283+ files . forEach ( ( f ) => {
284+ if ( f . id !== fileId && ! pinnedFileIds . includes ( f . id ) ) {
285+ onCloseFile ( f . id ) ;
286+ }
287+ } ) ;
288+ } ;
289+
282290 const handleCloseAllFiles = ( ) => {
283291 files . forEach ( ( f ) => {
284292 if ( ! pinnedFileIds . includes ( f . id ) ) {
@@ -299,6 +307,15 @@ export const Toolbar = ({
299307 }
300308 } ;
301309
310+ const handleCloseOtherTerminals = ( terminalId : string ) => {
311+ for ( let i = terminals . length - 1 ; i >= 0 ; i -= 1 ) {
312+ const t = terminals [ i ] ;
313+ if ( t . id !== terminalId && ! pinnedTerminalIds . includes ( t . id ) ) {
314+ onCloseTerminal ( t . id ) ;
315+ }
316+ }
317+ } ;
318+
302319 const handleCloseAllTerminals = ( ) => {
303320 for ( let i = terminals . length - 1 ; i >= 0 ; i -= 1 ) {
304321 const t = terminals [ i ] ;
@@ -308,6 +325,14 @@ export const Toolbar = ({
308325 }
309326 } ;
310327
328+ const handleCloseOtherAgents = ( agentId : string ) => {
329+ agentSessions . forEach ( ( s ) => {
330+ if ( s . agentId !== agentId && ! pinnedAgentIds . includes ( s . agentId ) ) {
331+ onCloseAgent ( s . agentId ) ;
332+ }
333+ } ) ;
334+ } ;
335+
311336 const handleCloseAllAgents = ( ) => {
312337 agentSessions . forEach ( ( s ) => {
313338 if ( ! pinnedAgentIds . includes ( s . agentId ) ) {
@@ -340,13 +365,21 @@ export const Toolbar = ({
340365 const isPinned = pinnedFileIds . includes ( file . id ) ;
341366 const fileIndexSorted = sortedFiles . findIndex ( ( f ) => f . id === file . id ) ;
342367 const hasRight = fileIndexSorted >= 0 && sortedFiles . length > fileIndexSorted + 1 ;
368+ const hasOtherClosable = files . some ( ( f ) => f . id !== file . id && ! pinnedFileIds . includes ( f . id ) ) ;
343369 return [
344370 [
345371 { key : 'copy-path' , label : 'Copy path' , onClick : ( ) => copyText ( file . id ) } ,
372+ { key : 'copy-name' , label : 'Copy name' , onClick : ( ) => copyText ( file . name ) } ,
346373 { key : 'pin-file' , label : isPinned ? 'Unpin' : 'Pin' , onClick : ( ) => togglePinFile ( file . id ) } ,
347374 ] ,
348375 [
349376 { key : 'close' , label : 'Close' , onClick : ( ) => onCloseFile ( file . id ) } ,
377+ {
378+ key : 'close-others' ,
379+ label : 'Close others' ,
380+ disabled : ! hasOtherClosable ,
381+ onClick : ( ) => handleCloseOtherFiles ( file . id ) ,
382+ } ,
350383 {
351384 key : 'close-right' ,
352385 label : 'Close right' ,
@@ -368,13 +401,22 @@ export const Toolbar = ({
368401 const isPinned = pinnedTerminalIds . includes ( terminal . id ) ;
369402 const terminalIndexSorted = sortedTerminals . findIndex ( ( t ) => t . id === terminal . id ) ;
370403 const hasRight = sortedTerminals . length > terminalIndexSorted + 1 ;
404+ const hasOtherClosable = terminals . some (
405+ ( t ) => t . id !== terminal . id && ! pinnedTerminalIds . includes ( t . id ) ,
406+ ) ;
371407 return [
372408 [
373409 { key : 'copy-terminal-name' , label : 'Copy terminal name' , onClick : ( ) => copyText ( terminal . name ) } ,
374410 { key : 'pin-terminal' , label : isPinned ? 'Unpin' : 'Pin' , onClick : ( ) => togglePinTerminal ( terminal . id ) } ,
375411 ] ,
376412 [
377413 { key : 'close-terminal' , label : 'Close' , onClick : ( ) => onCloseTerminal ( terminal . id ) } ,
414+ {
415+ key : 'close-other-terminals' ,
416+ label : 'Close others' ,
417+ disabled : ! hasOtherClosable ,
418+ onClick : ( ) => handleCloseOtherTerminals ( terminal . id ) ,
419+ } ,
378420 {
379421 key : 'close-right-terminals' ,
380422 label : 'Close right' ,
@@ -393,6 +435,9 @@ export const Toolbar = ({
393435 const agent = agentSessions . find ( ( s ) => s . agentId === tabMenu . targetId ) ;
394436 if ( ! agent ) return [ ] ;
395437 const isPinned = pinnedAgentIds . includes ( agent . agentId ) ;
438+ const hasOtherClosable = agentSessions . some (
439+ ( s ) => s . agentId !== agent . agentId && ! pinnedAgentIds . includes ( s . agentId ) ,
440+ ) ;
396441 return [
397442 [
398443 { key : 'copy-agent-id' , label : 'Copy agent id' , onClick : ( ) => copyText ( agent . agentId ) } ,
@@ -405,6 +450,12 @@ export const Toolbar = ({
405450 ] ,
406451 [
407452 { key : 'close-agent' , label : 'Close' , onClick : ( ) => onCloseAgent ( agent . agentId ) } ,
453+ {
454+ key : 'close-other-agents' ,
455+ label : 'Close others' ,
456+ disabled : ! hasOtherClosable ,
457+ onClick : ( ) => handleCloseOtherAgents ( agent . agentId ) ,
458+ } ,
408459 {
409460 key : 'close-all-agents' ,
410461 label : 'Close all' ,
0 commit comments