MCPcopy Create free account
hub / github.com/GCWing/BitFun / apply_exit_reason

Method apply_exit_reason

src/apps/cli/src/modes/chat.rs:1370–1411  ·  view source on GitHub ↗

Apply an exit reason from handle_key_event (shared by normal and batch paths).

(
        reason: ChatExitReason,
        this: &mut Self,
        chat_view: &mut ChatView,
        chat_state: &mut ChatState,
        session_id: &mut String,
        rt_handle: &tokio::runtime::Ha

Source from the content-addressed store, hash-verified

1368
1369 /// Apply an exit reason from handle_key_event (shared by normal and batch paths).
1370 fn apply_exit_reason(
1371 reason: ChatExitReason,
1372 this: &mut Self,
1373 chat_view: &mut ChatView,
1374 chat_state: &mut ChatState,
1375 session_id: &mut String,
1376 rt_handle: &tokio::runtime::Handle,
1377 should_quit: &mut bool,
1378 exit_reason: &mut ChatExitReason,
1379 ) {
1380 match reason {
1381 ChatExitReason::SwitchSession(new_session_id) => {
1382 match this.switch_to_session(
1383 &new_session_id,
1384 session_id,
1385 chat_state,
1386 chat_view,
1387 rt_handle,
1388 ) {
1389 Ok(()) => tracing::info!("Switched to session: {}", new_session_id),
1390 Err(e) => {
1391 chat_state.add_system_message(format!("Failed to switch session: {}", e));
1392 tracing::error!("Failed to switch session: {}", e);
1393 }
1394 }
1395 }
1396 ChatExitReason::NewSession => {
1397 match this.create_new_session(session_id, chat_state, chat_view, rt_handle) {
1398 Ok(()) => tracing::info!("Created new session: {}", session_id),
1399 Err(e) => {
1400 chat_state
1401 .add_system_message(format!("Failed to create new session: {}", e));
1402 tracing::error!("Failed to create new session: {}", e);
1403 }
1404 }
1405 }
1406 other => {
1407 *should_quit = true;
1408 *exit_reason = other;
1409 }
1410 }
1411 }
1412
1413 /// Handle non-key events (Mouse, Paste, Resize, etc.).
1414 fn handle_non_key_event(

Callers

nothing calls this directly

Calls 3

switch_to_sessionMethod · 0.80
add_system_messageMethod · 0.80
create_new_sessionMethod · 0.45

Tested by

no test coverage detected