Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions packages/web-shell/client/components/MessageTimestamp.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,51 @@
}

/*
* Anchored inside the message's top-right corner rather than floating above
* it: the message list (`.list`) is `overflow-y: auto`, so a tooltip spilling
* outside the row box would be clipped or trigger a scrollbar. Staying within
* the row keeps it visible at the scroll edges. `pointer-events: none` lets
* clicks and inner hover interactions (tool expand, links) pass through.
* Anchored inside the message row rather than floating above it: the message
* list (`.list`) is `overflow-y: auto`, so a tooltip spilling outside the row
* box would be clipped or trigger a scrollbar. Staying within the row keeps it
* visible at the scroll edges. `pointer-events: none` lets clicks and inner
* hover interactions (tool expand, links) pass through.
*
* Anchored at the BOTTOM-right, and fully opaque. Both halves matter, and the
* position is the load-bearing one.
*
* At the top-right the chip's lower edge cuts horizontally through the first
* line of the message, and the first line of a wrapped block is the one that
* runs the full column width. It does not hide the last word so much as
* decapitate it: the chip removes a letter's ascender while its bowl stays
* visible below, so "finished." reads as "finisheu." -- the shape that kept
* being reported as a corrupted error message in web-shell previews. Making
* the background opaque alone does NOT fix that; it erases the faint remnant
* of the ascender and leaves the letter looking even more like a "u". Moving
* the chip off the text is what fixes it. The last line of a wrapped block is
* a ragged remainder, and rows carrying an action bar (the turn-error Copy
* button) leave that corner empty outright.
*
* Opacity still matters on its own: at 92% a glyph beneath any overlay bleeds
* through it, which reads as broken text rather than as a chip. `.chatTip` and
* `.copyButton` sit over content too (`.chatActions` pulls itself up by -24px)
* and carry the same fix. So does `.toolTimeTip` in SubAgentPanel.module.css,
* which mirrors this chip over a sub-tool line and had no `background` at all
* -- but only its background: that row cannot wrap and is about as tall as the
* chip, so it has no slack to move into. `visual-capture-contracts.test.ts`
* pins these, because no test reads this geometry: reverting the anchor or the
* background keeps every suite green.
*
* Overlap is now rare, not impossible -- a message whose last block is a
* full-width code block or table still gets the chip in its corner. Reserving
* space in flow was rejected: hover-time padding reflows the transcript, and a
* permanent float notch shrinks every code block that establishes its own
* formatting context.
*/
.tip {
position: absolute;
top: 2px;
bottom: 2px;
right: 4px;
z-index: 5;
color: var(--muted-foreground);
background: color-mix(in srgb, var(--background) 92%, transparent);
background: var(--background);
border: 1px solid var(--border);
border-radius: 4px;
padding: 1px 4px;
font-size: 11px;
Expand All @@ -46,7 +78,7 @@

.chatTip {
color: var(--muted-foreground);
background: color-mix(in srgb, var(--background) 92%, transparent);
background: var(--background);
border-radius: 4px;
padding: 1px 4px;
font-size: 11px;
Expand Down Expand Up @@ -81,7 +113,7 @@
padding: 0;
border: 0;
border-radius: 5px;
background: color-mix(in srgb, var(--background) 92%, transparent);
background: var(--background);
color: var(--muted-foreground);
cursor: pointer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,27 @@
position: relative;
}

/*
* Mirrors MessageTimestamp's `.tip`, and had the same defect in a worse form:
* it declared no `background` at all, so the chip's digits composited directly
* onto the row's text. `.lineArg` reaches the row's right edge and
* `.lineElapsed` sits there for every running sub-tool, so the collision is
* structural, not incidental.
*
* Only the background is fixed here. `.tip` also moved to the bottom of its
* row, which works because a message wraps and its last line is a ragged
* remainder -- this row cannot wrap (`.lineArg` is `white-space: nowrap`) and
* is roughly as tall as the chip, so it has no vertical slack to move into and
* `bottom` would land in the same place `top` does. The text under the chip is
* still covered; it is now cleanly covered rather than overprinted.
*/
.toolTimeRow > .toolTimeTip {
position: absolute;
top: 2px;
right: 4px;
z-index: 5;
color: var(--muted-foreground);
background: var(--background);
font-size: 11px;
line-height: 1.4;
white-space: nowrap;
Expand Down
23 changes: 23 additions & 0 deletions packages/web-shell/client/e2e/visuals/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,26 @@
* cannot drift between the config and what actually renders.
*/
export const VISUAL_VIEWPORT = { width: 1280, height: 800 } as const;

/**
* Wall-clock instant every capture renders at.
*
* It is deliberately in the FUTURE relative to every date a fixture hardcodes.
* Relative formatters measure `Date.now() - value` (`formatRelativeTime`), so a
* fixture date on the far side of this instant yields a negative age and
* collapses to "just now": with an earlier constant the channel editor's
* pairing requests, dated 2026-07-28, rendered as "just now" instead of the
* "7/28/2026" the real clock produced. Future-dating is the safe direction --
* a fixture then reads as older than now, which is what every one of them
* means.
*
* Two rules follow for anyone adding a fixture. An absolute date must be
* earlier than this instant. A value meant to be "now" must be derived from
* this constant rather than from `Date.now()`, which in a spec runs on Node's
* real clock and lands months away from the page's frozen one.
*
* It lives here rather than in harness.ts so `visual-capture-contracts.test.ts`
* -- the gating vitest guard for both rules -- can import it without pulling in
* `@playwright/test`.
*/
export const FIXED_CAPTURE_TIME = new Date('2027-01-01T09:00:00.000Z');
11 changes: 10 additions & 1 deletion packages/web-shell/client/e2e/visuals/git-branch-picker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '../utils/mockDaemon';
import {
captureScreenshot,
FIXED_CAPTURE_TIME,
gotoSession,
installScenario,
resolveBaseURL,
Expand Down Expand Up @@ -51,7 +52,15 @@ test('branch picker, commit dialog, create PR form', async ({
behind: 0,
stashCount: 0,
operation: null,
computedAt: Date.now(),
// Derived from the frozen capture instant per the harness rule: a value
// meant to be "now" must not come from Node's real clock. No behaviour
// rides on it either way -- BranchPickerPopover stamps
// `listingFetchedAt` from the frozen clock and returns early on
// `at <= listingFetchedAt`, which a real-clock value (months BELOW the
// future-dated constant) and this value (exact equality) both satisfy.
// Exercising the reconcile path would need an explicit
// `FIXED_CAPTURE_TIME.getTime() + 1`.
computedAt: FIXED_CAPTURE_TIME.getTime(),
},
events: [
userTextEvent('Add a branch picker to the web shell', { id: 1 }),
Expand Down
41 changes: 39 additions & 2 deletions packages/web-shell/client/e2e/visuals/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import {
type MockDaemonController,
type WebShellDaemonScenario,
} from '../utils/mockDaemon';
import { VISUAL_VIEWPORT } from './constants';
import { FIXED_CAPTURE_TIME, VISUAL_VIEWPORT } from './constants';

export type VisualTheme = 'dark' | 'light';

export { VISUAL_VIEWPORT };
export { FIXED_CAPTURE_TIME, VISUAL_VIEWPORT };

/** localStorage key the web-shell reads for its persisted theme (see index.html). */
const THEME_STORAGE_KEY = 'qwen-code-web-shell-theme';
Expand Down Expand Up @@ -64,6 +64,41 @@ async function primeTheme(page: Page, theme: VisualTheme): Promise<void> {
);
}

/**
* Pin the page clock so anything rendering a wall-clock time is byte-identical
* across the base and head capture passes.
*
* Those two passes run minutes apart inside the SAME job -- the base render
* waits on its own `npm install` first -- so every timestamped view differed on
* every run purely because of when it was photographed. On PR #11267 that was
* the entire preview: the one view the compose step flagged as CHANGED,
* `terminal-turn-error-copy-narrow-dark`, scored exactly 0.02% (the threshold)
* and the whole diff was a `09:09:28` tip against a `09:18:16` one.
*
* What `setFixedTime` actually installs is Playwright's FULL fake clock, not a
* `Date`-only shim: `setTimeout`, `setInterval`, `requestAnimationFrame`,
* `requestIdleCallback`, `performance` and `Intl` are all replaced. Timers and
* rAF keep firing, so replay, streaming and `freezeLoopingAnimations` behave
* normally in outcome -- but two things do change and will cost a debugging
* session if they are not written down:
*
* - `performance.mark`/`measure` return throwaway entries and `getEntries()`
* comes back empty, so a capture can never observe a measure-storm.
* - Every `Date.now()`-delta window in the app is pinned permanently shut:
* background-agent grace misses, catalog staleness, retry backoff, live-state
* reconcile throttling. Nothing seeds those states today, so nothing fails --
* but a scenario that needs one to elapse will hang inside `gotoSession` and
* surface as a bare expect timeout. Such a scenario must seed already-expired
* timestamps or drive `page.clock.fastForward` / `runFor` itself.
*
* `visual-capture-contracts.test.ts` pins that both navigation helpers still
* call this before `page.goto`; nothing in the visuals suite reads the clock,
* so a dropped call would otherwise stay green.
*/
export async function freezeWallClock(page: Page): Promise<void> {
await page.clock.setFixedTime(FIXED_CAPTURE_TIME);
}

export function resolveBaseURL(testInfo: TestInfo): string {
const value = testInfo.project.use.baseURL;
if (!value)
Expand Down Expand Up @@ -98,6 +133,7 @@ export async function gotoSession(
search: Readonly<Record<string, string>> = {},
): Promise<void> {
await primeTheme(page, theme);
await freezeWallClock(page);
const query = new URLSearchParams({ theme, ...search });
await page.goto(
`/session/${encodeURIComponent(scenario.sessionId)}?${query.toString()}`,
Expand Down Expand Up @@ -125,6 +161,7 @@ export async function gotoNewSession(
theme: VisualTheme,
): Promise<void> {
await primeTheme(page, theme);
await freezeWallClock(page);
await page.goto(`/?theme=${theme}`);
await expect(page.locator('[data-web-shell-root]')).toBeVisible();
await expect(page.locator('html')).toHaveClass(new RegExp(`theme-${theme}`));
Expand Down
29 changes: 23 additions & 6 deletions packages/web-shell/client/e2e/visuals/screenshots.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ for (const theme of THEMES) {
await captureScreenshot(page, `goal-usage-limited-${theme}`);
});

// Assertions only, no captures. This scenario injects a fake turn_error so
// the error row's Copy affordance (#10001) can be exercised. It is the only
// visual test that hovers a message row DELIBERATELY, and its four captures
// meant every web-shell preview led with full-height red error images no
// matter what the PR touched -- readers repeatedly took the preview for a
// live failure.
//
// Dropping them does not blind the hover timestamp entirely: the parallel
// agents test leaves the cursor resting on the group header after
// `summary.click()`, so `parallel-agents-expanded` paints the chip through
// residual hover and moves when the chip moves. That is incidental rather
// than intended coverage, and `visual-capture-contracts.test.ts` is what
// actually pins the chip's anchor and background.
//
// The reveal/hide behaviour is pinned by the opacity assertions below on
// every viewport and on touch; the captures added a misleading preview,
// not coverage.
test(`terminal turn error`, async ({ browser, page }, testInfo) => {
const baseURL = resolveBaseURL(testInfo);
const scenario = createTerminalTurnErrorScenario(
Expand All @@ -168,14 +185,12 @@ for (const theme of THEMES) {
await expect(actions).toHaveCSS('opacity', '0');
await errorRow.hover();
await expect(actions).toHaveCSS('opacity', '1');
await captureScreenshot(page, `terminal-turn-error-copy-${theme}`);

await page.setViewportSize({ width: 720, height: 800 });
await page.mouse.move(0, 0);
await expect(actions).toHaveCSS('opacity', '0');
await errorRow.hover();
await expect(actions).toHaveCSS('opacity', '1');
await captureScreenshot(page, `terminal-turn-error-copy-narrow-${theme}`);

const touchContext = await browser.newContext({
...devices['Pixel 7'],
Expand Down Expand Up @@ -208,10 +223,12 @@ for (const theme of THEMES) {
touchErrorRow.locator('[data-web-shell-message-actions]'),
).toHaveCSS('opacity', '1');
await expect(touchCopyButton).toBeVisible();
await captureScreenshot(
touchPage,
`terminal-turn-error-copy-touch-${theme}`,
);
// No screenshot here on purpose. Touch is `hover: none`, so the hover
// timestamp chip never renders and this view carries zero coverage of
// it -- proven by a run that moved the chip and left these two captures
// at 0% diff. The assertions above are what guard the touch behaviour
// (#10001: actions stay visible without hover); the captures only added
// two full-height error screenshots to every preview.
} finally {
await touchContext.close();
}
Expand Down
Loading
Loading