Skip to content

Comments

intake(lote-B): import upstream PR #1842#8

Open
nsalvacao wants to merge 10 commits intobaseline/develop-sync-2026-02-17from
intake/lote-B-pr-1842
Open

intake(lote-B): import upstream PR #1842#8
nsalvacao wants to merge 10 commits intobaseline/develop-sync-2026-02-17from
intake/lote-B-pr-1842

Conversation

@nsalvacao
Copy link
Owner

@nsalvacao nsalvacao commented Feb 17, 2026

Upstream intake PR for isolated review.

Checklist:

  • Automated checks green
  • Bot review comments triaged
  • Manual review complete
  • Safe for baseline merge

AndyMik90 and others added 10 commits February 15, 2026 17:33
…k90#1805)

The FileWatcher was always watching the main project's spec directory for
implementation_plan.json changes. When tasks run in a worktree, the backend
writes the plan file to the worktree directory instead, so the watcher never
detected changes and subtask progress was never sent to the UI.

Changes:
- Add getSpecDirForWatcher() helper that checks worktree path first
- Update all 3 file watcher setup locations (TASK_START, TASK_UPDATE_STATUS
  auto-start, TASK_RECOVER_STUCK auto-restart) to use worktree-aware paths
- Add re-watch logic in execution-progress handler: when a worktree appears
  after task start, automatically switch the watcher to the worktree path
- Add worktree fallback in exit handler for reading final plan state
- Add getWatchedSpecDir() method to FileWatcher for path comparison

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dling (AndyMik90#1805)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rror handling

- Add pendingWatches guard in FileWatcher.watch() to prevent overlapping async
  calls from creating duplicate watchers (CodeRabbit critical finding)
- Add .catch() to all three fire-and-forget fileWatcher.watch() calls in
  execution-handlers.ts to prevent unhandled promise rejections
- Remove shadowed specsBaseDir re-declaration in autoRestart block, reusing
  the outer variable from the same TASK_RECOVER_STUCK handler scope
…variable shadowing

- Change pendingWatches from Set<string> to Map<string, string> (taskId->specDir)
  so re-watch calls with a different specDir are allowed through instead of silently dropped
- Add cancelledWatches Set to coordinate unwatch() with in-flight watch() calls,
  preventing watcher leaks when unwatch() runs during watch()'s await points
- Add .catch() handler to fileWatcher.unwatch() call in agent-events-handlers exit handler,
  consistent with the .catch() pattern used for all watch() calls
- Remove shadowed const mainSpecDir re-declaration inside autoRestart block in
  execution-handlers.ts, using the outer variable from the enclosing try block instead

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ions

- Add supersession check in watch() after awaiting existing watcher close
  to prevent a later concurrent call from having its watcher overwritten
- Return early in unwatch() when a watch() is in-flight to prevent
  double-closing the same FSWatcher
- Cancel in-flight watch() calls in unwatchAll() by marking their taskIds
  in cancelledWatches before closing existing watchers
- Add .catch() to fileWatcher.unwatch() calls in TASK_STOP and
  TASK_RECOVER_STUCK handlers to surface errors instead of silently dropping them

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Make finally block conditional so superseding watch() calls are not
  wiped out by the superseded call cleaning up pendingWatches
- Delete watcher from map before awaiting close() to prevent concurrent
  calls from double-closing the same FSWatcher reference
- Make cancelledWatches cleanup conditional on the call still owning the
  pendingWatches entry, preventing premature flag removal for concurrent calls
- Fix misleading comment about mainSpecDir declaration scope

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ards, and test coverage

- Remove dead code in finally block: after delete(), has() is always
  false so the inner if was always true; simplify to a single delete +
  cancelledWatches.delete call (Finding 1)
- Add implementation_plan.json existence check in getSpecDirForWatcher
  before preferring the worktree path, so the watcher is started in
  the correct directory even when the plan file hasn't been written yet
  (Finding 2)
- Clear pendingWatches in unwatchAll() so in-flight watch() calls can
  no longer register new watchers after a full teardown (Finding 3)
- Also clear cancelledWatches in unwatchAll() since in-flight calls bail
  via the supersession check and won't clean up the flags themselves
- Add comprehensive concurrency tests for FileWatcher covering
  deduplication, supersession, cancellation, and unwatchAll behaviour
  (Finding 4)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…bility

Replace hardcoded forward-slash strings in getWatchedSpecDir assertions with
path.join() so expected values match on Windows (backslash) and Unix (forward
slash) alike.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants