@@ -76,7 +76,7 @@ export function Autocomplete(props: {
7676} ) {
7777 const sdk = useSDK ( )
7878 const sync = useSync ( )
79- const command = useCommandDialog ( )
79+ const dialog = useCommandDialog ( )
8080 const { theme } = useTheme ( )
8181 const dimensions = useTerminalDimensions ( )
8282 const frecency = useFrecency ( )
@@ -317,81 +317,88 @@ export function Autocomplete(props: {
317317 const results : AutocompleteOption [ ] = [ ]
318318 const s = session ( )
319319 for ( const command of sync . data . command ) {
320- results . push ( {
321- display : "/" + command . name + ( command . mcp ? " (MCP)" : "" ) ,
322- description : command . description ,
323- onSelect : ( ) => {
324- const newText = "/" + command . name + " "
325- const cursor = props . input ( ) . logicalCursor
326- props . input ( ) . deleteRange ( 0 , 0 , cursor . row , cursor . col )
327- props . input ( ) . insertText ( newText )
328- props . input ( ) . cursorOffset = Bun . stringWidth ( newText )
329- } ,
330- } )
320+ if ( command . compact && s ) {
321+ results . push ( {
322+ display : "/" + command . name + ( command . mcp ? " (MCP)" : "" ) ,
323+ description : command . description ?? "compact the session" ,
324+ onSelect : ( ) => {
325+ dialog . trigger ( "session.compact" , "prompt" , {
326+ commandName : command . name ,
327+ template : command . template ,
328+ } )
329+ } ,
330+ } )
331+ } else if ( ! command . compact ) {
332+ results . push ( {
333+ display : "/" + command . name + ( command . mcp ? " (MCP)" : "" ) ,
334+ description : command . description ,
335+ onSelect : ( ) => {
336+ const newText = "/" + command . name + " "
337+ const cursor = props . input ( ) . logicalCursor
338+ props . input ( ) . deleteRange ( 0 , 0 , cursor . row , cursor . col )
339+ props . input ( ) . insertText ( newText )
340+ props . input ( ) . cursorOffset = Bun . stringWidth ( newText )
341+ } ,
342+ } )
343+ }
331344 }
332345 if ( s ) {
333346 results . push (
334347 {
335348 display : "/undo" ,
336349 description : "undo the last message" ,
337350 onSelect : ( ) => {
338- command . trigger ( "session.undo" )
351+ dialog . trigger ( "session.undo" )
339352 } ,
340353 } ,
341354 {
342355 display : "/redo" ,
343356 description : "redo the last message" ,
344- onSelect : ( ) => command . trigger ( "session.redo" ) ,
345- } ,
346- {
347- display : "/compact" ,
348- aliases : [ "/summarize" ] ,
349- description : "compact the session" ,
350- onSelect : ( ) => command . trigger ( "session.compact" ) ,
357+ onSelect : ( ) => dialog . trigger ( "session.redo" ) ,
351358 } ,
352359 {
353360 display : "/unshare" ,
354361 disabled : ! s . share ,
355362 description : "unshare a session" ,
356- onSelect : ( ) => command . trigger ( "session.unshare" ) ,
363+ onSelect : ( ) => dialog . trigger ( "session.unshare" ) ,
357364 } ,
358365 {
359366 display : "/rename" ,
360367 description : "rename session" ,
361- onSelect : ( ) => command . trigger ( "session.rename" ) ,
368+ onSelect : ( ) => dialog . trigger ( "session.rename" ) ,
362369 } ,
363370 {
364371 display : "/copy" ,
365372 description : "copy session transcript to clipboard" ,
366- onSelect : ( ) => command . trigger ( "session.copy" ) ,
373+ onSelect : ( ) => dialog . trigger ( "session.copy" ) ,
367374 } ,
368375 {
369376 display : "/export" ,
370377 description : "export session transcript to file" ,
371- onSelect : ( ) => command . trigger ( "session.export" ) ,
378+ onSelect : ( ) => dialog . trigger ( "session.export" ) ,
372379 } ,
373380 {
374381 display : "/timeline" ,
375382 description : "jump to message" ,
376- onSelect : ( ) => command . trigger ( "session.timeline" ) ,
383+ onSelect : ( ) => dialog . trigger ( "session.timeline" ) ,
377384 } ,
378385 {
379386 display : "/fork" ,
380387 description : "fork from message" ,
381- onSelect : ( ) => command . trigger ( "session.fork" ) ,
388+ onSelect : ( ) => dialog . trigger ( "session.fork" ) ,
382389 } ,
383390 {
384391 display : "/thinking" ,
385392 description : "toggle thinking visibility" ,
386- onSelect : ( ) => command . trigger ( "session.toggle.thinking" ) ,
393+ onSelect : ( ) => dialog . trigger ( "session.toggle.thinking" ) ,
387394 } ,
388395 )
389396 if ( sync . data . config . share !== "disabled" ) {
390397 results . push ( {
391398 display : "/share" ,
392399 disabled : ! ! s . share ?. url ,
393400 description : "share a session" ,
394- onSelect : ( ) => command . trigger ( "session.share" ) ,
401+ onSelect : ( ) => dialog . trigger ( "session.share" ) ,
395402 } )
396403 }
397404 }
@@ -401,64 +408,64 @@ export function Autocomplete(props: {
401408 display : "/new" ,
402409 aliases : [ "/clear" ] ,
403410 description : "create a new session" ,
404- onSelect : ( ) => command . trigger ( "session.new" ) ,
411+ onSelect : ( ) => dialog . trigger ( "session.new" ) ,
405412 } ,
406413 {
407414 display : "/models" ,
408415 description : "list models" ,
409- onSelect : ( ) => command . trigger ( "model.list" ) ,
416+ onSelect : ( ) => dialog . trigger ( "model.list" ) ,
410417 } ,
411418 {
412419 display : "/agents" ,
413420 description : "list agents" ,
414- onSelect : ( ) => command . trigger ( "agent.list" ) ,
421+ onSelect : ( ) => dialog . trigger ( "agent.list" ) ,
415422 } ,
416423 {
417424 display : "/session" ,
418425 aliases : [ "/resume" , "/continue" ] ,
419426 description : "list sessions" ,
420- onSelect : ( ) => command . trigger ( "session.list" ) ,
427+ onSelect : ( ) => dialog . trigger ( "session.list" ) ,
421428 } ,
422429 {
423430 display : "/status" ,
424431 description : "show status" ,
425- onSelect : ( ) => command . trigger ( "opencode.status" ) ,
432+ onSelect : ( ) => dialog . trigger ( "opencode.status" ) ,
426433 } ,
427434 {
428435 display : "/mcp" ,
429436 description : "toggle MCPs" ,
430- onSelect : ( ) => command . trigger ( "mcp.list" ) ,
437+ onSelect : ( ) => dialog . trigger ( "mcp.list" ) ,
431438 } ,
432439 {
433440 display : "/theme" ,
434441 description : "toggle theme" ,
435- onSelect : ( ) => command . trigger ( "theme.switch" ) ,
442+ onSelect : ( ) => dialog . trigger ( "theme.switch" ) ,
436443 } ,
437444 {
438445 display : "/editor" ,
439446 description : "open editor" ,
440- onSelect : ( ) => command . trigger ( "prompt.editor" , "prompt" ) ,
447+ onSelect : ( ) => dialog . trigger ( "prompt.editor" , "prompt" ) ,
441448 } ,
442449 {
443450 display : "/connect" ,
444451 description : "connect to a provider" ,
445- onSelect : ( ) => command . trigger ( "provider.connect" ) ,
452+ onSelect : ( ) => dialog . trigger ( "provider.connect" ) ,
446453 } ,
447454 {
448455 display : "/help" ,
449456 description : "show help" ,
450- onSelect : ( ) => command . trigger ( "help.show" ) ,
457+ onSelect : ( ) => dialog . trigger ( "help.show" ) ,
451458 } ,
452459 {
453460 display : "/commands" ,
454461 description : "show all commands" ,
455- onSelect : ( ) => command . show ( ) ,
462+ onSelect : ( ) => dialog . show ( ) ,
456463 } ,
457464 {
458465 display : "/exit" ,
459466 aliases : [ "/quit" , "/q" ] ,
460467 description : "exit the app" ,
461- onSelect : ( ) => command . trigger ( "app.exit" ) ,
468+ onSelect : ( ) => dialog . trigger ( "app.exit" ) ,
462469 } ,
463470 )
464471 const max = firstBy ( results , [ ( x ) => x . display . length , "desc" ] ) ?. display . length
@@ -564,7 +571,7 @@ export function Autocomplete(props: {
564571 }
565572
566573 function show ( mode : "@" | "/" ) {
567- command . keybinds ( false )
574+ dialog . keybinds ( false )
568575 setStore ( {
569576 visible : mode ,
570577 index : props . input ( ) . cursorOffset ,
@@ -581,7 +588,7 @@ export function Autocomplete(props: {
581588 draft . input = props . input ( ) . plainText
582589 } )
583590 }
584- command . keybinds ( true )
591+ dialog . keybinds ( true )
585592 setStore ( "visible" , false )
586593 }
587594
0 commit comments