- Fix unread indicator to only trigger when Claude finishes responding (using `>\r\n` pattern instead of timer-based detection) - Separate terminal ready detection logic for shell initialization vs Claude interactive session completion - Add terminal-utils.ts with `isTerminalReady()` (shell) and `isClaudeSessionReady()` (Claude interactive) - Update renderer.ts to use `isClaudeSessionReady()` and remove timer-based detection logic
21 lines
884 B
TypeScript
21 lines
884 B
TypeScript
// Terminal escape sequences used for detecting terminal state
|
|
|
|
// Bracketed paste mode enable - indicates terminal is ready for input
|
|
export const BRACKETED_PASTE_MODE_ENABLE = "\x1b[?2004h";
|
|
|
|
// Pattern that indicates Claude interactive session is done and waiting for input
|
|
// Looks for: >\r\n (empty prompt with no space, no suggestion text)
|
|
const CLAUDE_READY_PROMPT_PATTERN = />\r\n/;
|
|
|
|
// Check if a normal shell terminal is ready for input
|
|
// Used during terminal initialization in main.ts
|
|
export function isTerminalReady(buffer: string, startPos: number = 0): boolean {
|
|
return buffer.includes(BRACKETED_PASTE_MODE_ENABLE, startPos);
|
|
}
|
|
|
|
// Check if Claude interactive session is done and ready for input
|
|
// Used for unread indicator detection in renderer.ts
|
|
export function isClaudeSessionReady(buffer: string): boolean {
|
|
return CLAUDE_READY_PROMPT_PATTERN.test(buffer);
|
|
}
|