Add a packaged-client runtime boundary so the shared UI can talk to local, desktop, remote, and VS Code runtimes through the right transport instead of assuming one same-origin web server. Centralize OpenChamber-owned API access behind RuntimeAPIs, runtimeFetch, and runtime URL helpers, while keeping official OpenCode traffic on the SDK path. Support runtime switching, remote host selection, desktop client credentials, and headless connection links for pairing packaged clients with remote OpenChamber servers. Harden the new auth model by moving long-lived client tokens out of browser URLs, introducing short-lived scoped URL tokens for browser-owned transports, restricting URL-token access to explicit readable/realtime routes, and making client-token management session-scoped or self-scoped as appropriate. Update browser-owned assets and preview proxy flows to work with the split runtime model, including authenticated project icons, preview token propagation, CSP-safe preview bridge injection, and preview proxy auth that survives short-lived URL-token expiry. Tighten Electron security boundaries for packaged clients by gating privileged preload state to trusted origins and requiring explicit confirmation before connect deep-links import or switch remote runtimes. Also refresh agent guidance and project skills so future runtime/API, auth, preview, UI, CLI, settings, locale, and drag-to-reorder work follows the new architecture.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
|
|
import { shouldAutoLoadEarlierForUnderfilledPinnedViewport } from './useChatTimelineController';
|
|
|
|
const baseInput = {
|
|
sessionId: 'ses_1',
|
|
isPinned: true,
|
|
canLoadEarlier: true,
|
|
isLoadingOlder: false,
|
|
pendingRevealWork: false,
|
|
scrollHeight: 799,
|
|
clientHeight: 800,
|
|
};
|
|
|
|
describe('shouldAutoLoadEarlierForUnderfilledPinnedViewport', () => {
|
|
test('loads when pinned content does not fill the viewport', () => {
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport(baseInput)).toBe(true);
|
|
});
|
|
|
|
test('does not load when content already overflows', () => {
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
|
...baseInput,
|
|
scrollHeight: 802,
|
|
})).toBe(false);
|
|
});
|
|
|
|
test('does not load while user is away from bottom or history work is active', () => {
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
|
...baseInput,
|
|
isPinned: false,
|
|
})).toBe(false);
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
|
...baseInput,
|
|
isLoadingOlder: true,
|
|
})).toBe(false);
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
|
...baseInput,
|
|
pendingRevealWork: true,
|
|
})).toBe(false);
|
|
});
|
|
});
|