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
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
color: var(--openbitfun-color-content-primary);
font-family: var(--openbitfun-type-body-sm-font-family);
font-size: var(--openbitfun-type-body-sm-font-size);
font-variant-numeric: proportional-nums;
font-weight: var(--openbitfun-type-body-sm-font-weight);
line-height: var(--openbitfun-type-body-sm-line-height);
text-align: start;
Expand All @@ -81,13 +82,27 @@
position: relative;
display: inline-flex;
flex: 0 0 auto;
/* Match the prominent tool card's leading slot, including the hover glyph. */
inline-size: var(--openbitfun-space-5);
block-size: var(--openbitfun-space-5);
min-inline-size: var(--openbitfun-font-size-xl);
min-block-size: var(--openbitfun-font-size-xl);
align-items: center;
justify-content: center;
color: var(--openbitfun-color-content-secondary);
}

.icon [data-openbitfun-component='icon'] {
inline-size: var(--openbitfun-font-size-xl);
block-size: var(--openbitfun-font-size-xl);
}

.disclosure {
position: absolute;
inset: 0;
display: inline-flex;
align-items: center;
justify-content: center;
opacity: 0;
background: var(--openbitfun-color-surface-panel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export function FileRevisionSummary({ file, itemCount, expanded, onToggle, conte
<span className={styles.disclosure}><Icon name={expanded ? 'chevron-down' : 'chevron-right'} size="sm" /></span>
</span>
<span className={styles.subject} data-openbitfun-component={component} data-openbitfun-part="summary">
{prefixLabel && <span className={styles.count}>{prefixLabel}</span>}
<OverflowText className={styles.filename} title={file.path}>{file.label}</OverflowText>
{prefixLabel && <OverflowText className={styles.count}>{prefixLabel}</OverflowText>}
<OverflowText behavior="marquee" className={styles.filename} title={file.path}>{file.label}</OverflowText>
</span>
{(file.status || file.statusLabel || (!expanded && file.changeSummary)) && <span className={styles.metadata} data-has-status={Boolean(file.status || file.statusLabel)}>
{(file.status || file.statusLabel) && <span className={styles.result} data-status={file.status}>
Expand Down
4 changes: 3 additions & 1 deletion src/web-ui/src/app/components/NavPanel/NavPanel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,9 @@ $_section-header-height: 22px;
background: var(--openbitfun-color-surface-raised);
// Switch state color once. Interpolating an inherited custom property forces
// style recalculation throughout the card on every animation frame.
animation: openbitfun-nav-popover-in 150ms cubic-bezier(0.23, 1, 0.32, 1) both;
// Release the opening transform instead of retaining a transformed clipping
// ancestor around the independently moving device artwork.
animation: openbitfun-nav-popover-in 150ms cubic-bezier(0.23, 1, 0.32, 1) backwards;

&[data-control-state='active'] {
--_device-overview-light: var(--openbitfun-color-status-success-content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function installPreviewAnimations() {
return {
records,
finishPhase: async () => {
const phase = records.slice(-3);
const phase = records.slice(-1);
await act(async () => { phase.forEach(animation => animation.finish()); });
},
};
Expand Down Expand Up @@ -480,74 +480,92 @@ describe('device status card', () => {
expect(element('device-sidebar-visibility').dataset.deviceSurface).toBe('local');
});

it('hands off artwork, name, pagination and actions together without invoking the old device', async () => {
it('commits artwork, name, pagination and actions together without a blank exit', async () => {
const { next } = await renderBrowseableDevices();
const motion = installPreviewAnimations();
const total = element('nav-device-status-total');
act(() => next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 })));
expect(element('nav-device-status-name').textContent).toBe('Current host');
expect(element('nav-device-status-pagination').textContent).toBe('2 / 4');
expect((element('device-sidebar-visibility') as HTMLButtonElement).disabled).toBe(true);
act(() => { element('device-sidebar-visibility').click(); element('nav-device-usage-status').click(); });
expect(state.disconnectDevice).not.toHaveBeenCalled();
expect(motion.records).toHaveLength(3);
expect(motion.records.every(animation => !animation.element.contains(total))).toBe(true);
expect(motion.records[0].options.duration).toBe(80);
expect(motion.records[0].keyframes[1].transform).toBe('translateX(calc(4px * -1))');

await motion.finishPhase();
// The new device is usable before any animation completes. No stale action
// or disabled-color flash is needed to bridge an asynchronous content swap.
expect(element('nav-device-status-name').textContent).toBe('Another host');
expect(element('nav-device-status-pagination').textContent).toBe('3 / 4');
expect(element('nav-device-status-total')).toBe(total);
expect(total.textContent).toBe('4');
expect(document.querySelector('[data-artwork="linux"]')).not.toBeNull();
expect(document.querySelector('[data-testid="nav-device-usage-status"]')).toBeNull();
expect(motion.records).toHaveLength(6);
expect(motion.records[3].options.duration).toBe(140);
expect(motion.records[3].keyframes[0].transform).toBe('translateX(calc(4px * 2))');
expect((element('device-sidebar-visibility') as HTMLButtonElement).disabled).toBe(true);
act(() => element('device-sidebar-visibility').click());
expect(state.switchToDevice).not.toHaveBeenCalled();
await motion.finishPhase();
expect((element('device-sidebar-visibility') as HTMLButtonElement).disabled).toBe(false);
await act(async () => element('device-sidebar-visibility').click());
act(() => element('device-sidebar-visibility').click());
expect(useDeviceVisibilityPreferences.getState().hidden['peer-2']).toBe(true);
expect(useDeviceVisibilityPreferences.getState().hidden['peer-1']).toBeUndefined();

expect(motion.records).toHaveLength(1);
expect(motion.records[0].element.classList.contains('openbitfun-device-overview__device-scene')).toBe(true);
expect(motion.records[0].keyframes).toEqual([
{ transform: 'translateX(calc(4px * 2))' }, { transform: 'none' },
]);
expect(motion.records[0].options).toMatchObject({ duration: 140, fill: 'backwards' });
await motion.finishPhase();
expect(element('nav-device-status-name').textContent).toBe('Another host');
expect(element('nav-device-status-popover').hasAttribute('data-preview-motion')).toBe(false);
expect(state.switchToDevice).not.toHaveBeenCalled();
expect(state.disconnectDevice).not.toHaveBeenCalled();
});

it('coalesces rapid clicks and interrupts an entrance from its current frame', async () => {
it('keeps rapid browsing current and ignores completions from interrupted motion', async () => {
const { next, previous } = await renderBrowseableDevices();
const motion = installPreviewAnimations();
const styles = vi.spyOn(globalThis, 'getComputedStyle');
act(() => { next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 })); next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 })); });
expect(motion.records).toHaveLength(3);
expect(styles).toHaveBeenCalledTimes(1);
await motion.finishPhase();
expect(styles).toHaveBeenCalledTimes(1);
styles.mockRestore();
act(() => {
next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 }));
next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 }));
});
expect(motion.records).toHaveLength(1);
expect(element('nav-device-status-name').textContent).toBe('Third host');
expect(element('nav-device-status-pagination').textContent).toBe('4 / 4');
expect(document.querySelector('[data-artwork="server"]')).not.toBeNull();

