Skip to content

Commit f34ea5f

Browse files
Tommy Tongttommyth
authored andcommitted
feat: enhance
1 parent 531d973 commit f34ea5f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/cmd-intensive-chat-ui.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ const updateHeartbeat = async () => {
5959
if (!options.outputDir) return;
6060

6161
const heartbeatPath = path.join(options.outputDir, 'heartbeat.txt');
62-
await fs.writeFile(heartbeatPath, Date.now().toString(), 'utf8');
62+
try {
63+
const dir = path.dirname(heartbeatPath);
64+
await fs.mkdir(dir, { recursive: true }); // Ensure directory exists
65+
await fs.writeFile(heartbeatPath, Date.now().toString(), 'utf8');
66+
} catch (writeError) {
67+
// Log the specific error but allow the poll cycle to continue
68+
console.error(`Failed to write heartbeat file ${heartbeatPath}:`, writeError);
69+
}
6370
};
6471

6572
// Register process termination handlers

src/cmd-intensive-chat.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,16 @@ export async function isSessionActive(sessionId: string): Promise<boolean> {
301301
}
302302

303303
return true;
304-
} catch (e) {
305-
// Error accessing heartbeat file, session is likely dead
304+
} catch (e: any) { // Added ': any' to access e.code safely
305+
// If error is ENOENT (file not found), assume session is still starting
306+
if (e.code === 'ENOENT') {
307+
// Optional: Could add a check here to see if the session is very new
308+
// e.g., if (Date.now() - session.startTime < 2000) return true;
309+
// For now, let's assume ENOENT means it's possibly still starting.
310+
return true;
311+
}
312+
// For any other error, session is likely dead
313+
console.error(`Error checking heartbeat for session ${sessionId}:`, e); // Log other errors
306314
session.isActive = false;
307315
return false;
308316
}

src/components/InteractiveInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const InteractiveInput: FC<InteractiveInputProps> = ({ question, question
9999

100100
{predefinedOptions && predefinedOptions.length > 0 && (
101101
<Box flexDirection="column" marginBottom={1}>
102-
<Text>Use ↑/↓ to select options, type any key for custom input, Enter to submit</Text>
102+
<Text dimColor={true}>Use ↑/↓ to select options, Enter to submit</Text>
103103
{predefinedOptions.map((opt, i) => (
104104
<Text key={i} color={i === selectedIndex ? (mode === "option" ? 'greenBright' : 'green') : undefined}>
105105
{i === selectedIndex ? (mode === "option" ? '› ' : ' ') : ' '}{opt}

0 commit comments

Comments
 (0)