Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
106 changes: 62 additions & 44 deletions design-system/packages/ui/src/styles/scrollbars.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,56 @@
* tracks for edge-to-edge content.
*/
@layer openbitfun.base {
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar {
width: var(--openbitfun-scrollbar-width);
height: var(--openbitfun-scrollbar-width);
background: transparent;
}
/*
* Legacy WebKit fallback only when standard `scrollbar-color` is unavailable
* (e.g. Safari <= 18.1). Where `scrollbar-color` is supported, CSS Scrollbars
* Level 1 supersedes `::-webkit-scrollbar*` anyway, while universal
* `*::-webkit-scrollbar*` selectors still force WebKit style/layout work on
* every descendant node.
*/
@supports not (scrollbar-color: transparent transparent) {
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar {
width: var(--openbitfun-scrollbar-width);
height: var(--openbitfun-scrollbar-width);
background: transparent;
}

/* OS settings can expose the root, track pieces, buttons, and corner. */
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-track,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-track-piece,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-corner,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-button,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-resizer {
background: transparent;
}
/* OS settings can expose the root, track pieces, buttons, and corner. */
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-track,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-track-piece,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-corner,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-button,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-resizer {
background: transparent;
}

:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb {
background: var(--openbitfun-color-scrollbar-thumb);
border-radius: var(--openbitfun-scrollbar-radius);
}
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb {
background: var(--openbitfun-color-scrollbar-thumb);
border-radius: var(--openbitfun-scrollbar-radius);
}

@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb {
background: transparent;
}

:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility]):where(:hover, :focus-visible, [data-openbitfun-scrollbar-visibility="always"], :root:not([data-openbitfun-focus-visible="false"]) :focus-within, :root:not([data-openbitfun-focus-visible="false"]):focus-within)::-webkit-scrollbar-thumb {
background: var(--openbitfun-color-scrollbar-thumb);
}
}

:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:hover,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:active {
background: var(--openbitfun-color-scrollbar-thumb-hover);
}

:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:hover,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:active {
background: var(--openbitfun-color-scrollbar-thumb-hover);
@media (forced-colors: active) {
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:hover,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:active {
background: CanvasText;
}
}
}

/*
Expand All @@ -43,36 +70,33 @@
scrollbar-width: thin;
scrollbar-color: var(--openbitfun-color-scrollbar-thumb) transparent;
}
}

/*
* Hide only for a primary mouse/trackpad. Touch keeps a discoverable native
* thumb, and forced colors keeps the operating system's accessibility cues.
* Keyboard focus reveals its viewport without latching ordinary mouse focus.
* A document focus flag avoids a relational selector on every descendant.
* CSS-only consumers conservatively keep focused viewports discoverable.
* Scroll events (including streaming output) do not reveal an idle viewport.
*/
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility]):where(:not(:hover, :focus-visible, [data-openbitfun-scrollbar-visibility="always"])):where(:not(:focus-within), :root[data-openbitfun-focus-visible="false"], :root[data-openbitfun-focus-visible="false"] *)::-webkit-scrollbar-thumb {
background: transparent;
}

@supports (scrollbar-color: transparent transparent) {
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility]):where(:not(:hover, :focus-visible, [data-openbitfun-scrollbar-visibility="always"])):where(:not(:focus-within), :root[data-openbitfun-focus-visible="false"], :root[data-openbitfun-focus-visible="false"] *) {
/*
* Hide only for a primary mouse/trackpad. Touch keeps a discoverable native
* thumb, and forced colors keeps the operating system's accessibility cues.
* Keyboard focus reveals its viewport without latching ordinary mouse focus.
* Expressing reveal positively avoids `:root[data-openbitfun-focus-visible="false"] *`,
* which otherwise invalidates every DOM element whenever focus modality flips.
*/
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility]) {
scrollbar-color: transparent transparent;
}

:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility]):where(:hover, :focus-visible, [data-openbitfun-scrollbar-visibility="always"], :root:not([data-openbitfun-focus-visible="false"]) :focus-within, :root:not([data-openbitfun-focus-visible="false"]):focus-within) {
scrollbar-color: var(--openbitfun-color-scrollbar-thumb) transparent;
}
}
}

