Repository navigation
fix(chat): show omp's blob-store pictures on macOS and Windows (#2004) - #2114
Conversation
omp keeps a picture's bytes in <data>/blobs/<sha256>. Since #1998 the bridge read a blob only on Linux, through /proc/self/fd of the held store, and refused it on macOS and Windows, where Node has no descriptor-relative open. server/held-open.ts holds a directory opened without following a link and opens its entries through it, asking the open object itself what it is and where it is now: - Linux: unchanged (/proc/self/fd open and readlink). - macOS: openat(2) relative to the held descriptor (O_NOFOLLOW), and fgetattrlist(2) ATTR_CMN_FULLPATH for its path, through bun:ffi. fcntl(F_GETPATH) is variadic and returns an empty path through a fixed FFI signature on arm64, so it is not used. - Windows: CreateFileW and NtCreateFile relative to the held handle, both on the link itself, so a junction or symbolic link is refused; GetFinalPathNameByHandleW for its path, GetFileInformationByHandle for its identity, ReadFile for the bytes. openBlob and the transcript's anchor walk (ompBlobIdentity) use it. Identities are taken from bigint stats: Bun rounds a Windows file index held in a number. omp-images.test.ts runs on all three platforms now, the store and parent swap races included.
…ateFile, and run omp-images natively in CI Review of #2004's first commit: - The UNICODE_STRING and the name it points into were separate buffers reachable only through raw pointers, so GC could collect them before NtCreateFile read them. OBJECT_ATTRIBUTES, the UNICODE_STRING and the name now share the one allocation passed to the call. - ':' and '\\' are refused in an entry name only on Windows; elsewhere a session file may hold them. - fgetattrlist's options argument is an unsigned long (u64). - The native Windows and macOS CI jobs run server/omp-images.test.ts.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Held-directory API and platform implementations server/held-open.ts |
Adds the Held interface and platform-specific directory and entry operations for Linux, macOS, and Windows. |
Transcript and blob-store identity checks server/transcript-store.ts, server/conversation.ts |
Transcript identity values now use bigint stats. Blob identity lookup traverses held directories and checks the authorized transcript and blobs directory. |
Held blob opening and reading server/codex-images.ts |
Blob opening validates the held store and opens the digest relative to it. Image reads and cleanup use held-file operations. |
Cross-platform tests and CI coverage server/omp-images.test.ts, .github/workflows/ci.yml, changelog.d/omp-blob-pictures-mac-windows.md |
Tests cover supported platforms, path and identity cases, and directory-link substitutions. CI adds the image tests to Windows and macOS commands. The changelog records the platform support. |
Priority:
Estimated code review effort: 4 (Complex) | ~60 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- devswha/ovis#1998: Adds the original OMP blob-image serving path and Linux-only store checks that this change extends.
Merge Risk: 
Minimal · up to a86bc
-
This change extends omp blob-store picture display to macOS and Windows using held-directory opens. No concrete merge-blocking risk was found. The author-reported platform CI runs remain the main validation for Windows identity behavior.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title "fix(chat): show omp's blob-store pictures on macOS and Windows (
#2004)" names the main change. The PR extends blob-backed omp picture display from Linux to macOS and Windows through held-directory opens in server/held-open.ts, openBlob, and ompBlobIdentity. The title is short, specific, and matches the linked issue#2004.
Full details: Linked Issues check
-
Explanation
Directly linked issue
#2004requires blob-backed omp pictures on macOS and Windows. The requirement names a race-free, descriptor-relative open: openat or fcntl(F_GETPATH) on macOS, and NtCreateFile with a root directory handle on Windows. It also requires that no link above the store, or in its place, supplies the blob bytes.Code evidence at head a86bcb8:
- server/codex-images.ts: openBlob now gates on heldOpenPlatform(blobPlatform) instead of Linux only. It opens the store with openHeldDirectory(blobs), checks store.stat().identity against the checked identity, checks store.isAt(blobs), and opens the blob with store.open(digest, "file"). Those are the same checks and order as the former Linux code. blobStoreIdentity uses bigint lstat, so Windows file indexes compare exactly.
- server/held-open.ts: DarwinHeld calls libSystem openat(2) through bun:ffi (O_NOFOLLOW, O_NONBLOCK, O_CLOEXEC) and names the held object with fgetattrlist(2) ATTR_CMN_FULLPATH. WindowsHeld opens the directory with FILE_FLAG_OPEN_REPARSE_POINT, refuses reparse points, and walks the path for isAt. Entry names reject separators, NUL, '.', and '..'.
- Not inspected: the body of WindowsHeld.open (NtCreateFile call) and the rest of isAt. The inspection output was truncated at that point. The PR description and summary report that path, and the CI change adds omp-images.test.ts to the native Windows and macOS jobs. The reported platform results are author-reported; I did not rerun them.
- Not changed by this check: conversation.ts (ompBlobIdentity) and transcript-store.ts. Their behavior is taken from the change summary, not from inspected diff lines.
Result: the macOS and Windows requirements are implemented at the reviewed head, with no unmet coding requirement found in the inspected code. Linux behavior is unchanged per the PR description and the codex-images.ts diff. The issue's non-coding items, if any, do not apply.
Full details: Out of Scope Changes check
-
Explanation
Changed files, from the file summary and the inspected codex-images.ts diff:
- server/held-open.ts (new): the held-directory primitive. Required for the macOS and Windows opens in
#2004. - server/codex-images.ts: openBlob moves to the held-open API. Required by
#2004. - server/conversation.ts and server/transcript-store.ts: ompBlobIdentity and the bigint fstat identity move to the same platform gate and identity form. These support the transcript store-anchor walk named in
#2004. - server/omp-images.test.ts: tests for the new platform paths, run on Linux, macOS, and Windows. Supporting tests for the feature.
- .github/workflows/ci.yml: adds omp-images.test.ts to the native Windows install and macOS session test commands. Verification of the feature, not an unrelated CI change.
- changelog.d/omp-blob-pictures-mac-windows.md: a changelog entry for the user-visible fix. Documentation for the feature.
The PR description states that REMOTE_BUNDLE_VERSION is not changed, and the summary lists no such change. No change found that is unrelated to blob-store pictures. The Windows path walk and the 8.3-name, case-folding, and FAT32 handling are part of the Windows held-open requirement, not separate scope.
Limit: the summaries for conversation.ts, transcript-store.ts, ci.yml, and omp-images.test.ts are not confirmed against their diff lines. This check relies on the file summaries for those files.
- server/held-open.ts (new): the held-directory primitive. Required for the macOS and Windows opens in
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 5 files. (2 skipped: 2 unsupported.)
Full details: Description check
-
Explanation
The description covers the problem, the change, and a detailed validation section, so it matches the template's Change and Validation sections. It also includes a changelog-related note, a review history, and a release note about REMOTE_BUNDLE_VERSION. The Change section is thorough and explains the problem, the platform approach, and the Windows path-identity design. The Validation section lists platform test results and the checks run, with explicit results. The description is mostly complete. The template asks for linked issues when a feature is added, and this PR is a fix that links
#2004, so that requirement is satisfied. No required section is missing.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
GitHub's Windows runner keeps its temporary directory under a short 8.3 name (C:\\Users\\RUNNER~1), and the JS realpath keeps that spelling, while GetFinalPathNameByHandleW names the held store by its long name: the exact path check refused every blob there (Native Windows install). A store named with another letter case was refused the same way. Held.isAt(path) now asks whether the held object is the one the path names. Linux and macOS compare the path exactly, as before. Windows spells every short component long (GetLongPathNameW: the same entries by the same names, no junction resolved) and compares letter case ignored, one UTF-16 unit against one. A junction on the way still makes the handle's final path differ, so it is refused. The event-loop count test now has 30 s: it asserts buffer counts, not time, and its 40 MiB transcript takes about 4 s on Windows.
…paring spellings The previous commit compared the held store's final path with the named path, letter case ignored. In a case-sensitive directory (fsutil setCaseSensitiveInfo) that took Box for box, and a junction whose name differs from its target's only by case passed the no-link check (Codex review). Windows isAt now walks the named path from its root (a drive or a share): each name is opened by NtCreateFile through the directory before it, a reparse point (junction, symbolic link, mount point) is refused, and the walk must end at the very object held (volume serial and file index). The system resolves each name as any open would, short 8.3 names and each directory's own case rules included. The spelling test changes the case of its own ASCII name only, and a new test holds a store to its own name where letter case tells two directories apart (skipped where fsutil makes no case-sensitive directory).
…its full file id Codex review of the walk: - A '/' inside a share or device path (\\\\.\\C:/qa/link/agent\\blobs) put names into the parsed root, which CreateFileW then opened through a junction unseen; a subst drive's root did the same. A path with '/', NUL or the device namespace is refused, a server is never '.' or '?', and the root handle's own path must be the root named (letter case aside), so a drive that names a folder elsewhere (subst, a mapped share) is refused. - The 64-bit file index can be 0 or all ones where a file system keeps none unique, and two directories would then compare equal. isAt now compares FILE_ID_INFO (the volume serial and the 128-bit id) and refuses those values; stat() refuses a legacy index that names no one file. A Windows test holds a store to its path only when every name on it is walked.
…em keeps no full id FAT32 answers no FileIdInfo though its 64-bit index names the directory, so the previous commit refused every store there (Codex review; Microsoft's STL restored the same fallback). isAt prefers the full id and falls back to the index (its sentinels refused) only when the query fails; a full id the file system marks unavailable stays refused.
|
Merging a86bcb8 on the owner's go, relayed by Dori, which approves the |
Fixes #2004 (follow-up to #1998).
Problem
omp keeps a picture's bytes in its blob store (
<data>/blobs/<sha256>). Since #1998 the bridge read a blob only on Linux: it opened the store as a held directory and the blob through it (/proc/self/fd/<fd>/<digest>), so no link or directory swapped in above it could stand in for the store. Node has no descriptor-relative open on macOS or Windows, so thereopenBlobreturned null and Chat showed no blob-backed omp picture (reproduced on eamac and home-window in the issue).Change
server/held-open.tsholds a directory opened without following a link and opens its entries through the held object, asking the open object itself what it is (identity) and where it is now (path):/proc/self/fd/<fd>/<name>,O_NOFOLLOWreadlink /proc/self/fd/<fd>fstatopenat(2)via bun:ffi,O_NOFOLLOW|O_NONBLOCK|O_CLOEXECfgetattrlist(2)ATTR_CMN_FULLPATHfstatNtCreateFilewithRootDirectory= held handle,FILE_OPEN_REPARSE_POINT; any reparse point (junction, symlink) refusedGetFileInformationByHandle(volume serial + 64-bit file index);FILE_ID_INFOfor the walkopenBlob(codex-images.ts) and the transcript's store anchor walk (ompBlobIdentity, conversation.ts) use it, with the same checks and order as the Linux code before.fcntl(F_GETPATH)is not used: it is variadic, and through a fixed FFI signature on arm64 it returns 0 with an empty path (probed on eamac).…020vs the exact…019n), which would have refused every picture.OBJECT_ATTRIBUTES, itsUNICODE_STRINGand the name share the one allocation passed toNtCreateFile, so GC cannot collect a buffer reachable only through a raw pointer./, NUL,.,..everywhere, and\and:(streams) on Windows only.server/omp-images.test.tsnow runs on all three platforms, the swap races included, and the native Windows and macOS CI jobs run it.Windows: is the held store the one its path names?
Linux and macOS compare the descriptor's own path with the path asked for. Windows names one directory several ways (a short 8.3 name, as GitHub's runner keeps its temp directory under
C:\Users\RUNNER~1; another letter case), so an exact comparison refused every blob there, and a case-insensitive one let a different directory through in a case-sensitive folder. SoisAtwalks the path instead: from its root (a drive or a share, whose own handle must name that root, so asubstor mapped drive is refused), each name opened through the directory before it with reparse points refused, down to the very object held, compared byFILE_ID_INFO(the volume serial and the 128-bit id; the 64-bit index where a file system keeps no full id, as FAT32; ids that name no one file refused). A path with/, NUL or the\\.\device namespace is refused before it is walked.Try it
On a Mac or Windows PC running this branch's server, in an omp pane (omp 18.8.7 or later):
@shot.png what is this?), or ask it toreada picture file.readtool row). Before this PR it is missing there on macOS and Windows, while inline pictures still show.ls <omp data>/blobslists the picture's sha256 name; the Chat picture is served from that file only.Verification
Fresh clones of origin/main
65ffea69plus this branch, withHERDR_TEST_MODE=unit, deleted afterwards:bun test server/omp-images.test.ts21 pass, 0 fail, 3 skip (Windows-only cases); a real store probe givesimage/pngwith the exact bytes. The same tests against main's server code: 18 fail, probe null. A store under$HOMEis served too (fgetattrlistnames/Users/...).TEMPset to an 8.3 short path as on GitHub's runner): 23 pass, 0 fail, 1 skip (the colon-name case, POSIX-only by design), including the short-name and letter-case spellings, a case-sensitive folder (Boxvsbox, a junction whose name differs from its target's only by case), and/or\\.\spellings through a junction; probeimage/png. 20,000 relative opens withBun.gc(true)every 100: 0 failures. Asubstdrive below a junction or onto the real folder is refused (probe). Against main's server code: 18 fail, probe null.bun run check fastgreen on the head (unit 7757 pass, 0 fail).Review
isAt's design went through three more Codex rounds: case folding equated distinct directories in a case-sensitive folder (MEDIUM),/or\\.\orsubstcould hide a junction above the walk's root and sentinel file ids compared equal (two MEDIUM), and FAT32 lost its pictures when the full id was required (MEDIUM); each fixed and verified on home-window. Final round: APPROVE, no findings.:refused on POSIX). All fixed in the second commit; round 2 on that delta: no findings.fgetattrlistargument type was fixed; the macOS firmlink concern was checked on eamac (served).This PR touches a workflow (
.github/workflows/ci.yml, two test lists) and a file-serving security path, so it waits for a real review.REMOTE_BUNDLE_VERSIONis not raised here: the release PR raises it (docs/development.md).