Skip to content

Follow symlink starting points in omarchy-menu-file - #12669

Open
Bartok9 wants to merge 8 commits into
omacom:quattrofrom
Bartok9:fix-menu-file-follow-symlinks
Open

Bartok9 wants to merge 8 commits into
omacom:quattrofrom
Bartok9:fix-menu-file-follow-symlinks

Conversation

@Bartok9

@Bartok9 Bartok9 commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

omarchy-menu-file ran find without following symlink starting points, so paths like ~/Videos / ~/Pictures on extra disks produced zero files. Transcode never opened the picker because omarchy-menu-select got empty stdin.

Uses find -H so only command-line starting points are followed (not nested symlinks inside the tree).

Also bounds listing / menu payload so a huge library cannot blow MAX_ARG_STRLEN:

  • newest 500 files, and
  • ~80KB total path bytes via LC_ALL=C awk (byte length under UTF-8 LANG, first cut for ordinary valid UTF-8 names), and
  • omarchy-menu-select rejects oversized encoded options JSON (MAX_MENU_OPTIONS_JSON_BYTES=120000, measured in C-locale bytes) before the Perl/shell IPC hop.

Closes #12665.

Test plan

  • test/shell.d/menu-file-symlink-test.sh stubs omarchy-menu-select and asserts a symlink starting point still yields $link/... paths (find %p).
  • test/shell.d/menu-select-options-byte-budget-test.sh checks oversized invalid-UTF-8 options fail closed under C.UTF-8 with options payload too large.
  • ./test/shell for those files (no GitHub Actions on this repo).

Did not ping maintainers.

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

Source review found incomplete payload-size protection and an incorrect pathname expectation in the added test.

The 500-file cap is not a byte limit

In omarchy-menu-file, head -n 500 limits entries, while omarchy-menu-select still passes the entire encoded options array as one argument to Perl and later passes the menu payload through the shell IPC command.

Source-derived example with synthetic path lengths, not a runtime reproduction:

500 paths × 280 ASCII bytes = 140,000 bytes before JSON overhead
                              > 131,072-byte single-argument limit

Impact: On Linux systems with that argument limit, a collection of sufficiently long paths can still fail with an argument-too-long error instead of opening the picker. The cap helps ordinary-length collections but does not guarantee the protection stated in the comment.

Suggested change: Bound the encoded payload size with room for metadata, or use a transport that avoids a single oversized argument at both the Perl and shell/IPC boundaries.

Test-only correction: menu-file-symlink-test.sh:26 expects $real/clip.webm, but find -L traverses the symlink without canonicalizing %p:

starting point: $link -> $real
emitted path:   $link/clip.webm
test expects:  $real/clip.webm

By source inspection, this assertion rejects the intended output and makes the new test fail. Compare with "$link/clip.webm" instead. This is a test expectation mismatch, not a failure of the symlink traversal fix.

Verified by source inspection: -L follows symlinked starting directories, newest-first sorting is retained, and the selector's nonzero exit status still propagates. Only the newest 500 matches remain eligible, so older files are omitted from the picker.


Review information

Test scope: Source review at f4a067bd. No runtime results are relied upon here; actual menu rendering, external disks and end-to-end transcoding were not validated.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium initial inspection, independent Opus 5.5 High and GPT 6 Sol Xhigh technical assessments, followed by Astra Medium adjudication against pinned source and a separate editorial check.

@Bartok9

Bartok9 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review — both points were solid.

Pushed bad95f0:

  • Test now expects $link/clip.webm (find -L keeps the symlink start in %p, no canonicalize).
  • Listing cap is entry count and ~100KB total path bytes before omarchy-menu-select, so long paths can’t still trip MAX_ARG_STRLEN after JSON encoding.

Happy to tighten the byte budget further if maintainers want a different headroom.

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the earlier review and author reply, checked at bad95f00.

Earlier finding Status at bad95f00
Test expected $real/clip.webm Resolved
500-file cap is not a byte limit Still present, narrower: fixed for ordinary ASCII paths, not for long non-ASCII names

