fix: refresh host colors before focus returns - #2017
Conversation
📝 WalkthroughWalkthroughHost terminal theme querying now uses an atomic generation counter shared between the client loop and stdin reader. Unix input framing re-arms when the generation changes, and outer focus loss now triggers theme queries. ChangesHost theme query coordination
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ClientLoop
participant ThemeQuery
participant Generation
participant StdinReader
participant RawInputFramer
ClientLoop->>ThemeQuery: request host terminal theme
ThemeQuery->>Generation: increment generation
ThemeQuery->>StdinReader: shared generation becomes observable
StdinReader->>RawInputFramer: re-arm query framing
RawInputFramer-->>StdinReader: forward re-sent query response
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
Greptile SummaryRefresh host OSC 10/11/palette colors when outer focus is lost, and re-arm fragmented host-color reply framing via a generation counter shared with the stdin reader.
Confidence Score: 5/5This PR appears safe to merge; the focus-loss theme refresh and generation-based framer re-arm match the stated stale-color fix without a concrete blocking defect in the changed path. Generation is observed and the framer is re-armed immediately before push on the same read that delivers replies; complete OSC color sequences parse without relying on lone-ESC hold; OuterFocusLost querying is covered by tests and aligns with refreshing colors before return focus.
|
| Filename | Overview |
|---|---|
| src/client/input.rs | Replaces one-shot host_color_query_sent bool with generation sync so later theme queries re-arm lone-ESC holding and scheme-change tracking before push. |
| src/client/mod.rs | Shares AtomicU64 generation with the stdin thread and increments it on each host theme query (startup and event-driven). |
| src/raw_input.rs | OuterFocusLost now requests a host theme re-query; tests assert focus-gain does not and focus-loss does. |
Reviews (1): Last reviewed commit: "fix: refresh host colors before focus re..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/client/input.rs (1)
133-146: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffMove Unix-specific framing coordination behind
src/platform/.This new Unix-only helper extends platform behavior in
src/client/input.rs; keep the platform adapter here generic and isolate the Unix implementation undersrc/platform/.As per coding guidelines, “Keep core modules free of
#[cfg(target_os)]; isolate platform checks and behavior undersrc/platform/.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ace6ae8e-2c06-43c0-ad6b-b8723831d216
📒 Files selected for processing (3)
src/client/input.rssrc/client/mod.rssrc/raw_input.rs
ogulcancelik
left a comment
There was a problem hiding this comment.
this queries on focus loss, before the appearance changes. wezterm does not emit csi 2031 notifications, so please query on focus gain instead and add a regression test for loss → appearance change → gain.
Summary
Reproduction
On macOS with WezTerm, switch system appearance while Herdr is unfocused, then return to a Codex pane. The composer can retain stale host colors and render its background and text with insufficient contrast.
Verification
cargo test later_host_color_query_rearms_split_reply_framingcargo test outer_focus_loss_requests_host_theme_queryZIG=/opt/homebrew/opt/zig@0.15/bin/zig just ci 'all() - test(live_handoff_keeps_unmanaged_agent_name_bound_to_saved_session)'ZIG=/opt/homebrew/opt/zig@0.15/bin/zig just windows-lintlive_handoff_keeps_unmanaged_agent_name_bound_to_saved_sessionfails on this macOS host withagent_not_found; the identical failure reproduces from a detached, pristine upstreammasterworktree.