mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-16 13:05:53 +00:00
Async fsync, so writes from PTY to host terminal are fast again.
This commit is contained in:
parent
e9b395b726
commit
bb17f4adcd
3 changed files with 28 additions and 11 deletions
|
|
@ -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!
|
||||
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!
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue