fix(panels): compile out the git button on web (no git backend)
Some checks failed
Rust check (native) / macos-latest / 1.94 (push) Waiting to run
Rust check (native) / windows-latest / 1.94 (push) Waiting to run
Rust multi-platform build / linux-aarch64 (push) Waiting to run
Rust multi-platform build / macos-aarch64 (push) Waiting to run
Rust multi-platform build / windows-x86_64 (push) Waiting to run
Rust multi-platform build / macos-x86_64 (push) Waiting to run
Rust multi-platform build / windows-aarch64 (push) Waiting to run
Rust multi-platform build / ios-aarch64 (cargo check only) (push) Waiting to run
Rust multi-platform build / ios-aarch64-sim (cargo check only) (push) Waiting to run
Rust check (native) / ubuntu-latest / 1.94 (push) Failing after 3s
Rust check (native) / cargo-deny (native) (push) Failing after 1s
Rust check (native) / diagnostics golden drift (push) Failing after 3s
Rust multi-platform build / linux-x86_64 (push) Failing after 2s
Rust multi-platform build / wasm32-unknown-unknown / op-host-web (compile guard) (push) Failing after 2s
Rust multi-platform build / android-aarch64 (cargo check only) (push) Failing after 1s
Rust multi-platform build / android-x86_64 (cargo check only) (push) Failing after 2s
WASM bundle check (kickoff §1.2) / cargo check --target wasm32-unknown-unknown (push) Failing after 2s
WASM bundle check (kickoff §1.2) / cargo-deny --target wasm32-unknown-unknown check bans (push) Failing after 2s

The web/wasm build has no git backend and never paints GitPanel, so
the top-bar git button toggled an invisible panel (Codex stop-time
review). Gate the button's paint + hit-test on a `GIT_BUTTON_AVAILABLE`
const (`!cfg!(target_arch = "wasm32")`) so it only exists on desktop.
This commit is contained in:
Kayshen-X 2026-05-29 22:23:37 +08:00
parent a4b70fa055
commit 50e95fbf89

View file

@ -32,6 +32,11 @@ const PAD: f32 = 12.0;
const DIVIDER_W: f32 = 1.0;
const DIVIDER_H: f32 = 14.0;
const DIVIDER_GAP: f32 = 4.0;
/// The git button needs a desktop git backend (`op-git` via the
/// desktop host) to populate + paint the panel; the web/wasm build
/// has none, so the button is compiled out there — otherwise it would
/// toggle an invisible panel (Codex stop-time review).
const GIT_BUTTON_AVAILABLE: bool = !cfg!(target_arch = "wasm32");
/// Gap between the stacked per-agent brand icons in the chip.
const AGENT_ICON_GAP: f32 = 4.0;
/// Diameter of a macOS-style window-control dot.
@ -370,8 +375,9 @@ impl TopBar {
if rect_contains(figma_rect, point) {
return Some(TopBarHit::OpenFigmaImport);
}
// Git-panel toggle, just right of the centred file name.
if rect_contains(self.git_button_rect(rect), point) {
// Git-panel toggle, just right of the centred file name
// (desktop only — see `GIT_BUTTON_AVAILABLE`).
if GIT_BUTTON_AVAILABLE && rect_contains(self.git_button_rect(rect), point) {
return Some(TopBarHit::ToggleGitPanel);
}
// Right cluster: Maximize / Sun / Globe-with-chevron (right→left).
@ -587,30 +593,33 @@ impl Widget for TopBar {
);
// Git-panel button just right of the file name (TS GitButton):
// a branch glyph + optional branch name. Always shown — a
// click toggles the git panel (which offers `init` when the
// doc isn't yet in a repo).
let git_rect = self.git_button_rect(rect);
draw_icon(
cx.backend,
Icon::GitBranch,
Point2D::new(git_rect.origin.x, glyph_top(center_y, ICON_SIZE)),
ICON_SIZE,
self.theme.muted_foreground,
1.4,
);
if let Some(branch) = self.git_branch.as_deref() {
let label = TextLayout::single_run(
branch,
"system-ui",
11.0,
to_jian_color(self.theme.muted_foreground),
Point2D::new(0.0, 0.0),
);
cx.backend.draw_text(
&label,
Point2D::new(git_rect.origin.x + ICON_SIZE + 6.0, center_y + 4.0),
// a branch glyph + optional branch name. Always shown on
// desktop — a click toggles the git panel (which offers `init`
// when the doc isn't yet in a repo). Compiled out on web,
// which has no git backend to paint a panel.
if GIT_BUTTON_AVAILABLE {
let git_rect = self.git_button_rect(rect);
draw_icon(
cx.backend,
Icon::GitBranch,
Point2D::new(git_rect.origin.x, glyph_top(center_y, ICON_SIZE)),
ICON_SIZE,
self.theme.muted_foreground,
1.4,
);
if let Some(branch) = self.git_branch.as_deref() {
let label = TextLayout::single_run(
branch,
"system-ui",
11.0,
to_jian_color(self.theme.muted_foreground),
Point2D::new(0.0, 0.0),
);
cx.backend.draw_text(
&label,
Point2D::new(git_rect.origin.x + ICON_SIZE + 6.0, center_y + 4.0),
);
}
}
// ── Right cluster ──────────────────────────────────────