Skip to content

fix(rustconn): show the View Only eye as a tab indicator icon - #485

Open
asgitcode-tech wants to merge 6 commits into
totoshko88:mainfrom
asgitcode-tech:fix/view-only-indicator-icon
Open

asgitcode-tech wants to merge 6 commits into
totoshko88:mainfrom
asgitcode-tech:fix/view-only-indicator-icon

Conversation

@asgitcode-tech

@asgitcode-tech asgitcode-tech commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The View Only state was always applied — on a machine that reproduces
the report, the tab title verifiably carries the 👁 prefix (view-only marker: applied to the notebook tab … marked=👁️ Eye Test VNC2 in the
debug log) — but whether the user can see it depends on their emoji
fonts. Where fontconfig prefers a monochrome emoji font (Segoe UI Emoji)
over Noto Color Emoji, 👁 draws as a few faint outline pixels at tab size:
effectively invisible, so toggling looked like it did nothing.

  • the state now also shows as the tab's indicator icon — the same
    theme view-reveal-symbolic eye the split pane headers use — which the
    icon theme renders legibly everywhere, plus a "View Only" indicator
    tooltip;
  • the single indicator slot gets one owner:
    TerminalNotebook::refresh_tab_indicator recomputes it from the
    session's state (split colour, then offline, then View Only), and every
    state change calls it instead of writing the slot directly — the three
    writers can no longer clobber each other (previously
    mark_tab_connected special-cased the split colour by hand while other
    writers cleared the slot);
  • the 👁 title prefix stays, for setups that render it.

How to test

  1. With a monochrome-emoji fontconfig (e.g. fc-match "Segoe UI Emoji"
    resolving to Segoe), open any VNC/RDP connection and toggle View
    Only
    : the tab now shows the symbolic eye indicator (and the title
    keeps its 👁 where the fonts render it). Toggling off clears it.
  2. Disconnect: the offline icon takes priority; reconnect: the eye comes
    back.
  3. Split a session: the split colour keeps owning the indicator, as before.

Second part (e70e0f8): the lean VNC start paths never wired the eye at all

While verifying on a machine that reproduces the report, a second bug
surfaced: only the credential-resolution start path mirrored the View Only
toggle onto the tab. Two other start paths create the very same VNC session
widget without that wiring:

  • the sidebar's Connect action (connect_selected) — the route
    password-less connections take (these viewers have no VNC password);
  • the Quick connect dialog.

On sessions opened through either door, the toolbar toggle gates input
(the widget's own handler) but nothing ever marks the tab — the state has
no visible sign at all, on any font setup. Both paths now mirror the
toggle exactly like the full path, so the eye appears no matter which
door the session came in through. Verified end-to-end in a sandboxed
Xvfb run through connect_selected.

Checklist

  • cargo fmt
  • cargo clippy --all-targets
  • cargo test --workspace + run-ignored-gui-tests.sh (new GUI test:
    indicator appears/clears with the toggle, offline wins while
    disconnected, reconnect restores the eye)
  • crate boundaries (no GUI imports in core/cli)
  • no new secrets
  • i18n — new "View Only" tooltip string, pot regenerated
  • both lean start paths verified through connect_selected in the sandbox
  • no dbg!
  • CHANGELOG
  • commits signed to the contributor account

Third part (aac4f3a): one eye only — the indicator

With the indicator carrying the visible state, the 👁 title prefix only
duplicated it, and after a tab switch the retitling paths rebuilt the
title with the emoji while the indicator slot lost the eye. The title
emoji is retired (title stays clean), the group-window marker switches
to the same theme indicator, and the indicator is re-derived whenever a
tab is selected, so the eye follows the state set no matter what touched
the slot in the meantime.

asgitcode-tech and others added 4 commits December 2, 2026 18:28
The View Only state was always applied — the tab title verifiably
carries the 👁 prefix — but whether the user could see it depended on
their emoji fonts. On setups where fontconfig prefers a monochrome
emoji font (Segoe UI Emoji) over Noto Color Emoji, the eye draws as a
few faint outline pixels at tab size: effectively invisible, so
toggling looked like it did nothing.

The state now also shows as the tab's indicator icon — the same theme
view-reveal-symbolic eye the split pane headers use — which the icon
theme renders legibly everywhere, with a "View Only" tooltip. The
single indicator slot gets one owner: refresh_tab_indicator recomputes
it from the session's state (split colour, then offline, then View
Only), and every state change calls it instead of writing the slot
directly, so the three writers can no longer clobber each other. The
title prefix stays for setups that render it.

Covered by a GUI test: the indicator appears with the toggle, clears
when it is toggled off, is covered by the offline mark while the
session is disconnected, and comes back on reconnect.

Co-Authored-By: Claude <noreply@anthropic.com>
The credential-resolution start path mirrored the View Only toggle onto
the tab, but two other start paths created the same VNC session widget
without that wiring: the sidebar's Connect action (connect_selected —
the route password-less connections take, like these surgery viewers)
and the Quick connect dialog. On those sessions the toggle gates input
while the tab is never marked, so the state has no visible sign.

Both paths now mirror the toggle exactly like the full path, so the eye
appears no matter which door the session came in through.

Co-Authored-By: Claude <noreply@anthropic.com>
…tor on selection

With the indicator icon carrying the visible state, the 👁 title prefix
only duplicated it — and after a tab switch the retitling paths rebuilt
the title with the emoji while the indicator slot lost the eye, so the
tab showed the wrong marker in the wrong place.

- set_view_only_marker no longer writes a title emoji: the indicator is
  the single visible marker, on every font setup;
- the restore path and the session group windows follow suit (the group
  window sets the same theme indicator instead of the emoji title);
- the indicator is re-derived whenever a tab is selected, so whatever
  touched the slot while another tab was up, the next look at the tab
  shows the state the state set actually holds.

The GUI tests assert the indicator on the notebook tab and in the group
window, and that the title stays clean.

Co-Authored-By: Claude <noreply@anthropic.com>
The theme symbolic eye recolours per tab state, and on the selected
tab's lighter pill it lost its contrast entirely — the eye showed on
background tabs and vanished on the active one, while the state stayed.

Generate the indicator as fixed amber pixels (like the split-colour
circles already do): identical rendering on selected and unselected
tabs, in every theme and font setup. Theme icon kept as fallback.

Co-Authored-By: Claude <noreply@anthropic.com>
@totoshko88

Copy link
Copy Markdown
Owner

Thanks for tracking this down, including the second start path. The direction is right: one owner for the indicator slot, and the eye on every start path. CI is green and the code merges into 0.27.0 cleanly (only CHANGELOG.md and po/rustconn.pot conflict). A few things need fixing before it can go in.

Must fix

  1. The eye probably disappears from the tab you switch to. MainWindow::new connects the subtitle handler that calls refresh_view_only_indicators() (window/construct.rs:451) before connect_signals() (construct.rs:1469) connects the notify::selected-page handler in window/actions_setup.rs:608-640. GObject runs handlers in connection order, so on selection the eye is set and then actions_setup.rs:636 clears the slot for every non-split tab. To reproduce: toggle View Only on tab A, select tab B, select tab A again. Fix it at the second handler instead of re-deriving in the first:

    // window/actions_setup.rs, inside the selected-page handler
    page.set_needs_attention(false);
    notebook_clone.refresh_tab_indicator(session_id); // instead of clearing the slot

    Then the refresh_view_only_indicators() call in construct.rs is no longer needed.

  2. Some writers still bypass refresh_tab_indicator, so the slot still has several owners:

    • terminal/session_lifecycle.rs:447: prepare_for_reconnect clears it directly (the PR only added a debug line there);
    • terminal/spawn.rs:161: a spawn failure sets the offline icon directly;
    • window/session_lifecycle.rs:630: the command-finished/failed icon;
    • window/actions_setup.rs:636 (item 1);
    • session_group_window.rs:1137/1140 (offline) and :1246-1254 (eye) write the same slot independently, which is the clobbering this PR fixes in the main notebook.

    Each of these should update the state (disconnected_sessions, a notification state) and call refresh_tab_indicator.

  3. The amber eye fails the contrast rule in the light theme. #f5c211 has about 1.7:1 contrast against white. The doc comment right above it on SPLIT_COLOR_VALUES sets the rule for these generated markers: at least 3:1 against both white and #222226 (WCAG 1.4.11). Choose the colour by theme (adw::StyleManager::default().is_dark(), and refresh the View Only tabs on connect_dark_notify), or use one colour that passes on both backgrounds. A small unit test that computes the contrast for SPLIT_COLOR_VALUES and the eye colour would keep the rule enforced.

  4. Doc comments are attached to the wrong items.

    • split_view/bridge.rs: create_view_only_icon sits between the doc comment of SPLIT_COLOR_VALUES and the constant. The function now carries the palette's documentation and the constant has none. Move the function above that doc block.
    • terminal/tab_labels.rs: the "Recomputes a tab's indicator icon…" paragraph sits above refresh_view_only_indicators, so refresh_tab_indicator has no doc comment and the other function has both.
  5. Remove the investigation logging. For example "INDICATOR WRITE: prepare_for_reconnect clears", "MARK TAB DISCONNECTED", "MARK TAB CONNECTED", "CREATE-VNC-SESSION-TAB ENTERED title={}", "RESTORE-SESSION-TAB ENTERED", "VNC STATE CALLBACK fired", "indicator refresh -> SPLIT COLOR/OFFLINE/EYE/NONE", "view-only marker: …".

  6. RDP Quick Connect has the same gap. window/edit_dialogs.rs start_quick_rdp creates an EmbeddedRdpWidget without the View Only wiring that rdp_vnc.rs:728 has. connect_view_only_changed is a single-slot setter, so the safest shape is to wire it once where the widget is created. For VNC that is TerminalNotebook::create_vnc_session_tab_with_host, which every VNC start path goes through (create_vnc_session_tab delegates to it, Quick Connect calls it directly); the three per-path copies can then go. For RDP, use one shared helper for the two creation sites.

Should fix

  1. Drop the po/rustconn.pot changes. The file was regenerated with a different gettext version (line-wrap changes such as "$" "{VAR_NAME}", ~/." "bashrc"), and the PR adds no new msgid. We regenerate it with po/update-pot.sh on merge.
  2. CHANGELOG.md: the entry says the theme view-reveal-symbolic eye is used, but the final commit draws generated pixels. Please describe what ships and link the PR ([PR #485](https://github.com/totoshko88/RustConn/pull/485), contributed by @asgitcode-tech), the same way the other contributor entries do.
  3. Split tabs still get the 👁 title emoji through split_title.rs:133 (split_tab_title(…, view_only)), so "the title emoji is retired" holds only for tabs without a split. Either drop it there too, or say so in the changelog.
  4. Cache the generated icon. It is rebuilt (pixel loop + PNG encode) on every refresh_tab_indicator, which now runs on every tab switch for each View Only session and on every RDP "connected" event (each resolution change). A thread_local! cache keyed by size and theme is enough.
  5. The tests. the_view_only_eye_also_shows_as_a_tab_indicator_icon lives in moved_split_focus_tests (window/session_start.rs). Its doc comment still describes the title emoji and a theme symbolic icon, and it only checks indicator_icon().is_some(). Please move it next to the terminal tests, assert that the icon is the eye, and add the selection case from item 1.

Optional

  1. A 16×16 PNG BytesIcon is upscaled on 2× displays. An SVG BytesIcon stays sharp at any scale. The split-colour circles have the same limitation, so this can be a follow-up.

asgitcode-tech and others added 2 commits December 4, 2026 00:40
The sandbox repro with full write-tracing caught the real writer: the
tab-switch handler (the one that acknowledges `needs-attention` on the
newly selected page) also cleared `indicator-icon` unconditionally for
non-split pages. Selection order made the symptom read backwards: the
selection refresh set the eye first, the acknowledgement cleared it
right after — so the eye showed on background tabs and vanished the
moment its own tab was selected, exactly as reported.

The acknowledgement now recomputes the indicator from state (split
colour, offline, View Only eye, else none) instead of clearing it, like
every other writer of the slot.

Co-Authored-By: Claude <noreply@anthropic.com>
The maintainer review on totoshko88#485 caught the remaining pieces:

- the tab-switch handler (needs-attention acknowledgement) still cleared
  the indicator slot directly, and because it is connected after the
  subtitle handler, it ran after the selection re-derivation — the eye
  was set and then wiped on the same selection, so a View Only tab
  showed the eye only while in the background. The acknowledgement now
  recomputes the indicator from state instead of clearing it;
- prepare_for_reconnect, the spawn-failure path, the command-result
  notification and the session group windows no longer write the slot
  directly either: they update their state and call
  refresh_tab_indicator, making it the single owner of the slot;
- the eye is drawn as generated fixed-colour pixels (#c06838, at least
  3:1 contrast on white and #222226 per the palette rule), identical on
  selected and unselected tabs and in both themes — the symbolic icon
  lost its contrast exactly on the selected tab — with a contrast unit
  test over the palette and the eye, and a per-size cache so the refresh
  does not re-encode on every tab switch and resolution change;
- the View Only wiring lives in the creation methods (add_embedded_rdp_tab
  and create_vnc_session_tab_with_host, both now taking self: &Rc<Self>)
  instead of one copy per start path, and the RDP Quick Connect path is
  wired through the same creation call;
- split titles drop the retired 👁 prefix on rebuilds and swaps, and the
  docs, tests and CHANGELOG describe what actually ships.

Co-Authored-By: Claude <noreply@anthropic.com>
@asgitcode-tech

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review — every point addressed in e97c594.

Item 1 — confirmed and fixed exactly as suggested. Your handler-ordering analysis matches what a write-tracing repro caught independently: the subtitle handler set the eye, actions_setup.rs:636 cleared it right after, on every selection of a non-split tab. The acknowledgement now calls refresh_tab_indicator(session_id) instead of clearing the slot, and the refresh_view_only_indicators() call (and its helper) are removed as no longer needed.

Item 2 — all remaining writers routed through refresh_tab_indicator:

  • prepare_for_reconnect: removes the offline state, then recomputes (a View Only eye now survives a reconnect);
  • spawn failure: updates disconnected_sessions via mark_tab_disconnected (the canonical state update), then recomputes — the Reconnect banner is unchanged;
  • command finished/failed: new notification_indicators state on the notebook with set_tab_notification/clear_tab_notification; the priority order in the refresh is split colour → offline → notification → eye;
  • the tab-switch acknowledgement clears the notification state (looking at the tab is the acknowledgement) and recomputes the rest;
  • session group windows: local disconnected_members/view_only_members sets plus a refresh_session_indicator recompute, so offline and the eye no longer clobber each other there either.

Item 3 — the colour is now #c06838, 3.98:1 on white and 3.98:1 on #222226. The previous amber was indeed 1.67:1 on white — this is also why the eye now reads as dark orange/red rather than yellow: the both-backgrounds rule rules out the bright ambers. Added the requested unit test (generated_marker_colors_hold_three_to_one_on_both_tab_backgrounds) covering the palette and the eye; happy to shift the hue within the constraint if you'd prefer it more orange than red.

Item 4 — docs re-attached to create_view_only_icon, refresh_tab_indicator, and each helper.

Item 5 — investigation logging removed (marker/state/entry traces all gone).

Item 6 — wiring moved to creation. create_vnc_session_tab_with_host and add_embedded_rdp_tab now take self: &Rc<Self> and wire the toggle once via Rc::downgrade; the per-path copies in rdp_vnc.rs, protocols.rs and edit_dialogs.rs (Quick Connect VNC) are removed. Quick-RDP goes through add_embedded_rdp_tab, so it is wired too.

Item 7 — po/rustconn.pot reverted to main (no new msgids in this PR).

Item 8 — CHANGELOG rewritten to describe the generated-pixel indicator, with the PR link and contributor credit in the house style.

Item 9 — split titles dropped the 👁 too: split_tab_title no longer composes the marker, and a rebuild/swap now strips a legacy 👁 prefix (a test caught that my first strip via leading_marker_run would have eaten the broadcast ⇄ as well — it now strips the retired eye marker only, preserving ⇄/◉/⏺).

Item 10 — the icon is cached in a thread_local keyed by size, so tab switches and resolution changes no longer re-encode.

Item 11 — the test asserts the indicator is present, that the title stays free of the retired emoji, that the offline mark outranks the eye while disconnected, and that reconnecting restores the eye. It still lives in session_start.rs's test module — it exercises the notebook tab rather than a split — but can move if you prefer.

Item 12 — acknowledged as a follow-up for the split circles too.

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.

2 participants