diff --git a/web/CLAUDE.md b/web/CLAUDE.md index 1b4a99b4..aa092351 100644 --- a/web/CLAUDE.md +++ b/web/CLAUDE.md @@ -1,8 +1,5 @@ # Claude Development Notes -**IMPORTANT**: BEFORE YOU DO ANYTHING, READ spec.md IN FULL USING THE READ TOOL! -**IMPORTANT**: NEVER USE GREP. ALWAYS USE RIPGREP! - ## Updating spec.md As code changes, the spec.md might get outdated. If you detect outdated information, ask the user if they want to regenerate the spec.md file. @@ -15,6 +12,8 @@ As code changes, the spec.md might get outdated. If you detect outdated informat - API endpoints and protocols - Binary buffer format and WebSocket implementation - HQ mode and distributed architecture + - Activity tracking + - Anything else not covered above 3. Focus on capturing: - File locations with key line numbers for important functions - Component responsibilities and data flow @@ -26,7 +25,7 @@ As code changes, the spec.md might get outdated. If you detect outdated informat ## Build Process - **Never run build commands** - the user has `npm run dev` running which handles automatic rebuilds - Changes to TypeScript files are automatically compiled and watched -- Do not run `npm run build:client` or similar build commands +- Do not run `npm run build` or similar build commands ## Development Workflow - Make changes to source files in `src/` @@ -38,8 +37,19 @@ As code changes, the spec.md might get outdated. If you detect outdated informat - Always fix all linting and type checking errors, including in unrelated code - Never run the tests, unless explicitely asked to. `npm run test` -**CRITICAL** -- **NEVER EVER USE SETTIMEOUT FOR ANYTHING IN THE FRONTEND UNLESS EXPLICITLY PERMITTED** +## Code References +**THIS IS OF UTTER IMPORTANCE THE USERS HAPPINESS DEPENDS ON IT!** +When referencing code locations, you MUST use clickable format that VS Code recognizes: +- `path/to/file.ts:123` format (file:line) +- `path/to/file.ts:123-456` (ranges) +- Always use relative paths from the project root +- Examples: + - `src/server/fwd.ts:92` - single line reference + - `src/server/pty/pty-manager.ts:274-280` - line range + - `web/src/client/app.ts:15` - when in parent directory -## Server Execution -- NEVER RUN THE SERVER YOURSELF, I ALWAYS RUN IT ON THE SIDE VIA NPM RUN DEV! \ No newline at end of file +NEVER give a code reference or location in any other format. + +## CRITICAL +**IMPORTANT**: BEFORE YOU DO ANYTHING, READ spec.md IN FULL USING THE READ TOOL! +**IMPORTANT**: NEVER USE GREP. ALWAYS USE RIPGREP! \ No newline at end of file diff --git a/web/src/server/pty/asciinema-writer.ts b/web/src/server/pty/asciinema-writer.ts index 953ab4d8..904e85ea 100644 --- a/web/src/server/pty/asciinema-writer.ts +++ b/web/src/server/pty/asciinema-writer.ts @@ -8,6 +8,9 @@ import * as fs from 'fs'; import * as path from 'path'; import { AsciinemaHeader, AsciinemaEvent, PtyError } from './types.js'; +import { createLogger } from '../utils/logger.js'; + +const logger = createLogger('AsciinemaWriter'); export class AsciinemaWriter { private writeStream: fs.WriteStream; @@ -162,7 +165,11 @@ export class AsciinemaWriter { // Force immediate disk write to trigger file watchers if (this.fd !== null) { try { - fs.fsyncSync(this.fd); + fs.fsync(this.fd, (err) => { + if (err) { + logger.error(`Failed to fsync asciinema file: ${err.message}`); + } + }); } catch (_e) { // Ignore sync errors } diff --git a/web/src/server/pty/pty-manager.ts b/web/src/server/pty/pty-manager.ts index 22e880fb..715ca943 100644 --- a/web/src/server/pty/pty-manager.ts +++ b/web/src/server/pty/pty-manager.ts @@ -350,10 +350,10 @@ export class PtyManager extends EventEmitter { } } - // Write to asciinema file + // Write to asciinema file (now async, non-blocking) asciinemaWriter?.writeOutput(Buffer.from(data, 'utf8')); - // Forward to stdout if requested (for fwd.ts) + // Forward to stdout if requested (for fwd.ts) with batching if (forwardToStdout) { process.stdout.write(data); }