@@ -33,7 +33,7 @@ import {
3333} from "./components/selectors.js" ;
3434import type { TuiBackend , TuiSessionMutationResult } from "./tui-backend.js" ;
3535import { addBlockedChatSubmitNotice } from "./tui-busy-notice.js" ;
36- import { sanitizeRenderableText } from "./tui-formatters.js" ;
36+ import { formatTuiErrorMessage } from "./tui-formatters.js" ;
3737import {
3838 TUI_RECENT_SESSIONS_ACTIVE_MINUTES ,
3939 TUI_SESSION_PICKER_LIMIT ,
@@ -272,14 +272,14 @@ export function createCommandHandlers(context: CommandHandlerContext) {
272272 applySessionInfoFromPatch ( result ) ;
273273 await refreshSessionInfo ( ) ;
274274 } catch ( err ) {
275- chatLog . addSystem ( `model set failed: ${ String ( err ) } ` ) ;
275+ chatLog . addSystem ( `model set failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
276276 }
277277 } ) ;
278278 } catch ( err ) {
279279 if ( ! isCurrentSessionSelection ( selection ) ) {
280280 return ;
281281 }
282- chatLog . addSystem ( `model list failed: ${ String ( err ) } ` ) ;
282+ chatLog . addSystem ( `model list failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
283283 tui . requestRender ( ) ;
284284 }
285285 } ;
@@ -378,7 +378,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
378378 if ( ! isCurrentSessionSelection ( selection ) ) {
379379 return ;
380380 }
381- chatLog . addSystem ( `sessions list failed: ${ String ( err ) } ` ) ;
381+ chatLog . addSystem ( `sessions list failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
382382 tui . requestRender ( ) ;
383383 }
384384 } ;
@@ -476,7 +476,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
476476 setActivityStatus ( "error" ) ;
477477 }
478478 } catch ( err ) {
479- chatLog . addSystem ( `auth flow failed: ${ sanitizeRenderableText ( String ( err ) ) } ` ) ;
479+ chatLog . addSystem ( `auth flow failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
480480 setActivityStatus ( "error" ) ;
481481 }
482482 break ;
@@ -497,7 +497,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
497497 }
498498 chatLog . addSystem ( "status: unknown response" ) ;
499499 } catch ( err ) {
500- chatLog . addSystem ( `status failed: ${ String ( err ) } ` ) ;
500+ chatLog . addSystem ( `status failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
501501 }
502502 break ;
503503 case "agent" :
@@ -534,7 +534,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
534534 await sendMessage ( continuation ) ;
535535 }
536536 } catch ( err ) {
537- chatLog . addSystem ( `goal failed: ${ sanitizeRenderableText ( String ( err ) ) } ` ) ;
537+ chatLog . addSystem ( `goal failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
538538 }
539539 } else {
540540 await sendMessage ( raw ) ;
@@ -591,7 +591,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
591591 applySessionInfoFromPatch ( result ) ;
592592 await refreshSessionInfo ( ) ;
593593 } catch ( err ) {
594- chatLog . addSystem ( `model set failed: ${ String ( err ) } ` ) ;
594+ chatLog . addSystem ( `model set failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
595595 }
596596 }
597597 break ;
@@ -621,7 +621,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
621621 applySessionInfoFromPatch ( result ) ;
622622 await refreshSessionInfo ( ) ;
623623 } catch ( err ) {
624- chatLog . addSystem ( `think failed: ${ String ( err ) } ` ) ;
624+ chatLog . addSystem ( `think failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
625625 }
626626 break ;
627627 case "verbose" :
@@ -643,7 +643,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
643643 await loadHistory ( ) ;
644644 }
645645 } catch ( err ) {
646- chatLog . addSystem ( `verbose failed: ${ String ( err ) } ` ) ;
646+ chatLog . addSystem ( `verbose failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
647647 }
648648 break ;
649649 case "trace" :
@@ -660,7 +660,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
660660 applySessionInfoFromPatch ( result ) ;
661661 await refreshSessionInfo ( ) ;
662662 } catch ( err ) {
663- chatLog . addSystem ( `trace failed: ${ String ( err ) } ` ) ;
663+ chatLog . addSystem ( `trace failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
664664 }
665665 break ;
666666 case "fast" :
@@ -683,7 +683,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
683683 applySessionInfoFromPatch ( result ) ;
684684 await refreshSessionInfo ( ) ;
685685 } catch ( err ) {
686- chatLog . addSystem ( `fast failed: ${ String ( err ) } ` ) ;
686+ chatLog . addSystem ( `fast failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
687687 }
688688 break ;
689689 case "reasoning" :
@@ -700,7 +700,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
700700 applySessionInfoFromPatch ( result ) ;
701701 await refreshSessionInfo ( ) ;
702702 } catch ( err ) {
703- chatLog . addSystem ( `reasoning failed: ${ String ( err ) } ` ) ;
703+ chatLog . addSystem ( `reasoning failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
704704 }
705705 break ;
706706 case "usage" : {
@@ -722,7 +722,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
722722 delete state . sessionInfo . effectiveResponseUsage ;
723723 await refreshSessionInfo ( ) ;
724724 } catch ( err ) {
725- chatLog . addSystem ( `usage failed: ${ String ( err ) } ` ) ;
725+ chatLog . addSystem ( `usage failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
726726 }
727727 break ;
728728 }
@@ -740,7 +740,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
740740 applySessionInfoFromPatch ( result ) ;
741741 await refreshSessionInfo ( ) ;
742742 } catch ( err ) {
743- chatLog . addSystem ( `usage failed: ${ String ( err ) } ` ) ;
743+ chatLog . addSystem ( `usage failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
744744 }
745745 break ;
746746 }
@@ -762,7 +762,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
762762 applySessionInfoFromPatch ( result ) ;
763763 await refreshSessionInfo ( ) ;
764764 } catch ( err ) {
765- chatLog . addSystem ( `elevated failed: ${ String ( err ) } ` ) ;
765+ chatLog . addSystem ( `elevated failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
766766 }
767767 break ;
768768 case "activation" : {
@@ -784,7 +784,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
784784 applySessionInfoFromPatch ( result ) ;
785785 await refreshSessionInfo ( ) ;
786786 } catch ( err ) {
787- chatLog . addSystem ( `activation failed: ${ String ( err ) } ` ) ;
787+ chatLog . addSystem ( `activation failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
788788 }
789789 break ;
790790 }
@@ -814,7 +814,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
814814 await setSession ( result . key ) ;
815815 chatLog . addSystem ( `new session: ${ result . key } ` ) ;
816816 } catch ( err ) {
817- chatLog . addSystem ( `new session failed: ${ sanitizeRenderableText ( String ( err ) ) } ` ) ;
817+ chatLog . addSystem ( `new session failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
818818 } finally {
819819 sessionCreationInFlight = false ;
820820 }
@@ -856,7 +856,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
856856 if ( ! isCurrentSessionSelection ( resetResultSelection ) ) {
857857 return ;
858858 }
859- chatLog . addSystem ( `reset failed: ${ sanitizeRenderableText ( String ( err ) ) } ` ) ;
859+ chatLog . addSystem ( `reset failed: ${ formatTuiErrorMessage ( err ) } ` ) ;
860860 }
861861 break ;
862862 }
@@ -1029,7 +1029,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
10291029 clearPendingSubmit ( state , runId ) ;
10301030 chatLog . dropPendingUser ( runId ) ;
10311031 }
1032- chatLog . addSystem ( `${ isBtw ? "btw failed" : "send failed" } : ${ String ( err ) } ` ) ;
1032+ chatLog . addSystem ( `${ isBtw ? "btw failed" : "send failed" } : ${ formatTuiErrorMessage ( err ) } ` ) ;
10331033 if ( ! isBtw ) {
10341034 setActivityStatus ( "error" ) ;
10351035 }
0 commit comments