@@ -20,6 +20,7 @@ const CustomHeadersScreen = React.lazy(
2020 ( ) => import ( './ui/pages/CustomHeadersScreen.js' ) ,
2121) ;
2222const HelpScreen = React . lazy ( ( ) => import ( './ui/pages/HelpScreen.js' ) ) ;
23+ const ExitScreen = React . lazy ( ( ) => import ( './ui/pages/ExitScreen.js' ) ) ;
2324
2425import {
2526 useGlobalExit ,
@@ -45,7 +46,9 @@ type Props = {
4546
4647// ShowTaskListWrapper: Handles task list mode with session conversion support
4748function ShowTaskListWrapper ( ) {
48- const [ currentView , setCurrentView ] = useState < 'tasks' | 'chat' > ( 'tasks' ) ;
49+ const [ currentView , setCurrentView ] = useState < 'tasks' | 'chat' | 'exit' > (
50+ 'tasks' ,
51+ ) ;
4952 const [ chatScreenKey , setChatScreenKey ] = useState ( 0 ) ;
5053 const [ exitNotification , setExitNotification ] =
5154 useState < ExitNotificationType > ( {
@@ -61,7 +64,29 @@ function ShowTaskListWrapper() {
6164 // Global exit handler
6265 useGlobalExit ( setExitNotification ) ;
6366
67+ // Listen for navigation events (including exit)
68+ useEffect ( ( ) => {
69+ const unsubscribe = onNavigate ( event => {
70+ if (
71+ event . destination === 'exit' ||
72+ event . destination === 'tasks' ||
73+ event . destination === 'chat'
74+ ) {
75+ setCurrentView ( event . destination ) ;
76+ }
77+ } ) ;
78+ return unsubscribe ;
79+ } , [ ] ) ;
80+
6481 const renderView = ( ) => {
82+ if ( currentView === 'exit' ) {
83+ return (
84+ < Suspense fallback = { loadingFallback } >
85+ < ExitScreen />
86+ </ Suspense >
87+ ) ;
88+ }
89+
6590 if ( currentView === 'chat' ) {
6691 return (
6792 < Suspense fallback = { loadingFallback } >
@@ -92,7 +117,7 @@ function ShowTaskListWrapper() {
92117 return (
93118 < Box flexDirection = "column" width = { terminalWidth } >
94119 { renderView ( ) }
95- { exitNotification . show && (
120+ { exitNotification . show && currentView !== 'exit' && (
96121 < Box paddingX = { 1 } flexShrink = { 0 } >
97122 < Alert variant = "warning" > { exitNotification . message } </ Alert >
98123 </ Box >
@@ -123,6 +148,7 @@ function AppContent({
123148 | 'systemprompt'
124149 | 'customheaders'
125150 | 'tasks'
151+ | 'exit'
126152 > ( skipWelcome ? 'chat' : 'welcome' ) ;
127153
128154 // Add a key to force remount ChatScreen when returning from welcome screen
@@ -190,7 +216,7 @@ function AppContent({
190216 // Both 'chat' and 'resume-last' go to chat view
191217 setCurrentView ( value === 'resume-last' ? 'chat' : value ) ;
192218 } else if ( value === 'exit' ) {
193- gracefulExit ( ) ;
219+ setCurrentView ( 'exit' ) ;
194220 }
195221 } ;
196222
@@ -263,6 +289,12 @@ function AppContent({
263289 />
264290 </ Suspense >
265291 ) ;
292+ case 'exit' :
293+ return (
294+ < Suspense fallback = { loadingFallback } >
295+ < ExitScreen version = { version } />
296+ </ Suspense >
297+ ) ;
266298 default :
267299 return (
268300 < Suspense fallback = { loadingFallback } >
@@ -280,7 +312,7 @@ function AppContent({
280312 return (
281313 < Box flexDirection = "column" width = { terminalWidth } >
282314 { renderView ( ) }
283- { exitNotification . show && (
315+ { exitNotification . show && currentView !== 'exit' && (
284316 < Box paddingX = { 1 } flexShrink = { 0 } >
285317 < Alert variant = "warning" > { exitNotification . message } </ Alert >
286318 </ Box >
0 commit comments