mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor(ui): extract switch controls logic into reusable hook and terminal restoration utility
Extracts duplicated exit/switch confirmation handling from CodexDisplay and RemoteModeDisplay into a custom useSwitchControls hook. Centralizes terminal state restoration (raw mode, keyboard protocol cleanup) into a restoreTerminalState utility function used across codex modules. Improves code reusability and maintainability.
This commit is contained in:
@@ -4,6 +4,7 @@ import { resolve } from 'node:path';
|
||||
|
||||
import { ApiClient } from '@/api/api';
|
||||
import { logger } from '@/ui/logger';
|
||||
import { restoreTerminalState } from '@/ui/terminalState';
|
||||
import { loop, type EnhancedMode, type PermissionMode } from './loop';
|
||||
import { MessageQueue2 } from '@/utils/MessageQueue2';
|
||||
import { hashObject } from '@/utils/deterministicJson';
|
||||
@@ -136,6 +137,7 @@ export async function runCodex(opts: {
|
||||
}
|
||||
cleanupStarted = true;
|
||||
logger.debug('[codex] Cleanup start');
|
||||
restoreTerminalState();
|
||||
try {
|
||||
if (sessionWrapper) {
|
||||
sessionWrapper.stopKeepAlive();
|
||||
|
||||
Reference in New Issue
Block a user