Verified: The test now expects $link/clip.webm and passes. It fails on f4a067bd, and on the base script without -L, so it catches the original bug. For long ASCII paths, the new awk budget now opens the picker: 280-byte paths that previously failed with Argument list too long now list the newest 355 files, and the menu payload is about 100.7 KB.

The budget counts characters, not bytes, in a UTF-8 locale

In omarchy-menu-file, length($0) is charged against max_bytes = 100000. In a multibyte locale, gawk's length() counts characters, and Omarchy sets a UTF-8 LANG. A CJK character is 3 bytes but costs one budget unit.

Isolated run with the real omarchy-menu-select, 500 synthetic files with long CJK names:

awk budget counted:    75,500 units   (under 100,000, all 500 kept)
actual path bytes:    185,500
options JSON:         186,501 bytes  > 131,071-byte single-argument limit
result:               omarchy-menu-select: /usr/bin/perl: Argument list too long (exit 126)

The same fixture under LC_ALL=C keeps 269 entries and opens normally. Long Cyrillic names fail the same way. Moderate-length non-Latin names stay under the limit. At 500 entries, failure needs paths of roughly 260 or more UTF-8 bytes that are still no longer than about 199 characters.

The byte budget can also be exceeded after awk by two less common kinds of name:

  • names heavy in characters that JSON escapes (\, ", control characters);
  • names containing invalid UTF-8 bytes, each replaced by a 3-byte U+FFFD during encoding.

Both failed the same way in isolated runs with crafted names, including under LC_ALL=C.

Impact: For collections with long non-ASCII file names, omarchy-transcode still fails without opening the picker. omarchy-games-retro-install exits silently. The code comment ("total path bytes") and the reply's statement that long paths can no longer trip the limit after JSON encoding hold for ASCII names without heavy escaping only.

Suggested change: Enforce the limit on the encoded size inside omarchy-menu-select, where the exact JSON and metadata are known, or avoid passing the options as one large argument. That covers all three routes. A smaller step is running the filter as LC_ALL=C awk: in a disposable copy, it fixed the CJK case (269 entries, exit 0). It does not cover escaped or invalid UTF-8 names.

Wording note: Only the newest 500 or fewer files are now eligible. For example, 280-byte paths list the newest 355.


Review information

Test scope: Follow-up at bad95f00. Isolated command-only runs used the real omarchy-menu-file and omarchy-menu-select, synthetic file names and a stub in place of the shell IPC hop. The PR's test file ran by itself. Menu rendering, the real IPC transport and the full test suite were not run. Limits assume 4 KiB pages and the C.UTF-8 locale.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments with targeted cross-checks, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@Bartok9

Bartok9 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up — good catch on length() under UTF-8.

Pushed another commit:

  • Run the listing filter as LC_ALL=C awk so the budget is bytes, not characters (CJK/Cyrillic long names no longer under-count).
  • Dropped the path budget from 100KB → 80KB for JSON/escape/metadata headroom before omarchy-menu-select.

A full encoded-size check inside omarchy-menu-select would be the more complete fix for exotic escapes/invalid UTF-8; happy to do that in a follow-up if maintainers want it scoped there instead of only at the lister.

@llstrk

llstrk commented Sep 24, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the earlier reviews (first, second) and the author reply, checked at f9c706e3.

Earlier finding Status at f9c706e3
Budget counts characters, not bytes, in a UTF-8 locale Resolved
Names with escaped or invalid UTF-8 bytes exceed the limit after awk Still present, only when such bytes make up a large share of the listing
500-file cap is not a byte limit Still present, narrower: now only through the row above
Only the newest 500 or fewer files are eligible Addressed in the PR description
Test expected $real/clip.webm Resolved earlier; test unchanged

Verified: LC_ALL=C awk makes length() count bytes. In isolated runs with the real omarchy-menu-file and omarchy-menu-select, long CJK and Cyrillic names that fail at bad95f00 with Argument list too long now open the picker (about 200 to 285 entries depending on name length, payload about 80.5 KB). For valid UTF-8 names without heavy escaping, the 80,000-byte budget keeps the payload at or below about 81.2 KB, well under the 131,071-byte single-argument limit. The exit status still comes from omarchy-menu-select, and the PR's test passes at this head. No regressions were found in the changed lines or in omarchy-transcode and omarchy-games-retro-install.

Escaped and invalid UTF-8 bytes still grow past the limit

The awk budget counts raw path bytes, but omarchy-menu-select expands some bytes when it JSON-encodes the options:

byte in path                            bytes in payload
valid UTF-8 (including CJK, Cyrillic)   1 -> 1
" \ tab CR                              1 -> 2
other control bytes (0x01 to 0x1f)      1 -> 6   (\u00XX)
invalid UTF-8 (e.g. CP1251, Latin-1)    1 -> 3   (U+FFFD)

With a full budget, the payload passes 131,071 bytes when roughly more than 31% of listed path bytes are invalid UTF-8, more than 12.5% are control bytes, or more than 62% are quotes or backslashes. Isolated runs at f9c706e3 with synthetic file names:

case                                        payload (bytes)  result
long CP1251 names (56% non-UTF-8 bytes)         158,670      Argument list too long (exit 126)
ASCII names inside a CP1251-named folder        172,368      Argument list too long (exit 126)
names with 40 control bytes each                174,670      Argument list too long (exit 126)
names with 120 quotes/backslashes each          137,813      Argument list too long (exit 126)
shorter CP1251 names (27% non-UTF-8 bytes)       62,170      opens
Latin-1 accented names                           71,170      opens

Impact: Collections with long legacy-encoded names (for example folders copied from older CP1251 or Latin-1 systems), or with unusual characters, still make omarchy-transcode exit without a picker and omarchy-games-retro-install exit silently. Ordinary UTF-8 libraries are no longer affected. The new code comment ("headroom for JSON quotes/escapes") and the PR description ("cannot blow MAX_ARG_STRLEN") state slightly more than this.

Suggested change: The encoded-size check inside omarchy-menu-select proposed in the reply covers all of these cases, because the exact JSON and metadata are known only there. If that check is left for a separate PR, narrowing the code comment to valid UTF-8 names keeps it accurate.


Review information

Test scope: Follow-up at f9c706e3, compared with bad95f00. Isolated command-only runs used the real omarchy-menu-file and omarchy-menu-select, synthetic file names and a stub in place of the shell IPC hop. Payload sizes for failing rows were computed with the real Perl encoders on the exact listing, a method that matched the stub-observed size in every run that opened. The PR's test file ran by itself. Menu rendering, the real IPC transport and the full test suite were not run. Limits assume 4 KiB pages and the C.UTF-8 locale. How common legacy-encoded names are in practice was not assessed.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@Bartok9

Bartok9 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up — agreed the remaining edge is encoded expansion (escapes / invalid UTF-8), not the C-locale path budget.

Pushed cbb7a78:

  • omarchy-menu-select now rejects oversized encoded options JSON (MAX_MENU_OPTIONS_JSON_BYTES=120000) before building the shell/IPC payload, so escape and U+FFFD expansion can’t still trip MAX_ARG_STRLEN after the lister cut.
  • Softened the omarchy-menu-file comments to describe the path-byte budget as a valid-UTF-8 first cut; encoded size is owned in select.

Ordinary UTF-8 libraries stay covered by the lister; legacy/control-heavy names fail closed with a clear select error instead of Argument list too long.

@llstrk

llstrk commented Sep 24, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the previous review and the author reply, checked at cbb7a789.

Earlier finding Status at cbb7a789
Escaped and invalid UTF-8 bytes grow past the limit after awk Resolved for quotes, backslashes and control bytes. Still present for invalid UTF-8 in a UTF-8 locale (see below)
500-file cap is not a byte limit Still present, narrower: now only through the invalid UTF-8 route
Code comment and PR description overstate the protection Still present: the new comment says the growth "is enforced in omarchy-menu-select"
Budget counts characters, not bytes, in a UTF-8 locale (awk) Resolved earlier; unchanged
Only the newest 500 or fewer files are eligible Resolved earlier in the PR description
Test expected $real/clip.webm Resolved earlier; the test still passes

Verified: The new check in omarchy-menu-select rejects oversized options from quotes, backslashes and control bytes with options payload too large (exit 1) in every locale tested, instead of the earlier Argument list too long. Ordinary menus produce payloads identical to f9c706e3, the omarchy-menu-file listing is byte-identical, and the PR's test passes at this head and still fails against the base omarchy-menu-file.

The new size check counts characters, not bytes, in a UTF-8 locale

omarchy-menu-select:80 measures options_json_bytes=${#options_json}. Bash documents ${#parameter} as the length in characters, so under a UTF-8 locale it counts code points. encode_json writes U+FFFD (3 bytes) and other non-ASCII text as raw UTF-8, so the check undercounts exactly the invalid UTF-8 growth it was added to catch. This is the same character/byte distinction as the earlier awk finding, one step later.

Isolated runs at cbb7a789 with the real omarchy-menu-file and omarchy-menu-select, synthetic file names:

case (entries kept)                     JSON bytes  counted in UTF-8  C.UTF-8 and en_US.UTF-8       LC_ALL=C
long CP1251 names (414)                    204,931            80,731  Argument list too long (126)  rejected (exit 1)
ASCII names in a CP1251 folder (321)       208,972            80,572  Argument list too long (126)  rejected (exit 1)
60 CJK chars + 40 control bytes (304)      141,361           104,881  Argument list too long (126)  rejected (exit 1)
120 quotes/backslashes per name (493)      140,013           140,013  rejected (exit 1)             rejected (exit 1)

The oversized JSON passes the check and fails at the second Perl call (lines 86 to 97), the same result as at f9c706e3.

Impact: In a UTF-8 locale, listings from omarchy-menu-file without ASCII escape growth count at most about 81,000 characters, so the check cannot trigger on them. Collections with long legacy-encoded names still make omarchy-transcode and omarchy-games-retro-install fail as before, and large lists of non-ASCII options passed directly to omarchy-menu-select are not bounded either. The reply's statement that U+FFFD expansion can no longer trip MAX_ARG_STRLEN holds only under a C locale.

Suggested change: Count bytes, for example options_json_bytes=$(LC_ALL=C; printf '%s' "${#options_json}"). In a disposable copy of this head, that one-line change rejected 500 CP1251 options with exit 1 under both UTF-8 locales, and small menus still opened. Measuring the length inside the first Perl call is an alternative. With either change, the comments in both scripts become accurate. The PR description still says a huge library "cannot blow MAX_ARG_STRLEN" and does not mention the select-side check.

Optional test improvement: The PR's only test replaces omarchy-menu-select with a stub, so the new check has no coverage. A test that stubs omarchy-shell instead and passes invalid UTF-8 options under C.UTF-8 would fail at this head (exit 126) and pass with the change above (exit 1).

Note on the new error: The message goes to stderr only. omarchy-transcode is started from the menu and SUPER + CTRL + PERIOD, and omarchy-games-retro-install from the menu, both without a terminal. When the check triggers, no picker and no message appear, and omarchy-games-retro-install exits 0 through || exit 0. The "clear select error" described in the reply is visible only when run from a terminal.

Note on the 120,000 limit: Lists whose encoded JSON is between 120,001 and about 130,900 bytes used to open and are now rejected. For example, 500 direct ASCII options with a 125,164-byte payload opened at f9c706e3 and exit 1 at this head. Through omarchy-menu-file this needs heavily escaped names. The in-tree menus checked are far below this range.


Review information

Test scope: Follow-up at cbb7a789, compared with f9c706e3. Isolated command-only runs used the real omarchy-menu-file and omarchy-menu-select, synthetic file names, the C.UTF-8, en_US.UTF-8 and C locales, and a stub in place of the shell IPC hop that receives the real payload as an argument. The PR's test file ran by itself. Menu rendering, the real IPC transport and the full test suite were not run. The locale of real menu and keybinding launches was not observed: the main finding assumes a UTF-8 LC_CTYPE, which Omarchy's shell environment falls back to. Limits assume 4 KiB pages.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@Bartok9

Bartok9 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — same char-vs-byte issue one layer later. ${#options_json} under UTF-8 LC_CTYPE under-counted the U+FFFD growth the check was meant to catch.

Pushed a fix:

  • Count options JSON with options_json_bytes=$(LC_ALL=C; printf '%s' "${#options_json}") so the 120KB cap is bytes in UTF-8 locales too.
  • Added test/shell.d/menu-select-options-byte-budget-test.sh (invalid UTF-8 options under C.UTF-8 must exit 1 with options payload too large; small menus still pass the budget).

Ordinary UTF-8 libraries were already fine via the lister; legacy-encoded / invalid-UTF-8 heavy lists should now fail closed before Perl hits Argument list too long.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the previous review and the author reply, checked at 073d4985.

Verified: the size check in omarchy-menu-select now counts bytes.

The new test does not detect a return to character counting. A separate question about find -L, not covered by earlier reviews, is raised below.

Earlier finding Status at 073d4985
The new size check counts characters, not bytes, in a UTF-8 locale Resolved
Escaped and invalid UTF-8 bytes grow past the limit after awk Resolved: such listings are now rejected with options payload too large
500-file cap is not a byte limit Resolved: no tested omarchy-menu-file listing reaches Argument list too long
Code comments overstate the protection Resolved
PR description Still present, narrower: it describes only the lister bounds, not the new 120,000-byte cap in the shared omarchy-menu-select or the new test
Error goes to stderr only (note) Still present: code paths unchanged
Lists between 120,001 and about 130,900 JSON bytes now rejected (note) Still present, broader: now also non-ASCII lists passed directly to omarchy-menu-select
Earlier resolved items (awk byte budget, "500 or fewer", symlink test path) Unchanged; the symlink test passes

Verified: options_json_bytes=$(LC_ALL=C; printf '%s' "${#options_json}") equals the byte count in all 16 locale combinations tested (bash 5.3), including LANG, LC_CTYPE and LC_ALL set to UTF-8 locales and bash --posix. The parent shell's locale is unchanged. Isolated runs with the real omarchy-menu-file and omarchy-menu-select and a stub for the shell IPC hop:

listing (entries kept)               JSON bytes  cbb7a789 (C.UTF-8, en_US.UTF-8)  073d4985 (all three locales)
long CP1251 names (370)                186,481   Argument list too long (126)     options payload too large (1)
ASCII names in a CP1251 folder (388)   180,033   Argument list too long (126)     options payload too large (1)
60 CJK chars + 40 control bytes (298)  140,061   Argument list too long (126)     options payload too large (1)
long valid Cyrillic UTF-8 (272)         80,513   opens                            opens

Payloads for ordinary menus (plain lists, stdin input with width and height, icon rows with tabs and CJK text, quotes and backslashes) are identical to cbb7a789 apart from temporary paths. The author's "fail closed before Perl hits Argument list too long" holds for the second Perl call and the IPC hop. Collections over the cap are now rejected outright, not truncated, so the stderr-only note above still applies to them.

Optional test improvement: menu-select-options-byte-budget-test.sh also passes at cbb7a789. Its 80 options of 2,000 invalid bytes are 160,641 characters after encoding, already over 120,000 when counted as characters. With b"\xff"*1400 on line 24, the JSON is 112,641 characters and 336,641 bytes: the test then fails at cbb7a789 (exit 126) and passes at this head. The test still fails at base, so it guards against removing the check entirely.

find -L also follows symlinks inside the roots

-L follows every symlink found during the walk, not only symlinked starting points as the comment at omarchy-menu-file:47-49 describes. find -L has been used since the PR's first commit. Isolated runs with synthetic folders, comparing this head with a copy using -H:

layout inside the roots                      -L (this head)                       -H copy and base
link to an outside folder + outside file     9 entries                            3 entries
Videos/system -> /usr                        27,553 matches, 1.32 s;              not followed, 0.008 s
                                             all 500 entries from /usr
                                             (the fixture's own files were older)
Videos/up -> home folder (loop)              pictures listed twice (11 for 7);    not followed
                                             find reports a loop, exit still 0

sort -rn reads the whole walk before the awk cap, so the cap limits the entries shown, not the time spent walking. The exit status is unaffected: find's errors go to /dev/null and the script returns the menu's status. Omarchy creates ~/Pictures, ~/Videos and ~/Games/roms as real folders, so this needs links created by the user. A linked ROM subfolder is one case where following is arguably wanted.

Impact: For users with symlinks inside their media folders, the picker can list unrelated or duplicated files, and a link to a large tree makes every file-picker open walk that tree. This goes beyond #12665, which is about symlinked starting points.

Suggested change: Use find -H, which follows only the starting points. In the same runs it still listed files under both symlinked roots, which is the #12665 case. If following links inside the roots is intended, stating that in the comment and PR description would make the choice explicit.

Related PRs: #13197 (also by this PR's author) and #13018 address #12665 with find -H, and #7320 also changes this pipeline. All three conflict with this PR at the same lines. #13197 also removes duplicates by device and inode. In runs of this head, overlapping roots (for example Videos -> Pictures) listed each file twice, so 500 entries showed 250 files. -H alone does not change that.


Review information

Test scope: Follow-up at 073d4985, compared with cbb7a789, the first reviewed commit f4a067bd and base. Isolated command-only runs used the real omarchy-menu-file and omarchy-menu-select, synthetic file names and folders, the C.UTF-8, en_US.UTF-8 and C locales, GNU findutils 4.11.0, and a stub in place of the shell IPC hop. The PR's new test ran by itself against this head, cbb7a789 and base. Menu rendering, the real IPC transport, the full test suite, network mounts and the locale of real menu and keybinding launches were not tested. Bash versions older than 5.3 were checked by reading the bash source only.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@Bartok9

Bartok9 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — agreed -L was broader than #12665 (nested links / loops / large foreign trees).

Pushed c623a07:

  • Switched the walk to find -H so only symlink starting points are followed; nested symlinks inside the roots are not.
  • Updated the comment to match.
  • Tightened menu-select-options-byte-budget-test.sh (~1400 invalid bytes × 80) so a return to character-length counting under UTF-8 would fail while byte counting still passes.

On related open PRs (#13197 / #13018 / #7320): happy to close or rebase once maintainers pick a line — this branch is the fuller payload-budget + -H variant; #13197’s device/inode dedupe is still a useful separate follow-up if overlapping roots remain an issue after -H.

@llstrk

llstrk commented Sep 28, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the previous review and the author reply, checked at c623a07a.

Verified: find -H still fixes the symlinked starting point from #12665 and no longer follows symlinks inside the roots. The tightened test now catches a return to character counting. No regressions were found in the changed or shared code.

Earlier finding Status at c623a07a
find -L also follows symlinks inside the roots Resolved
Byte-budget test also passes with character counting (optional test note) Resolved
PR description Resolved: it now describes find -H, the 120,000-byte cap in omarchy-menu-select and the new test
Error goes to stderr only (note) Still present: code paths unchanged
Lists between 120,001 and about 130,900 JSON bytes now rejected (note) Still present: code unchanged
Overlapping roots list each file twice (related PRs note) Still present; the reply leaves #13197's device/inode dedupe to a follow-up if needed. #13197, #13018 and #7320 still conflict at the same lines
Earlier resolved items (byte counting in awk and omarchy-menu-select, escaped and invalid UTF-8, 500-file cap, "500 or fewer", symlink test path) Unchanged; both PR tests pass

Verified: isolated runs with synthetic folders, comparing this head with 073d4985 and base:

layout                                          base       073d4985 (-L)            c623a07a (-H)
real root with nested links                     own file   also follows the links   own file
  (outside folder, file, broken link, up -> ..)            and the loop
root that is a symlink (#12665)                 nothing    listed                   listed
root that is a symlink, with a nested dir link  nothing    both files               own file

Relative, chained and trailing-slash starting points are listed at this head. Broken starting-point links are still rejected with Path not found before find runs. For files under a linked root, the %T@ and %p fields are the same under -H and -L, and %p keeps the link spelling. With synthetic linked Pictures, Videos and Games/roms, omarchy-transcode and omarchy-games-retro-install receive the files at this head and an empty list at base. One trade-off: a linked subfolder inside a root (for example roms/linked -> elsewhere) has its files listed under -L but not under -H, the same as base. The new comment at omarchy-menu-file:47-50 describes this accurately.

The tightened menu-select-options-byte-budget-test.sh fails at cbb7a789 (exit 126, Argument list too long) and passes at this head. It also fails when only the byte-count line is reverted to ${#options_json}. Both PR tests pass at this head and merged onto current quattro. The full test/shell run on that merge fails in the same 14 unrelated files as quattro alone in this sandbox.

Optional test improvement: menu-file-symlink-test.sh passes when find -H is changed back to find -L, so it does not guard the new choice. A nested link inside the linked root that leads to a matching file, asserted absent from the output, would fail under -L and pass under -H. The stub comment on line 20 still says "assert find -L worked".


Review information

Test scope: Follow-up at c623a07a, compared with 073d4985, cbb7a789 and base, and merged onto current quattro. Isolated command-only runs used the real omarchy-menu-file and omarchy-menu-select, synthetic folders and file names, GNU findutils 4.11.0 and bash 5.3, with omarchy-menu-select or the shell IPC hop stubbed. Menu rendering, the real IPC transport, network mounts and the locale of real menu launches were not tested.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@Bartok9

Bartok9 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — optional test note applied.

Pushed f5e9355:

  • menu-file-symlink-test.sh now plants a nested symlink under the linked root and asserts nested.webm is not listed (guards -H vs -L).
  • Stub comment updated to say find -H starting-point behavior.

Residual notes left as-is for now:

No further code changes planned unless a maintainer wants one of those scoped here.

@jandrusk

Copy link
Copy Markdown

Same symlink starting-point bug as #12665. Live omarchy-menu-file still uses plain find (no -H).

Open fixes:

This #12669 also adds an awk entry/byte budget + menu-select changes. Prefer consolidating into #13018/#15140 and closing the extras once one merges.

@Bartok9

Bartok9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Agreed this overlaps #12665 / #13018 / #15140 / #13197. Happy to close #12669 once one of those lands with find -H so the starting-point bug is not left open. The awk entry/byte budget and menu-select changes here can move with whichever PR maintainers keep, or drop if they are out of scope.

@omarchybot omarchybot added bug Something isn't working and removed enhancement New feature or request labels Oct 15, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at f5e9355 by Opus 5.5 in Claude Code, with Codex Medium as a separate second opinion on which of the open fixes for #12665 to bring forward. This is a bug fix, so the enhancement label is now bug. Nothing was run on a worker, because this pull request is not the one being taken forward.

Four open pull requests fix #12665 with find -H: this one, #13018, #13197 and #15140. The oldest fix normally wins, and this one is the oldest. It doesn't win here because the listing caps break menus that work on quattro today.

  • The awk filter in bin/omarchy-menu-file stops at 500 entries or 80,000 path bytes. On quattro, a ROM or video library of 600 short paths is offered in full (a payload of about 16 KB). With this change its 100 oldest files can no longer be picked, and nothing tells the user.
  • The 120,000-byte check added to bin/omarchy-menu-select refuses option lists between that size and the real argument limit, which open today. It also measures only the options, while quattro's payload now carries selected, onChange and the prompt as well, so it doesn't guarantee that the payload fits.

#13018 has the same 500-file cut. #13197 is the oldest fix without one, so it is the one brought forward. It also removes duplicate rows when roots overlap.

The large-library failure the issue also reports (Argument list too long past about 128 KiB) is real, and none of the four fixes it. Both models read it as a separate bug. Choosing between a cap (newest 500, refuse or truncate) and changing how the payload reaches omarchy-shell is a decision about behaviour, so it is left to the maintainer rather than riding along with the symlink fix. The encoded-size check here is the most careful work toward that so far, and it is worth keeping for that follow-up. This branch also currently conflicts with quattro in bin/omarchy-menu-select, where #14433 added --multiple and --selected.

Waiting on the maintainer to choose among the fixes for #12665.

@Bartok9

Bartok9 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Understood — #12669 is not the one to take forward for #12665.

The 500-entry / 80KB caps and the 120KB encoded-options check change behavior that works on quattro today (full short-path libraries, and payloads between that cap and the real argument limit). That should not ride along with the symlink fix. Happy to leave #13197 as the find -H line, including its overlapping-root dedupe.

I will not push more listing-cap changes here. The encoded-size check can be reused later if a maintainer wants the separate large-library (Argument list too long) bug fixed on its own, after the quattro conflict from #14433 (--multiple / --selected) is accounted for. I will close this PR once a maintainer confirms #13197 (or another) is the chosen fix, so #12665 is not left with only this branch.

Expect find -L %p under the symlink start path, and cap listing by
entry count plus total path bytes so select stays under MAX_ARG_STRLEN.
Use LC_ALL=C awk so length() is bytes under UTF-8 LANG, and lower the
path budget to leave headroom for JSON escapes before menu-select.
Enforce an exact options-JSON byte cap in omarchy-menu-select so escape and
invalid-UTF-8 expansion cannot still trip MAX_ARG_STRLEN after the lister
budget. Soften omarchy-menu-file comments to match the valid-UTF-8 first cut.
${#options_json} is characters under UTF-8 LC_CTYPE, so invalid UTF-8
expanded to U+FFFD could still pass the cap and hit MAX_ARG_STRLEN.
Measure with LC_ALL=C and add a shell test for the oversized path.
-H follows symlink starting points (omacom#12665) without walking nested
symlinks found inside media roots. Tighten menu-select byte-budget
test so character-length counting would fail under UTF-8.
Assert a nested symlink inside the linked root is not listed, and fix
the stub comment that still mentioned find -L.
@Bartok9
Bartok9 force-pushed the fix-menu-file-follow-symlinks branch from f5e9355 to ce32b4e Compare October 25, 2026 21:41
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects file browsing and the shared option picker.

The code changes appear sound, but the new test must follow the repository's numeric-comparison rule before merging.

Findings

  1. P2 Numeric checks break repository style ▶

Summary

Fixes omarchy-menu-file when a supplied directory is a symlink.

  • File pickers can read files through symlinked starting folders.
  • The file picker stops oversized option lists before sending them to the menu.

Reviews (1) · Last reviewed commit: "Tighten menu-file symlink test for find ..." · Reviewed by Greptile

# ~337k bytes — fails under a character-length cap, passes with byte counting.
opts=()
i=1
while [[ $i -le 80 ]]; do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Numeric checks break repository style

The new loop uses [[ $i -le 80 ]], and both exit-code checks use [[ $rc -eq 1 ]]. The repository requires (( )) for numeric comparisons. Use while (( i <= 80 )); do and (( rc == 1 )) for those checks. This requirement must be satisfied before merging.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@omarchybot omarchybot removed the bug Something isn't working label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Looked again at ce32b4e by Opus 5.5 in Claude Code, with Codex Medium classifying it separately from the diff alone. This push rebases the branch onto current quattro, so the earlier conflict with #14433 in bin/omarchy-menu-select is gone. The pull request's own changes are the same as at f5e9355: find -H, the 500-entry / 80,000-byte listing cap, the 120,000-byte options check, and the two tests. Nothing was run on a worker.

The two models disagree on what this is, so the bug label has come off until that is settled. I read it as a bug fix, since find -H fixes #12665. Codex Medium read it as an enhancement. The listing cap and the options check deliberately change menus that work on quattro today, and that is what an enhancement covers.

What the earlier review found still holds, because the code it was about hasn't changed. #13197 fixes #12665 with find -H and no listing cap, and it is still open. Choosing between the fixes, and deciding whether to cap the large-library Argument list too long failure or change how the payload is sent, is still the maintainer's call.

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.

omarchy-menu-file returns 0 files when ~/Pictures/~/Videos are symlinks (transcode panel never opens)

4 participants