Skip to content

fix(watcher): detect file changes for files-type sources and close dead SSE connections#456

Merged
loganj merged 1 commit intomainfrom
markdown-file-refresh-issue-wi
Mar 24, 2026
Merged

fix(watcher): detect file changes for files-type sources and close dead SSE connections#456
loganj merged 1 commit intomainfrom
markdown-file-refresh-issue-wi

Conversation

@loganj
Copy link
Collaborator

@loganj loganj commented Mar 24, 2026

Summary

  • findProjectForPath now matches files from type:"files" sources — previously only checked RootPath prefixes, which are empty for file-list sources, so change events were silently dropped
  • watchProjectSources watches directories of individually listed files — so FocusProject correctly monitors these sources
  • SSE handler returns on write error — prevents events from being consumed from the subscriber channel but never delivered to a disconnected client

🤖 Generated with Claude Code

…dead SSE connections

findProjectForPath never matched files from type:"files" sources because
their RootPath is empty — it only checked RootPath prefixes. Now also
checks individual src.Files paths so change events are correctly
attributed to their project.

watchProjectSources now watches directories containing individually
listed files, so FocusProject picks them up.

The SSE handler now checks fmt.Fprintf errors and returns immediately
on write failure, preventing events from being consumed from the
subscriber channel but never delivered to a disconnected client.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@loganj loganj marked this pull request as ready for review March 24, 2026 22:22
@loganj loganj merged commit 4f7939b into main Mar 24, 2026
4 checks passed
@loganj loganj deleted the markdown-file-refresh-issue-wi branch March 24, 2026 22:22
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a34c348585

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +205 to +206
if err := w.watcher.Add(dir); err == nil {
w.focusWatched = append(w.focusWatched, dir)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve baseline root watches when adding files-source dirs

If a type:"files" source includes a root-level file (for example README.md), filepath.Dir(f) is the project root, which is already shallow-watched in Start. fsnotify.Add is a no-op that still returns nil for duplicate paths, so this code appends that root path to focusWatched; later removeFocusWatches calls Remove on it and unintentionally drops the baseline project-root watch. After focus is cleared/switched, create/remove events under the project root no longer trigger auto-detect rescans in handleEvent, so newly added source dirs can be missed until process restart.

Useful? React with 👍 / 👎.

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.

1 participant