mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 10:39:32 +01:00
fix: don't point the image watcher at a remote session's directory
A remote-SSH session's workingDir is a path on the remote host, and the image watcher watched it on the local disk: a folder that is not there, or a same-named local folder whose images then popped up as the remote session's. Same root cause as the Ralph @fix_plan.md watcher fix. Three places start a watch, and all three now skip a remote session: setupSessionListeners(), the app-wide toggle in PUT /api/settings (which re-watches every enabled session), and POST /api/sessions/:id/image-watcher, which refuses to turn it on (INVALID_INPUT, like the Git fetch settings route) and still lets it be turned off. The Session Options row is hidden for a remote session, the way the Git tab is, since the client's _apiPost() does not throw on a refused request.
This commit is contained in:
1 parent
ecf28fa3be
commit
2c2f69adba
5 files changed
+206
-5
No files matched your search
@@ -2709,7 +2709,10 @@ Object.assign(CodemanApp.prototype, {
|
||||
// Git: the session's own choice if it has one, otherwise the app setting. updateGitFetchStatus is also
|
||||
// what SSE calls when a scheduled run lands, so the rows stay current while the modal is open.
|
||||
this.updateGitFetchStatus(sessionId);
|
||||
document.getElementById('modalImageWatcherEnabled').checked = session.imageWatcherEnabled ?? true;
|
||||
const imageWatcherToggle = document.getElementById('modalImageWatcherEnabled');
|
||||
imageWatcherToggle.checked = session.imageWatcherEnabled ?? true;
|
||||
// The server never watches a remote session's directory (it is on another host), so the row is hidden.
|
||||
imageWatcherToggle.closest('.set-row').style.display = session.remote ? 'none' : '';
|
||||
document.getElementById('modalFlickerFilterEnabled').checked = session.flickerFilterEnabled ?? false;
|
||||
|
||||
// Populate session name input with prefix/suffix split
|
||||
|
||||
@@ -3780,6 +3780,11 @@ export function registerSessionRoutes(
|
||||
const { id } = req.params as { id: string };
|
||||
const body = parseBody(ImageWatcherSchema, req.body, 'Invalid request body');
|
||||
const session = findSessionOrFail(ctx, id, req);
|
||||
// A remote session's workingDir is a path on the remote host; the watcher would watch it on the
|
||||
// LOCAL disk (a missing folder, or a same-named local one whose images are not the session's).
|
||||
if (body.enabled && session.remote) {
|
||||
return createErrorResponse(ApiErrorCode.INVALID_INPUT, 'Image watching does not run for remote sessions');
|
||||
}
|
||||
|
||||
if (body.enabled) {
|
||||
imageWatcher.watchSession(session.id, session.workingDir);
|
||||
|
||||
@@ -1183,9 +1183,10 @@ export function registerSystemRoutes(
|
||||
|
||||
// Handle image watcher toggle dynamically
|
||||
toggleService((merged.imageWatcherEnabled as boolean) ?? false, imageWatcher, 'Image watcher', () => {
|
||||
// Re-watch all active sessions that have image watcher enabled
|
||||
// Re-watch all active sessions that have image watcher enabled (never a remote session: its
|
||||
// workingDir is a path on the remote host, not on this disk)
|
||||
for (const session of ctx.sessions.values()) {
|
||||
if (session.imageWatcherEnabled) {
|
||||
if (session.imageWatcherEnabled && !session.remote) {
|
||||
imageWatcher.watchSession(session.id, session.workingDir);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -2067,8 +2067,10 @@ export class WebServer extends EventEmitter {
|
||||
session.ralphTracker.setWorkingDir(session.workingDir);
|
||||
}
|
||||
|
||||
// Start watching for new images in this session's working directory (if enabled globally and per-session)
|
||||
if ((await this.isImageWatcherEnabled()) && session.imageWatcherEnabled) {
|
||||
// Start watching for new images in this session's working directory (if enabled globally and per-session).
|
||||
// A remote session's workingDir is a path on the remote host, and the watcher watches it on the LOCAL
|
||||
// disk, so it is skipped there (the per-session and app-wide toggles skip it too).
|
||||
if ((await this.isImageWatcherEnabled()) && session.imageWatcherEnabled && !session.remote) {
|
||||
imageWatcher.watchSession(session.id, session.workingDir);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user