fix(grid): accept OSC 7 from every hostname the machine has gone by - #84
Conversation
The OSC 7 host gate cached gethostname(2) once per process, but macOS rewrites the hostname on every network change (DHCP reverse-DNS name online, <name>.local offline) while a shell's $HOST is frozen at its own startup. After a change every cwd report was rejected as non-local, so Terminal.cwd stayed None and new tabs, splits, and the scratch terminal no longer inherited the focused shell's directory. Re-query on each OSC 7 and match against a bounded set of every name observed during the process lifetime, so shells started before and after a change both pass. Claude-Session: https://claude.ai/code/session_01YTGJ217L3Zc1eZAGeyftpm
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae1a183901
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mut observed = OBSERVED | ||
| .lock() | ||
| .unwrap_or_else(|poisoned| poisoned.into_inner()); | ||
| if !observed.contains(¤t) { |
There was a problem hiding this comment.
Refresh re-observed hostnames before eviction
When hostname changes follow A, B, …, H, A, I, reconnecting to A leaves it at the front because contains does not refresh its position. Observing I then evicts A, so a shell started during the second A period has its OSC 7 updates rejected immediately after the next network change, recreating the regression this cache is intended to prevent. Move a re-observed entry to the back before applying the bounded eviction policy.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 25c8d23: a re-observed name is moved to the back before eviction (LRU).
Summary
host_is_local) cachedgethostname(2)once per process, but macOS rewrites the hostname on every network change (DHCP reverse-DNS name online,<name>.localoffline) while a shell's$HOSTis frozen at its own startup. After a change every cwd report was rejected as non-local, soTerminal.cwdstayedNone.Test plan
cargo test -p noa-grid(632 passed) incl. newhostname_matches_any_local_accepts_names_the_machine_went_by_earliercargo clippy --workspace— no new warningscdsomewhere and ⌘T opens the new tab in that directoryhttps://claude.ai/code/session_01YTGJ217L3Zc1eZAGeyftpm