Skip to content

fix: Set a UTF-8 locale for the quick actions; open search results in TextEdit - #31

Merged
a1594834522-coder merged 1 commit into
memorylake-ai:mainfrom
a1594834522-coder:fix/quick-actions-locale
Sep 14, 2026
Merged

a1594834522-coder merged 1 commit into
memorylake-ai:mainfrom
a1594834522-coder:fix/quick-actions-locale

Conversation

@a1594834522-coder

Copy link
Copy Markdown
Contributor

Summary

Two problems found on the first day of real use of the macOS quick actions (#30). Every string in the search dialog rendered as mojibake on a Chinese-language Mac: services run with no locale variables, zsh therefore slices by byte, ${query:0:60} could cut a character in half, and osascript reacts to one invalid byte by decoding the whole script text in the system legacy encoding (GB18030). The generated config.sh now exports LANG=en_US.UTF-8 when nothing is set. And the dialog was the wrong control for results — display dialog text cannot be selected, so copying one line meant the "copy everything" button. Results now open as a text file in TextEdit, where any part can be selected and ⌘W dismisses it.

Changes

  • scripts/install-macos-quick-actions.sh: the generated config.sh exports a UTF-8 LANG when the environment has none, with a comment on why; the two button strings are gone from the message tables.
  • scripts/quick-actions/search.sh: writes the results to ~/Library/Caches/memorylake-quick-actions/search-<timestamp>.txt (header: query and time) and opens it with open -e; files older than a day are deleted on the next search.

Test plan

  • Reproduced: env -i shell with __CF_USER_TEXT_ENCODING=…:0x19:… and a byte-truncated Chinese string → osascript renders the whole script as GB18030 mojibake; with LANG=en_US.UTF-8 zsh slices by character and the output is correct
  • Reinstalled from a checkout; config.sh carries the export
  • ⌃⌥⌘L from a Chinese-language account via the real service: TextEdit opens with correct Chinese, individual lines selectable
  • Same run under env -i HOME PATH __CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34 (the service's environment) with a 40-character Chinese query
  • shellcheck -s sh clean

🤖 Generated with Claude Code

… TextEdit

Services run with no locale variables at all. Without one zsh slices strings
by byte, so the `${query:0:60}` in the search action could cut a character
in half. osascript then decodes the whole dialog script in the system legacy
encoding — GB18030 on a Chinese Mac — and every string in the dialog,
buttons included, shows as mojibake. The generated config.sh now exports
LANG=en_US.UTF-8 when nothing is set.

The results dialog itself was the wrong control: display dialog text cannot
be selected, so copying one line meant copying all of them with the button.
The results are now written to a text file under
~/Library/Caches/memorylake-quick-actions and opened in TextEdit, where any
part can be selected; files older than a day are removed on the next search.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@a1594834522-coder
a1594834522-coder merged commit 960b17e into memorylake-ai:main Sep 14, 2026
5 of 6 checks passed
a1594834522-coder added a commit that referenced this pull request Sep 14, 2026
## Summary

Follow-up to #31, which opens search results in TextEdit from a text
file. That file was written under
`~/Library/Caches/memorylake-quick-actions` and kept for a day, leaving
a small but real residue on the user's disk. It now goes to the per-user
temp dir macOS provides, which the system purges on reboot and after
three idle days, and the action deletes anything older than an hour on
the next search. The dir is resolved with `getconf DARWIN_USER_TEMP_DIR`
rather than `$TMPDIR`, because services run with an empty environment
where `$TMPDIR` is unset and the fallback would have been the shared
`/tmp`.

## Changes

- **`scripts/quick-actions/search.sh`**: results file lives in
`$(getconf DARWIN_USER_TEMP_DIR)memorylake-quick-actions/`; cleanup
threshold one hour instead of one day.

## Test plan

- [x] `env -i HOME PATH __CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34` (the
service's environment, no `TMPDIR`) → file lands under
`/var/folders/…/T/memorylake-quick-actions/`, TextEdit opens it with
correct Chinese
- [x] Reinstalled from a checkout; ⌃⌥⌘L via the real service produces
the same
- [x] `zsh -n` clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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