Fix #126: stop note tiles from triggering ENOENT on undefined file path#130
Open
Hude06 wants to merge 1 commit into
Open
Fix #126: stop note tiles from triggering ENOENT on undefined file path#130Hude06 wants to merge 1 commit into
Hude06 wants to merge 1 commit into
Conversation
When a note tile is created without a backing file, tile-manager built
the viewer webview URL with `encodeURIComponent(undefined)`, producing
the literal query string `tilePath=undefined`. The viewer then parsed
that as a truthy string and called `fs:readfile("undefined")`, which
the desktop bridge resolved against the app install dir and failed
with ENOENT (issue collabs-inc#126).
Two changes:
1. tile-manager.js: build the viewer URL with URLSearchParams and
only set `tilePath` when filePath is a non-empty string. Note
tiles without a backing file get a viewer URL with no tilePath.
2. viewer App.tsx: defense in depth — treat the literal strings
"undefined" and "null" as missing tilePath, so any other caller
that emits a stringified nullish value also no-ops cleanly.
Fixes collabs-inc#126
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the Contributor License Agreement (CLA) and hereby sign the CLA. |
chihirokajiwara-AI
pushed a commit
to chihirokajiwara-AI/collab-public
that referenced
this pull request
May 10, 2026
When a note tile has no file path, the viewer would receive tilePath=undefined in the URL, triggering an ENOENT error on readFile. Now uses URLSearchParams and only sets tilePath when it's a valid non-empty string. Also strengthened the viewer-side guard to reject string literals "undefined" and "null". Upstream: collabs-inc#130 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #126.
Root cause
Tracing the ENOENT from the issue:
canvas-rpc.js:104— RPCtileCreatedefaultstileTypeto"note". For a note with no backing file, it falls through tocreateFileTile("note", x, y, undefined).tile-manager.js:626-628— Builds the viewer webview URL with\tilePath=${encodeURIComponent(filePath)}`.encodeURIComponent(undefined)returns the literal string"undefined", so the URL becomesviewer.html?tilePath=undefined&tileMode=note`.viewer/src/App.tsx:108-114— ParsestilePathfrom the URL.params.get("tilePath")returns the string"undefined". Theif (tp)guard treats it as truthy and callssetSelectedPath("undefined").viewer/src/App.tsx:324— Subsequently callswindow.api.readFile("undefined"). The desktop bridge resolves the relative path against the app install dir, producing the path from the issue:Fix
Two surgical changes, both upstream of the IPC call:
collab-electron/src/windows/shell/src/tile-manager.jsBuild the viewer URL with
URLSearchParamsand only settilePathwhenfilePathis a non-empty string. Note tiles without a backing file now get a viewer URL with notilePathat all, so the viewer's existingif (!selectedPath) return;guard catches them naturally and never callsreadFile.collab-electron/src/windows/viewer/src/App.tsxDefense in depth — treat the literal strings
"undefined"and"null"as missingtilePath. This protects against any other caller that might still emit a stringified nullish value (e.g. older serialized state, third-party RPC callers).What this does not do
This PR fixes the crash but does not implement in-memory note content. Note tiles created without a backing file will render an empty viewer rather than throwing. The viewer already accepts a
tileModequery param but does not currently branch on it — adding real in-memory note rendering is a larger scope and belongs in a follow-up.Verification
Repro from the issue: