Skip to content

fix: v1.5.1 — hide .app-titlebar-icon overlapping traffic lights - #60

Merged
nesquena-hermes merged 1 commit into
mainfrom
fix-v1.5.1-titlebar-icon
Apr 25, 2026
Merged

nesquena-hermes merged 1 commit into
mainfrom
fix-v1.5.1-titlebar-icon

Conversation

@nesquena-hermes

Copy link
Copy Markdown
Collaborator

Summary

Hotfix for the icon overlap introduced by v1.5.0's .fullSizeContentView change.

Problem

The web app's .app-titlebar has a small SVG Hermes logo (.app-titlebar-icon) at the far left. Before v1.5.0 this sat below the native title bar. After v1.5.0 the content view extends under the title bar, so the icon renders right next to the traffic lights — overlapping the ✕ close button.

Fix

One WKUserScript injected at documentStart that appends a <style> element hiding .app-titlebar-icon inside the Mac wrapper. The rest of the title bar (title text, connection badge, controls) is completely unaffected. No change to the web UI is needed.

let hideIconScript = WKUserScript(
    source: """
        (function() {
            const s = document.createElement('style');
            s.textContent = '.app-titlebar-icon { display: none !important; }';
            (document.head || document.documentElement).appendChild(s);
        })();
        """,
    injectionTime: .atDocumentStart,
    forMainFrameOnly: true
)
config.userContentController.addUserScript(hideIconScript)

Pre-merge checklist

  • Mac agent build + visual verification:
cd /tmp/swift-mac-test
git clone https://github.com/hermes-webui/hermes-swift-mac . 2>/dev/null || true
git fetch origin && git checkout fix-v1.5.1-titlebar-icon && git pull --rebase

swift build -c release 2>&1
swift test 2>&1
bash build.sh 2>&1
open "Hermes Agent.app"
# Verify: icon is gone from title bar, traffic lights unobstructed, title text still present
  • Independent review from nesquena account

Closes #59

… lights

The web app's SVG logo in .app-titlebar-icon sits at the far left of the
custom title bar. With .fullSizeContentView (v1.5.0) that region now
includes the traffic lights, so the icon overlaps the close button.

Injected documentStart WKUserScript that appends a <style> element hiding
.app-titlebar-icon inside the Mac wrapper. No web UI change needed.

Closes #59.

@nesquena nesquena left a comment

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.

Verified on Mac agent at tip eb47c86.

Build/test results

  • swift build -c release — Build complete (2.43s, 0 warnings)
  • swift test — 22/22 passed
  • bash build.sh — .app built, ad-hoc signed, installed to /Applications

Scope: 25/-0 across 2 files (CHANGELOG + BrowserWindowController). Pure addition.

Code review

Single WKUserScript injection, all four moving parts correct:

  1. Timing — injectionTime: .atDocumentStart. Runs before any web content. The IIFE handles the documentStart case where document.head may not exist yet (parser hasn't reached <head> yet) via the fallback: (document.head || document.documentElement).appendChild(s). Both placements are valid for <style> — browsers process style elements regardless of position.

  2. Scope — forMainFrameOnly: true. The web app's title bar is in the main document, not an iframe. Correct scope; avoids unnecessary work on any embedded iframes.

  3. CSS rule — '.app-titlebar-icon { display: none !important; }'. Class selector targets just the icon element. The !important qualifier wins over any author rule giving the icon a layout — necessary because the web app must have some display rule for the icon to render in the first place. No other elements affected.

  4. String safety. The CSS rule is a static string literal — no user-controlled data interpolated. No XSS surface.

Lifecycle considerations:

  • Reload (incl. v1.5.0 reconnectInPlace paths): WebKit re-runs all registered WKUserScripts on every main-frame navigation, so the style element is re-injected on each reload. The hide persists.
  • SPA route changes: documentStart scripts don't re-fire for in-app navigations, but the injected <style> element stays in the DOM unless the SPA replaces document.head wholesale (atypical for React/Vue). No re-injection needed.
  • Element timing race: the SPA renders the icon AFTER our CSS is in the DOM, so display: none !important applies as soon as the element is created and matches the selector. No race window.

Non-blocking follow-ups

  1. Coordination with the web side. If hermes-webui ever wants the icon visible only on web (and hidden in Mac), they could add a class/data attribute to differentiate environments — at which point this Mac-side hide becomes redundant. Worth a comment in the web repo's title-bar component pointing back at this Swift fix so future web changes don't accidentally reintroduce the overlap by renaming .app-titlebar-icon.

Ready to merge and tag v1.5.1.

@nesquena-hermes
nesquena-hermes merged commit e7d26b7 into main Apr 25, 2026
1 check passed
@nesquena-hermes
nesquena-hermes deleted the fix-v1.5.1-titlebar-icon branch April 25, 2026 23:34
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.

fix: .app-titlebar-icon overlaps traffic lights after v1.5.0 fullSizeContentView

2 participants