mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-04 14:39:42 +02:00
fix: image watcher now uses relative path for subdirectory images
- Added relativePath field to ImageDetectedEvent - Compute relative path from working directory in image-watcher - Use relativePath in frontend URL (fixes 'Failed to load image' for subdirs) - Minor CLAUDE.md improvements chore: bump version to 0.1461
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { watch, type FSWatcher } from 'chokidar';
|
||||
import { basename, extname } from 'node:path';
|
||||
import { basename, extname, relative } from 'node:path';
|
||||
import { statSync } from 'node:fs';
|
||||
import type { ImageDetectedEvent } from './types.js';
|
||||
|
||||
@@ -265,10 +265,14 @@ export class ImageWatcher extends EventEmitter {
|
||||
try {
|
||||
const stat = statSync(filePath);
|
||||
const fileName = basename(filePath);
|
||||
const workingDir = this.sessionDirs.get(sessionId);
|
||||
// Compute relative path from working directory (for file-raw endpoint)
|
||||
const relativePath = workingDir ? relative(workingDir, filePath) : fileName;
|
||||
|
||||
const event: ImageDetectedEvent = {
|
||||
sessionId,
|
||||
filePath,
|
||||
relativePath,
|
||||
fileName,
|
||||
timestamp: Date.now(),
|
||||
size: stat.size,
|
||||
|
||||
Reference in New Issue
Block a user