(gw: GatewayClient)
| 136 | } |
| 137 | |
| 138 | export function useMainApp(gw: GatewayClient) { |
| 139 | const { exit } = useApp() |
| 140 | const { stdout } = useStdout() |
| 141 | const [cols, setCols] = useState(stdout?.columns ?? 80) |
| 142 | |
| 143 | useEffect(() => { |
| 144 | if (!stdout) { |
| 145 | return |
| 146 | } |
| 147 | |
| 148 | const sync = () => setCols(stdout.columns ?? 80) |
| 149 | |
| 150 | stdout.on('resize', sync) |
| 151 | |
| 152 | if (stdout.isTTY) { |
| 153 | stdout.write(BRACKET_PASTE_ON) |
| 154 | } |
| 155 | |
| 156 | return () => { |
| 157 | stdout.off('resize', sync) |
| 158 | |
| 159 | if (stdout.isTTY) { |
| 160 | stdout.write(BRACKET_PASTE_OFF) |
| 161 | } |
| 162 | } |
| 163 | }, [stdout]) |
| 164 | |
| 165 | const [historyItems, setHistoryItems] = useState<Msg[]>(() => [{ kind: 'intro', role: 'system', text: '' }]) |
| 166 | const [lastUserMsg, setLastUserMsg] = useState('') |
| 167 | const [stickyPrompt, setStickyPrompt] = useState('') |
| 168 | const [catalog, setCatalog] = useState<null | SlashCatalog>(null) |
| 169 | const [voiceEnabled, setVoiceEnabled] = useState(false) |
| 170 | const [voiceTts, setVoiceTts] = useState(false) |
| 171 | const [voiceRecording, setVoiceRecording] = useState(false) |
| 172 | const [voiceProcessing, setVoiceProcessing] = useState(false) |
| 173 | const [voiceRecordKey, setVoiceRecordKey] = useState<ParsedVoiceRecordKey>(DEFAULT_VOICE_RECORD_KEY) |
| 174 | const [sessionStartedAt, setSessionStartedAt] = useState(() => Date.now()) |
| 175 | const [turnStartedAt, setTurnStartedAt] = useState<null | number>(null) |
| 176 | const [lastTurnEndedAt, setLastTurnEndedAt] = useState<null | number>(null) |
| 177 | const [goodVibesTick, setGoodVibesTick] = useState(0) |
| 178 | const [bellOnComplete, setBellOnComplete] = useState(false) |
| 179 | |
| 180 | const ui = useStore($uiState) |
| 181 | const overlay = useStore($overlayState) |
| 182 | |
| 183 | const turnLiveTailActive = useTurnSelector(state => |
| 184 | Boolean( |
| 185 | state.streaming || |
| 186 | state.streamPendingTools.length || |
| 187 | state.streamSegments.length || |
| 188 | state.reasoning.trim() || |
| 189 | state.reasoningActive || |
| 190 | state.tools.length || |
| 191 | state.subagents.length || |
| 192 | state.todos.length |
| 193 | ) |
| 194 | ) |
| 195 |
no test coverage detected