Repository navigation
fix(app): restore titlebar toggle visual contract after PR #878 #880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c989a92
fix(app): restore titlebar toggle visual contract after PR #878
Astro-Han 412d706
fix(app): drop selected-tab chip on right-panel sidepanel tabs
Astro-Han 5844733
Revert "fix(app): drop selected-tab chip on right-panel sidepanel tabs"
Astro-Han 858c394
fix(app): unify right-panel tab selection vocabulary and shrink × glyph
Astro-Han d4684fd
fix(ui): keep close × hover-only on selected sidepanel tabs
Astro-Han 7883396
fix(app,ui): hover preview + uniform width for right-panel tabs
Astro-Han 9fb6962
refactor(ui): grid-overlay leading cell for sidepanel close button
Astro-Han d363a29
refactor(ui,app): pill-tab geometry on 4pt grid
Astro-Han 7519d45
fix(ui,app): center sidepanel tab content with anchor-positioned clos…
Astro-Han c89ce1a
fix(app,ui): address PR #880 review + CI feedback
Astro-Han bc70865
refactor(app): tighten PR #880 contract + close review nits
Astro-Han 8c8e5f8
refactor(app): trim PR #880 duplication
Astro-Han 7ed5e2c
fix(app): selected+hover keeps active overlay (P2) + comment drift (P3)
Astro-Han 3902f44
fix(app): restructure titlebar right rail so tab strip and utility to…
Astro-Han 3b16637
fix(app): keep titlebar right rail full-height so tabs slot border-l …
Astro-Han 2aa0bf9
test(app): split titlebar rail tests out of session-tab-chip-contract
Astro-Han c76f8f7
fix(app): gate titlebar tabs rail on the same desktop breakpoint as S…
Astro-Han cd73d82
test(app): reword comment to avoid CodeQL js/redos false positive
Astro-Han 8ec16d0
test(app): poll for layout convergence after viewport resize in rail …
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
191 changes: 191 additions & 0 deletions
191
packages/app/e2e/session/session-tab-chip-contract.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| import { expect, test, type Page } from "../fixtures" | ||
| import { openRightPanel } from "../actions" | ||
|
|
||
| // Contract for the right-panel tab strip after the PR #880 chip + × cleanup. | ||
| // | ||
| // 1) Selected tab background uses `--row-active-overlay` (the same selection | ||
| // overlay the sidebar session row uses), not the previous opaque | ||
| // `var(--sidebar)`. Single source of truth for "this row/tab is selected" | ||
| // across the app. | ||
| // | ||
| // 2) The × close button visual is small (~8px) — clearly subordinate to the | ||
| // leading icon. The click slot stays at 14px to preserve a comfortable | ||
| // hover target. | ||
| // | ||
| // 3) Leading icon and × overlap at the same horizontal center (within 1px). | ||
| // PR #878 fixed the swap but left a 2-3px drift because CSS literals | ||
| // (`width: 14px`, `left: 10px`) ignore that html base font-size is 13px, | ||
| // so `size-3.5` (used by leadingSpan + closeBtn) renders ~11px instead. | ||
| // | ||
| // 4) Icon swap is instant — no opacity transition. Sweeping the mouse across | ||
| // multiple tabs must not flash both icons during a fade. | ||
| // | ||
| // These assertions complement (don't replace) the snap grid in | ||
| // packages/app/e2e/snap/right-panel-tabs-hover.snap.ts. | ||
|
|
||
| const FILES_TAB = { name: "Files" } | ||
| const REVIEW_TAB = { name: "Review" } | ||
| const STATUS_TAB = { name: "Status" } | ||
|
|
||
| async function openExtraTabs(page: Page) { | ||
| await page.locator("main").first().click() | ||
| await page.keyboard.press("ControlOrMeta+\\") // fileTree.toggle | ||
| await page.keyboard.press("ControlOrMeta+Shift+R") // review.toggle | ||
| await expect.poll(() => page.getByRole("tab").count(), { timeout: 5_000 }).toBe(3) | ||
| } | ||
|
|
||
| async function ensureRightPanelOpen(page: Page) { | ||
| await openRightPanel(page) | ||
| } | ||
|
|
||
| test.describe("right-panel tab chip + × contract", () => { | ||
| test("selected tab uses --row-active-overlay (matches sidebar session row)", async ({ page, gotoSession }) => { | ||
| await gotoSession() | ||
| await ensureRightPanelOpen(page) | ||
| await openExtraTabs(page) | ||
|
|
||
| // Click Files so Files is selected. Then sample its computed bg. | ||
| await page.getByRole("tab", FILES_TAB).click() | ||
| await page.mouse.move(0, 0) // no hover; rest state | ||
|
|
||
| const tokenAndComputed = await page.evaluate(() => { | ||
| const root = document.documentElement | ||
| const tokenRaw = getComputedStyle(root).getPropertyValue("--row-active-overlay").trim() | ||
| const trig = document.querySelector('[data-slot="tabs-trigger"][data-value="files"]') as HTMLElement | null | ||
| const computed = trig ? getComputedStyle(trig).backgroundColor : "" | ||
| return { tokenRaw, computed } | ||
| }) | ||
|
|
||
| // --row-active-overlay is defined as rgba(0,0,0,0.06) light / rgba(255,255,255,0.06) dark. | ||
| // We just assert the token resolves to a low-alpha rgba (not the previous | ||
| // opaque var(--sidebar) hex) so this test survives palette tweaks. | ||
| expect(tokenAndComputed.tokenRaw).toMatch(/rgba?\(/) | ||
| expect(tokenAndComputed.computed).toMatch(/rgba\(/) // not transparent, not solid hex | ||
| const alphaMatch = tokenAndComputed.computed.match(/rgba?\([^)]*,\s*([\d.]+)\s*\)/) | ||
| expect(alphaMatch).not.toBeNull() | ||
| const alpha = Number(alphaMatch![1]) | ||
| expect(alpha).toBeGreaterThan(0) | ||
| expect(alpha).toBeLessThan(0.2) // overlay band, not opaque | ||
| }) | ||
|
|
||
| test("× icon visual is ~8px while click slot matches leading icon size", async ({ page, gotoSession }) => { | ||
| await gotoSession() | ||
| await ensureRightPanelOpen(page) | ||
| await openExtraTabs(page) | ||
|
|
||
| // Hover the Files tab so the × is rendered (opacity 1). | ||
| await page.getByRole("tab", FILES_TAB).hover() | ||
|
|
||
| const dims = await page.evaluate(() => { | ||
| const wrap = document.querySelector('[data-slot="tabs-trigger-wrapper"][data-value="files"]') | ||
| const slot = wrap?.querySelector('[data-slot="tabs-trigger-close-button"]') as HTMLElement | null | ||
| const leadingSpan = wrap?.querySelector('[data-slot="tab-icon-default"]') as HTMLElement | null | ||
| const svg = slot?.querySelector('[data-slot="icon-svg"]') as HTMLElement | null | ||
| const box = (el: HTMLElement | null) => { | ||
| if (!el) return null | ||
| const r = el.getBoundingClientRect() | ||
| return { w: Math.round(r.width), h: Math.round(r.height) } | ||
| } | ||
| return { slot: box(slot), leading: box(leadingSpan), svg: box(svg) } | ||
| }) | ||
|
|
||
| // Click slot must match the leading icon span. Both use `size-3.5`-aware | ||
| // sizing now (0.875rem; ~11px under the app's rem-13 base) so swapping the | ||
| // icon for the × keeps the same hit target and footprint. | ||
| expect(dims.slot?.w).toBe(dims.leading?.w) | ||
| expect(dims.slot?.h).toBe(dims.leading?.h) | ||
| // Visible × glyph: smaller than the slot — 6 to 10px so it reads as a | ||
| // subordinate affordance instead of overflowing the slot like the 16×16 | ||
| // leading icon does. | ||
| expect(dims.svg?.w).toBeGreaterThanOrEqual(6) | ||
| expect(dims.svg?.w).toBeLessThanOrEqual(10) | ||
| expect(dims.svg?.h).toBeGreaterThanOrEqual(6) | ||
| expect(dims.svg?.h).toBeLessThanOrEqual(10) | ||
| }) | ||
|
|
||
| test("× center aligns with leading icon center (within 1px)", async ({ page, gotoSession }) => { | ||
| await gotoSession() | ||
| await ensureRightPanelOpen(page) | ||
| await openExtraTabs(page) | ||
|
|
||
| // Measure both elements while the wrapper is hovered. The close slot is | ||
| // `position: absolute` and the leading icon span sits in normal flow, so | ||
| // their CSS contracts both reference the same wrapper origin; we just need | ||
| // a state where both are laid out (the leading span still occupies space | ||
| // even when its opacity is 0 on hover). | ||
| await page.getByRole("tab", FILES_TAB).hover() | ||
|
|
||
| const positions = await page.evaluate(() => { | ||
| const wrap = document.querySelector('[data-slot="tabs-trigger-wrapper"][data-value="files"]') as HTMLElement | null | ||
| const leading = wrap?.querySelector('[data-slot="tab-icon-default"]') as HTMLElement | null | ||
| const slot = wrap?.querySelector('[data-slot="tabs-trigger-close-button"]') as HTMLElement | null | ||
| const box = (el: HTMLElement | null) => { | ||
| if (!el) return null | ||
| const r = el.getBoundingClientRect() | ||
| return { x: r.x, w: r.width, center: r.x + r.width / 2 } | ||
| } | ||
| return { leading: box(leading), slot: box(slot), wrapper: box(wrap) } | ||
| }) | ||
|
|
||
| expect(positions.leading).not.toBeNull() | ||
| expect(positions.slot).not.toBeNull() | ||
| const diff = Math.abs(positions.leading!.center - positions.slot!.center) | ||
| expect(diff).toBeLessThanOrEqual(1) | ||
| }) | ||
|
|
||
| test("icon swap is instant (no opacity transition)", async ({ page, gotoSession }) => { | ||
| await gotoSession() | ||
| await ensureRightPanelOpen(page) | ||
| await openExtraTabs(page) | ||
| await page.mouse.move(0, 0) | ||
|
|
||
| const transitions = await page.evaluate(() => { | ||
| const wrap = document.querySelector( | ||
| '[data-slot="tabs-trigger-wrapper"][data-value="files"]', | ||
| ) as HTMLElement | null | ||
| const icon = wrap?.querySelector('[data-slot="tab-icon-default"]') as HTMLElement | null | ||
| const closeSlot = wrap?.querySelector('[data-slot="tabs-trigger-close-button"]') as HTMLElement | null | ||
| const dur = (el: HTMLElement | null) => (el ? getComputedStyle(el).transitionDuration : null) | ||
| return { iconDur: dur(icon), closeSlotDur: dur(closeSlot) } | ||
| }) | ||
|
|
||
| // Both must be 0s — the swap is instant on hover, not faded. Multi-property | ||
| // transitions can produce a comma-joined string like "0s, 0s"; accept any | ||
| // shape that contains only zero durations. | ||
| const allZero = (val: string | null) => val !== null && /^(0s\s*,?\s*)+$/.test(val.trim()) | ||
| expect(allZero(transitions.iconDur)).toBe(true) | ||
| expect(allZero(transitions.closeSlotDur)).toBe(true) | ||
| }) | ||
|
|
||
| test("Status (non-closable) shows no × on hover and keeps its icon", async ({ page, gotoSession }) => { | ||
| // Regression guard: PR #878 had a moment where Status's icon faded under | ||
| // a `:has(close-button-slot)` selector even though Status has no slot. | ||
| // The current contract is: Status icon never fades, no × ever renders. | ||
| await gotoSession() | ||
| await ensureRightPanelOpen(page) | ||
| await openExtraTabs(page) | ||
|
|
||
| await page.getByRole("tab", STATUS_TAB).hover() | ||
| const dims = await page.evaluate(() => { | ||
| const wrap = document.querySelector( | ||
| '[data-slot="tabs-trigger-wrapper"][data-value="status"]', | ||
| ) as HTMLElement | null | ||
| const icon = wrap?.querySelector('[data-slot="tab-icon-default"]') as HTMLElement | null | ||
| const closeSlot = wrap?.querySelector('[data-slot="tabs-trigger-close-button"]') | ||
| const iconOpacity = icon ? getComputedStyle(icon).opacity : null | ||
| return { iconOpacity, hasCloseSlot: closeSlot !== null } | ||
| }) | ||
|
|
||
| expect(dims.iconOpacity).toBe("1") | ||
| expect(dims.hasCloseSlot).toBe(false) | ||
|
|
||
| // Sanity: Review's wrapper still has the slot (closable peer). | ||
| const reviewHasSlot = await page.evaluate(() => | ||
| document.querySelector( | ||
| '[data-slot="tabs-trigger-wrapper"][data-value="review"] [data-slot="tabs-trigger-close-button"]', | ||
| ) !== null, | ||
| ) | ||
| expect(reviewHasSlot).toBe(true) | ||
| await page.getByRole("tab", REVIEW_TAB).hover() // also closes the hover test cleanly | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import { expect, type Page } from "@playwright/test" | ||
| import { openRightPanel, openSidebar } from "../actions" | ||
| import { test } from "../fixtures" | ||
| import { sessionItemSelector } from "../selectors" | ||
| import { applyDarkModeForTests } from "../utils" | ||
| import { composeGrid, snapOutputPath, type Shot } from "./_compose" | ||
|
|
||
| // Hover-state probe for the right-panel tab strip. Captures three states of | ||
| // the closable Files tab so we can verify the close-button affordance: | ||
| // | ||
| // 1) rest — Files tab at rest, leading icon only, no close button | ||
| // 2) hover — mouse hovering Files tab; expectation: leading icon | ||
| // fades to opacity 0, close × fades in at the same 14×14 | ||
| // cell, no layout shift, no double-icon visible | ||
| // 3) measurements — page-level dump of bounding boxes for the close-button | ||
| // slot vs leading icon vs label so we know exactly where | ||
| // each piece lands in screen coordinates. | ||
| // | ||
| // Why not extend right-panel-titlebar.snap.ts: that snap intentionally moves | ||
| // the mouse to (0,0) to freeze a clean static frame. Hover state needs its | ||
| // own target so the two contracts don't fight. | ||
|
|
||
| test.use({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 2, reducedMotion: "reduce" }) | ||
|
|
||
| async function openFilesAndReview(page: Page) { | ||
| await page.locator("main").first().click() | ||
| await page.keyboard.press("ControlOrMeta+\\") | ||
| await page.keyboard.press("ControlOrMeta+Shift+R") | ||
| await expect.poll(() => page.getByRole("tab").count(), { timeout: 5_000 }).toBe(3) | ||
| await page.getByRole("tab", { name: "Status" }).click() | ||
| } | ||
|
|
||
| async function dumpBoxes(page: Page, label: string) { | ||
| // Dump the bounding boxes of every interesting element in the tab strip so | ||
| // we can reason about exact positions vs the CSS-declared 14×14 + left:10 | ||
| // contract in tabs.css. | ||
| const data = await page.evaluate(() => { | ||
| const tabs = Array.from( | ||
| document.querySelectorAll<HTMLElement>('[data-slot="tabs-trigger-wrapper"]'), | ||
| ) | ||
| return tabs.map((wrap) => { | ||
| const trig = wrap.querySelector<HTMLElement>('[data-slot="tabs-trigger"]') | ||
| const icon = wrap.querySelector<HTMLElement>('[data-slot="tab-icon-default"]') | ||
| const iconSvg = icon?.querySelector<HTMLElement>('[data-component="icon"]') | ||
| const closeSlot = wrap.querySelector<HTMLElement>('[data-slot="tabs-trigger-close-button"]') | ||
| const closeBtn = closeSlot?.querySelector<HTMLElement>('[data-component="icon-button"]') | ||
| const closeBtnIcon = closeBtn?.querySelector<HTMLElement>('[data-component="icon"]') | ||
| const cs = (el?: HTMLElement | null) => (el ? window.getComputedStyle(el) : null) | ||
| const box = (el?: HTMLElement | null) => { | ||
| if (!el) return null | ||
| const r = el.getBoundingClientRect() | ||
| return { x: Math.round(r.x), y: Math.round(r.y), w: Math.round(r.width), h: Math.round(r.height) } | ||
| } | ||
| return { | ||
| value: wrap.getAttribute("data-value"), | ||
| selected: trig?.getAttribute("data-selected") === "" || trig?.hasAttribute("data-selected"), | ||
| wrapper: box(wrap), | ||
| trigger: box(trig), | ||
| leadingSpan: box(icon), | ||
| leadingIconDiv: box(iconSvg), | ||
| closeSlot: box(closeSlot), | ||
| closeBtn: box(closeBtn), | ||
| closeBtnIcon: box(closeBtnIcon), | ||
| closeSlotOpacity: cs(closeSlot)?.opacity, | ||
| leadingSpanOpacity: cs(icon)?.opacity, | ||
| triggerFontWeight: cs(trig)?.fontWeight, | ||
| } | ||
| }) | ||
| }) | ||
| process.stdout.write(`\n[boxes ${label}]\n${JSON.stringify(data, null, 2)}\n`) | ||
| } | ||
|
|
||
| async function captureStates( | ||
| page: Page, | ||
| label: "light" | "dark", | ||
| sessionID: string, | ||
| ): Promise<Shot[]> { | ||
| await openSidebar(page) | ||
| await page.locator(sessionItemSelector(sessionID)).click() | ||
| await openRightPanel(page) | ||
| await openFilesAndReview(page) | ||
|
|
||
| // Rest state — mouse parked far away so no tab hovers. | ||
| await page.mouse.move(0, 0) | ||
| await page.waitForTimeout(200) | ||
| await dumpBoxes(page, `${label}-rest`) | ||
| const rest = { | ||
| name: `${label}-rest`, | ||
| buf: await page.screenshot({ | ||
| clip: { x: 600, y: 0, width: 700, height: 80 }, | ||
| animations: "disabled", | ||
| }), | ||
| } | ||
|
|
||
| // Hover state — hover the Files tab (closable). This should fade the | ||
| // leading icon and reveal the × close button. | ||
| await page.getByRole("tab", { name: "Files" }).hover() | ||
| await page.waitForTimeout(200) | ||
| await dumpBoxes(page, `${label}-hover-files`) | ||
| const hoverFiles = { | ||
| name: `${label}-hover-files`, | ||
| buf: await page.screenshot({ | ||
| clip: { x: 600, y: 0, width: 700, height: 80 }, | ||
| animations: "disabled", | ||
| }), | ||
| } | ||
|
|
||
| // Hover state on Review (also closable) — Review is selected by default | ||
| // after openFilesAndReview clicks Status? No, openFilesAndReview clicks | ||
| // Status; Review/Files are open but unselected. So this is hover on an | ||
| // unselected closable tab — same expected swap. | ||
| await page.getByRole("tab", { name: "Review" }).hover() | ||
| await page.waitForTimeout(200) | ||
| await dumpBoxes(page, `${label}-hover-review`) | ||
| const hoverReview = { | ||
| name: `${label}-hover-review`, | ||
| buf: await page.screenshot({ | ||
| clip: { x: 600, y: 0, width: 700, height: 80 }, | ||
| animations: "disabled", | ||
| }), | ||
| } | ||
|
|
||
| return [rest, hoverFiles, hoverReview] | ||
| } | ||
|
|
||
| test("right-panel-tabs-hover", async ({ page, project }) => { | ||
| test.setTimeout(180_000) | ||
|
|
||
| let sessionID: string | undefined | ||
| await project.open({ | ||
| beforeGoto: async ({ sdk }) => { | ||
| const session = await sdk.session.create({ title: "snap right panel tabs hover" }).then((res) => res.data) | ||
| sessionID = session?.id | ||
| }, | ||
| }) | ||
| if (!sessionID) throw new Error("Session create did not return an id") | ||
| project.trackSession(sessionID) | ||
|
|
||
| const shots: Shot[] = [] | ||
| shots.push(...(await captureStates(page, "light", sessionID))) | ||
| await applyDarkModeForTests(page) | ||
| shots.push(...(await captureStates(page, "dark", sessionID))) | ||
|
|
||
| const out = snapOutputPath("right-panel-tabs-hover") | ||
| await composeGrid(shots, out) | ||
| process.stdout.write(`\n[snap] right-panel-tabs-hover grid -> ${out}\n\n`) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.