/* Opt-in hover viewports release idle tracks instead of only hiding paint.
Native overflow still owns whether a track is needed when revealed. */
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
[data-openbitfun-scrollbar-visibility="hover"]:not(:hover, :focus-visible):where(:not(:focus-within), :root[data-openbitfun-focus-visible="false"], :root[data-openbitfun-focus-visible="false"] *) {
[data-openbitfun-scrollbar-visibility="hover"]:not(:hover, :focus-visible):where(:not(:focus-within), :root[data-openbitfun-focus-visible="false"][data-openbitfun-scrollbar-visibility="hover"], :root[data-openbitfun-focus-visible="false"] [data-openbitfun-scrollbar-visibility="hover"]) {
scrollbar-width: none;
}

[data-openbitfun-scrollbar-visibility="hover"]:not(:hover, :focus-visible):where(:not(:focus-within), :root[data-openbitfun-focus-visible="false"], :root[data-openbitfun-focus-visible="false"] *)::-webkit-scrollbar {
[data-openbitfun-scrollbar-visibility="hover"]:not(:hover, :focus-visible):where(:not(:focus-within), :root[data-openbitfun-focus-visible="false"][data-openbitfun-scrollbar-visibility="hover"], :root[data-openbitfun-focus-visible="false"] [data-openbitfun-scrollbar-visibility="hover"])::-webkit-scrollbar {
display: none;
}
}
Expand All @@ -90,11 +114,5 @@
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility]) {
scrollbar-color: auto;
}

:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:hover,
:where([data-openbitfun-design-system-root], [data-openbitfun-design-system-root] *, [data-openbitfun-scrollbar-visibility])::-webkit-scrollbar-thumb:active {
background: CanvasText;
}
}
}
5 changes: 5 additions & 0 deletions design-system/packages/ui/tests/scroll-area.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,10 @@ test("ScrollArea styling uses public scrollbar tokens and preserves native scrol
assert.match(publishedStyles, /--openbitfun-color-scrollbar-thumb-hover/);
assert.match(publishedStyles, /\[data-openbitfun-scrollbar-visibility\]/);
assert.match(publishedStyles, /scrollbar-width:\s*none/);
// Universal legacy WebKit scrollbar rules must stay gated behind
// `@supports not (scrollbar-color: transparent transparent)` and avoid
// `:root[data-openbitfun-focus-visible="false"] *` full-tree invalidation.
assert.match(publishedStyles, /@supports not\s*\(scrollbar-color:\s*transparent transparent\)/);
assert.doesNotMatch(publishedStyles, /\[data-openbitfun-focus-visible="false"\]\s*\*/);
assert.doesNotMatch(styles, /#[0-9a-f]{3,8}/i);
});
3 changes: 2 additions & 1 deletion src/web-ui/src/app/components/SceneBar/SceneBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const SceneBar: React.FC<SceneBarProps> = ({
const canAcceptTab = canAcceptCanvasTab || offeredSceneTab;
const activeCanvasDrop = canAcceptTab ? canvasDrop : null;
const sceneBarClassName = `openbitfun-scene-bar ${className}`.trim();
const openTabIds = useMemo(() => shownTabs.map(tab => tab.id), [shownTabs]);
const {
tabRegionRef,
tabsRef,
Expand All @@ -146,7 +147,7 @@ const SceneBar: React.FC<SceneBarProps> = ({
} = useSceneTabNavigation({
activeTabId: selectedTabId,
navigationMotion,
openTabIds: shownTabs.map(tab => tab.id),
openTabIds,
});

/**
Expand Down
18 changes: 15 additions & 3 deletions src/web-ui/src/app/components/SceneBar/useSceneTabNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,23 @@ export function useSceneTabNavigation({
const pending = pendingRevealRef.current;
if (!pending) return;
const tabs = tabsRef.current;
if (!tabs) { pendingRevealRef.current = null; return; }

const visibleStart = tabs.scrollLeft;
const maxScrollLeft = Math.max(0, tabs.scrollWidth - tabs.clientWidth);
// Fast path: when the tab strip fits completely within its viewport and is
// already at origin, any clamped scroll target is 0. Avoid querying tab DOM
// nodes and calling `getBoundingClientRect()`, which otherwise forces an
// extra synchronous layout pass during session switches.
if (maxScrollLeft <= SCROLL_EDGE_EPSILON && visibleStart <= SCROLL_EDGE_EPSILON) {
pendingRevealRef.current = null;
return;
}

const activeTab = getTabElements().find(tab => tab.dataset.openbitfunValue === pending.id);
const activeItem = activeTab?.closest<HTMLElement>('[data-openbitfun-part="item"]') ?? activeTab;
if (!tabs || !activeItem) { pendingRevealRef.current = null; return; }
if (!activeItem) { pendingRevealRef.current = null; return; }

const visibleStart = tabs.scrollLeft;
const visibleEnd = visibleStart + tabs.clientWidth;
// TabGroup's item is nested in a positioned, draggable SceneBar wrapper.
// Its offsetLeft belongs to that wrapper, not this scroll viewport.
Expand All @@ -121,7 +133,7 @@ export function useSceneTabNavigation({
nextLeft = tabEnd - tabs.clientWidth;
}

const target = Math.max(0, Math.min(nextLeft, tabs.scrollWidth - tabs.clientWidth));
const target = Math.max(0, Math.min(nextLeft, maxScrollLeft));
if (Math.abs(target - visibleStart) <= SCROLL_EDGE_EPSILON) {
pendingRevealRef.current = null;
return;
Expand Down
10 changes: 4 additions & 6 deletions src/web-ui/src/app/layout/AppLayout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
*/
@use '@/shared/styles/surface-recipes' as surfaces;

// ==================== CSS reset ====================
// Note: keep box-sizing !important for global consistency.
*, *::before, *::after {
box-sizing: border-box !important;
}

// ==================== Shell root ====================
// `box-sizing: border-box` is owned by `@layer openbitfun.reset` in index.html
// and `@openbitfun/ui/styles.css`; avoid unlayered universal `*::before/*::after`
// `!important` rules that force WebKit pseudo-element style resolution on every node.
html, body {
margin: 0;
padding: 0;
Expand Down
1 change: 0 additions & 1 deletion src/web-ui/src/app/layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import { AcpSessionNotifications } from './AcpSessionNotifications';
import { api } from '@/infrastructure/api/service-api/ApiClient';
import { AppearanceBackgroundMediaLayer, appearanceRuntime, useAppearance } from '@/infrastructure/appearance';
import { PeerConnectionStatus } from '@/infrastructure/peer-device/PeerConnectionStatus';
import './AppLayout.scss';

type TransitionDirection = 'entering' | 'returning' | null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* the action settled and the target scene had a frame to paint.
*
* Opening an existing session needs no curtain: its tab is held in front and
* the session view shows its own loading skeleton, in its own layout, so the
* loading presentation never changes size or position mid-open.
* the session view shows its own centered loading spinner, in its own layout,
* so the loading presentation never changes size or position mid-open.
*/

import React, { useEffect, useRef, useState } from 'react';
Expand Down
52 changes: 33 additions & 19 deletions src/web-ui/src/app/styles/scrollbar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,55 @@ describe('shared native scrollbar presentation', () => {
});

it('preserves automatic track geometry and only releases explicitly opted-in hover tracks', () => {
const interactionRules = stylesheet.slice(
stylesheet.indexOf('@media (hover: hover)'),
stylesheet.indexOf('/* Opt-in hover viewports'),
);
const hoverRules = stylesheet.slice(
stylesheet.indexOf('/* Opt-in hover viewports'),
stylesheet.indexOf('/* Explicit hidden viewports'),
const hoverStart = stylesheet.indexOf('/* Opt-in hover viewports');
const hiddenStart = stylesheet.indexOf('/* Explicit hidden viewports');
const interactionBlocks = Array.from(
stylesheet
.slice(0, hoverStart)
.matchAll(/@media \(hover: hover\) and \(pointer: fine\) and \(forced-colors: none\)\s*\{([\s\S]*?)\n \}/g),
match => match[1],
);
const hoverRules = stylesheet.slice(hoverStart, hiddenStart);
const positiveRevealSelector =
':where(:hover, :focus-visible, [data-openbitfun-scrollbar-visibility="always"], :root:not([data-openbitfun-focus-visible="false"]) :focus-within, :root:not([data-openbitfun-focus-visible="false"]):focus-within)';

expect(interactionBlocks).toHaveLength(2);
expect(interactionBlocks[0]).toContain('background: transparent;');
expect(interactionBlocks[0]).toContain(positiveRevealSelector);
expect(interactionBlocks[0]).toContain('background: var(--openbitfun-color-scrollbar-thumb);');
expect(interactionBlocks[1]).toContain('scrollbar-color: transparent transparent;');
expect(interactionBlocks[1]).toContain(positiveRevealSelector);
expect(interactionBlocks[1]).toContain('scrollbar-color: var(--openbitfun-color-scrollbar-thumb) transparent;');
for (const block of interactionBlocks) {
expect(block).not.toMatch(/(?:overflow|width|height|display|scrollbar-gutter)\s*:/);
}

expect(interactionRules).toContain('(pointer: fine) and (forced-colors: none)');
expect(interactionRules).toContain(
':not(:hover, :focus-visible, [data-openbitfun-scrollbar-visibility="always"])',
);
expect(interactionRules).toContain(':where(:not(:focus-within), :root[data-openbitfun-focus-visible="false"], :root[data-openbitfun-focus-visible="false"] *)');
expect(interactionRules).toContain('background: transparent;');
expect(interactionRules).toContain('scrollbar-color: transparent transparent;');
expect(interactionRules).not.toMatch(/(?:overflow|width|height|display|scrollbar-gutter)\s*:/);
expect(hoverRules).toContain('@media (hover: hover) and (pointer: fine) and (forced-colors: none)');
expect(hoverRules).toMatch(
/\[data-openbitfun-scrollbar-visibility="hover"\]:not\(:hover, :focus-visible\):where\(:not\(:focus-within\), :root\[data-openbitfun-focus-visible="false"\], :root\[data-openbitfun-focus-visible="false"\] \*\)\s*\{\s*scrollbar-width:\s*none;/,
/\[data-openbitfun-scrollbar-visibility="hover"\]:not\(:hover, :focus-visible\):where\(:not\(:focus-within\), :root\[data-openbitfun-focus-visible="false"\]\[data-openbitfun-scrollbar-visibility="hover"\], :root\[data-openbitfun-focus-visible="false"\] \[data-openbitfun-scrollbar-visibility="hover"\]\)\s*\{\s*scrollbar-width:\s*none;/,
);
expect(hoverRules).toMatch(
/\[data-openbitfun-scrollbar-visibility="hover"\]:not\(:hover, :focus-visible\):where\(:not\(:focus-within\), :root\[data-openbitfun-focus-visible="false"\], :root\[data-openbitfun-focus-visible="false"\] \*\)::-webkit-scrollbar\s*\{\s*display:\s*none;/,
/\[data-openbitfun-scrollbar-visibility="hover"\]:not\(:hover, :focus-visible\):where\(:not\(:focus-within\), :root\[data-openbitfun-focus-visible="false"\]\[data-openbitfun-scrollbar-visibility="hover"\], :root\[data-openbitfun-focus-visible="false"\] \[data-openbitfun-scrollbar-visibility="hover"\]\)::-webkit-scrollbar\s*\{\s*display:\s*none;/,
);
const rulesOnly = stylesheet.replace(/\/\*[\s\S]*?\*\//g, '');
expect(hoverRules).not.toMatch(/(?:overflow(?:-[xy])?|scrollbar-gutter)\s*:/);
expect(stylesheet).not.toMatch(/\.is-scrolling|:has\(|!important/);
expect(rulesOnly).not.toMatch(/\[data-openbitfun-focus-visible="false"\]\s*\*/);
expect(rulesOnly).not.toMatch(/\.is-scrolling|:has\(|!important/);
});

it('guards standard width and color together so Safari 18 keeps the WebKit path', () => {
expect(stylesheet).toMatch(
/@supports not \(scrollbar-color: transparent transparent\)\s*\{[\s\S]*::-webkit-scrollbar\s*\{/,
);
expect(stylesheet).toMatch(
/@supports \(scrollbar-color: transparent transparent\)\s*\{[^{}]+\{\s*scrollbar-width:\s*thin;\s*scrollbar-color:\s*var\(--openbitfun-color-scrollbar-thumb\) transparent;/,
);
expect(stylesheet.match(/scrollbar-width:\s*thin/g)).toHaveLength(1);
expect(stylesheet).toMatch(
/@media \(forced-colors: active\)[\s\S]*scrollbar-color:\s*auto;[\s\S]*background:\s*CanvasText;/,
/@media \(forced-colors: active\)\s*\{[\s\S]*?background:\s*CanvasText;/,
);
expect(stylesheet).toMatch(
/@media \(forced-colors: active\)\s*\{[^{}]+\{\s*scrollbar-color:\s*auto;/,
);
});

Expand Down
Loading
Loading