Skip to content

Refresh @ file mentions for new and spaced paths - #67

Merged
hardbeat920 merged 3 commits into
hardbeat920:mainfrom
elanchezhiyanr:fix/project-file-index-refresh
Sep 5, 2026
Merged

Refresh @ file mentions for new and spaced paths#67
hardbeat920 merged 3 commits into
hardbeat920:mainfrom
elanchezhiyanr:fix/project-file-index-refresh

Conversation

@elanchezhiyanr

Copy link
Copy Markdown
Contributor

What changed

The project file index now refreshes on window focus and directory-change notifications, and a refresh is no longer dropped if a scan is already in flight. The composer @ picker subscribes to those updates.

Paths with spaces are included in @. The picker still shows the real name. Picking one inserts a single-word @ token (spaces become hyphens). On send, the prompt maps that token to the real project-relative path. Paths that leave the workspace or would break the tokenizer are skipped.

Why

@ used a stale in-memory git ls-files cache. The explorer already reloaded on focus; the mention list did not. Files copied into the project from Finder therefore did not appear until something else forced a full reload.

@ tokens are one whitespace-delimited word, so spaced names were excluded entirely. They now stay a normal @label in the composer, with the real path recovered from the mention index on send rather than decoded from user text.

UI

Behavior only. Copy a file or a folder (including names with spaces) into the project, return to MonoCode, type @ plus part of the name, pick it, and confirm it is referenced in the prompt.

Checklist

  • I ran npm run check
  • This PR is small and focused
  • I did not mix unrelated changes

Fixes #66

Keep @ mentions in sync with files added on disk by invalidating the
in-memory listing on focus and directory changes, and by not dropping a
refresh that arrives while a scan is already in flight.
Show spaced files and folders in the picker, insert a single-word @
token, and resolve it to the real project-relative path on send. Skip
paths that leave the workspace or would break the tokenizer.
@hardbeat920

Copy link
Copy Markdown
Owner

Looks great overall @elanchezhiyanr. Could you reject Unicode line separators and bidi control characters in isSafeProjectRelative() and add a regression test?

Mentionable relatives must not include control, format, or line/paragraph
separator characters, so a crafted name cannot split the prompt or spoof
the token. Add regression coverage for those cases.
@elanchezhiyanr

Copy link
Copy Markdown
Contributor Author

Hi @hardbeat920 Thanks. Done in the latest commit.

isSafeProjectRelative() now rejects Unicode controls, bidi/format marks, and line/paragraph separators (Cc, Cf, Zl, Zp). Same check is on the token path so those names never become an @ label. Added a regression test for U+2028, U+2029, NEL, U+202E, and ZWSP.

@hardbeat920

Copy link
Copy Markdown
Owner

Thanks @elanchezhiyanr, this addresses my concern. Looks good to merge!

@hardbeat920
hardbeat920 merged commit 5502bcb into hardbeat920:main Sep 5, 2026
2 checks passed
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.

@ mentions miss newly pasted files and paths with spaces

2 participants