@@ -174,7 +174,14 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
174174 } = input ;
175175 const navigate = useNavigate ( ) ;
176176 const router = useRouter ( ) ;
177- const { settleThread, pinThread, confirmAndUnpinThread } = useThreadActions ( ) ;
177+ const {
178+ settleThread,
179+ pinThread,
180+ confirmAndUnpinThread,
181+ confirmAndArchiveThread,
182+ confirmAndDeleteThread,
183+ } = useThreadActions ( ) ;
184+ const destructiveShortcutPending = useRef ( false ) ;
178185 const canWriteSourceControl = useEnvironmentScope ( environmentId , AuthSourceControlWriteScope ) ;
179186 const switchGitRef = useAtomCommand ( vcsEnvironment . switchRef , { reportFailure : false } ) ;
180187 const updateThreadMetadata = useOrchestrationCommand ( threadEnvironment . updateMetadata , {
@@ -648,6 +655,41 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
648655 ) ;
649656 } ;
650657 const shortcuts = {
658+ "thread.archive" : ( { event } ) => {
659+ if ( ! readEnvironmentScope ( environmentId , AuthOrchestrationOperateScope ) ) return false ;
660+ if ( ! activeThreadShell || ! activeThreadRef || ! serverConfigLoaded ) return ;
661+ if ( event . repeat || destructiveShortcutPending . current ) return ;
662+ destructiveShortcutPending . current = true ;
663+ let didArchive = false ;
664+ void confirmAndArchiveThread ( activeThreadRef , {
665+ onArchived : ( ) => {
666+ didArchive = true ;
667+ } ,
668+ } )
669+ . then ( ( result ) =>
670+ toastThreadActionFailure (
671+ didArchive ? "Thread archived, but navigation failed" : "Failed to archive thread" ,
672+ ) ( result ) ,
673+ )
674+ . finally ( ( ) => {
675+ destructiveShortcutPending . current = false ;
676+ } ) ;
677+ } ,
678+ "thread.delete" : ( { event } ) => {
679+ if ( ! readEnvironmentScope ( environmentId , AuthOrchestrationOperateScope ) ) return false ;
680+ if ( ! activeThreadShell || ! activeThreadRef || ! serverConfigLoaded ) return ;
681+ if ( event . repeat || destructiveShortcutPending . current ) return ;
682+ destructiveShortcutPending . current = true ;
683+ const target = activeThreadRef ;
684+ void confirmAndDeleteThread ( target )
685+ . then ( ( result ) => {
686+ if ( readThreadShell ( target ) !== null )
687+ toastThreadActionFailure ( "Failed to delete thread" ) ( result ) ;
688+ } )
689+ . finally ( ( ) => {
690+ destructiveShortcutPending . current = false ;
691+ } ) ;
692+ } ,
651693 "thread.settle" : ( ) => {
652694 if ( ! readEnvironmentScope ( environmentId , AuthOrchestrationOperateScope ) ) return false ;
653695 if ( ! activeThreadShell || ! activeThreadRef || ! serverConfigLoaded ) return ;
0 commit comments