const interrupted = motion.records.slice(-3);
const scene = motion.records[0].element;
scene.style.opacity = '0.35';
const interrupted = motion.records[0];
const scene = interrupted.element;
scene.style.transform = 'translateX(2px)';
act(() => previous.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 })));
expect(interrupted.every(animation => animation.cancel.mock.calls.length === 1)).toBe(true);
expect(motion.records[6].keyframes[0]).toEqual({ opacity: '0.35', transform: 'translateX(2px)' });
scene.style.removeProperty('opacity');
expect(interrupted.cancel).toHaveBeenCalledOnce();
expect(element('nav-device-status-name').textContent).toBe('Another host');
expect(motion.records[1].keyframes[0]).toEqual({ transform: 'translateX(2px)' });
scene.style.removeProperty('transform');
await act(async () => { interrupted.forEach(animation => animation.finish()); });
expect(element('nav-device-status-name').textContent).toBe('Third host');
await motion.finishPhase();
await act(async () => { interrupted.finish(); });
expect(element('nav-device-status-name').textContent).toBe('Another host');
expect(element('nav-device-status-popover').dataset.previewMotion).toBe('true');
await motion.finishPhase();
expect((element('device-sidebar-visibility') as HTMLButtonElement).disabled).toBe(false);
expect(element('nav-device-status-popover').hasAttribute('data-preview-motion')).toBe(false);
expect(state.switchToDevice).not.toHaveBeenCalled();
});

it('keeps the selected device usable if the browser cannot start an animation', async () => {
const { next } = await renderBrowseableDevices();
installPreviewAnimations();
const scene = document.querySelector<HTMLElement>('.openbitfun-device-overview__device-scene')!;
scene.animate = () => { throw new Error('Animation unavailable'); };
act(() => next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 })));
expect(element('nav-device-status-name').textContent).toBe('Another host');
expect(element('nav-device-status-popover').hasAttribute('data-preview-motion')).toBe(false);
expect((element('device-sidebar-visibility') as HTMLButtonElement).disabled).toBe(false);
});

it('cancels decorative motion when the rendered device changes externally', async () => {
const { next } = await renderBrowseableDevices();
const motion = installPreviewAnimations();
act(() => next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 })));
expect(element('nav-device-status-name').textContent).toBe('Another host');
await act(async () => {
state.overview = overview();
render();
});
expect(element('nav-device-status-name').textContent).toBe('Workstation');
expect(motion.records[0].cancel).toHaveBeenCalledOnce();
await motion.finishPhase();
expect(element('nav-device-status-name').textContent).toBe('Workstation');
expect(element('nav-device-status-popover').hasAttribute('data-preview-motion')).toBe(false);
});

it('settles directly when reduced motion is preferred or enabled during a transition', async () => {
const setReduced = installMotionPreference(true);
const { next } = await renderBrowseableDevices();
Expand All @@ -557,7 +575,7 @@ describe('device status card', () => {
expect(element('nav-device-status-name').textContent).toBe('Another host');
setReduced(false);
act(() => next.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 1 })));
expect(motion.records).toHaveLength(3);
expect(motion.records).toHaveLength(1);
setReduced(true);
expect(element('nav-device-status-name').textContent).toBe('Third host');
expect((element('device-sidebar-visibility') as HTMLButtonElement).disabled).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,13 @@ const DeviceStatusControl: React.FC<DeviceStatusControlProps> = ({
const triggerRef = useRef<HTMLButtonElement>(null);
const popoverRef = useRef<HTMLDivElement>(null);
const artworkRef = useRef<HTMLDivElement>(null);
const headingRef = useRef<HTMLDivElement>(null);
const actionsRef = useRef<HTMLDivElement>(null);
const selectPreview = useCallback((deviceId: string) => {
setPreviewId(deviceId);
}, []);
const previewMotion = useDevicePreviewMotion({
scope: JSON.stringify([open, accountId, activePeerId, carouselDeviceIds]),
surfaceRef: popoverRef,
artworkRef,
headingRef,
actionsRef,
onSelect: selectPreview,
});
const browseDevice = (direction: -1 | 1, animate: boolean) => {
Expand Down Expand Up @@ -546,7 +542,7 @@ const DeviceStatusControl: React.FC<DeviceStatusControlProps> = ({
<span data-testid="nav-device-status-total">{formatNumber(previewDevices.length)}</span>
</span>
)}
<div className="openbitfun-device-overview__device-heading" ref={headingRef} data-overflow-trigger aria-live="polite" aria-atomic="true">
<div className="openbitfun-device-overview__device-heading" data-overflow-trigger aria-live="polite" aria-atomic="true">
{/* The system is drawn, not written: the same mark the trigger and
the device rows use. State is drawn after the name. */}
<span className="openbitfun-device-overview__device-mark" aria-hidden="true">
Expand Down Expand Up @@ -619,12 +615,11 @@ const DeviceStatusControl: React.FC<DeviceStatusControlProps> = ({
)}
</div>
</div>
<div className="openbitfun-device-overview__device-actions" ref={actionsRef}>
<div className="openbitfun-device-overview__device-actions">
{displayedSurfaceId && !['mobile', 'watch'].includes(displayedAccountDevice?.device_kind?.trim().toLowerCase() ?? '') && (
<DeviceVisibilityButton
surfaceId={displayedSurfaceId}
name={displayedDevice.name}
disabled={previewMotion.isTransitioning}
/>
)}
</div>
Expand Down
Loading
Loading