Skip to content

Commit ad5ebf5

Browse files
committed
Merge main into loop/shortcuts-search
Resolve merge conflict in docs/loop/feature-ledger.md: adopt main's canonical ledger and prepend this PR's shortcuts-search (#59) row. No code changes.
2 parents 5f88f6e + 3a4f438 commit ad5ebf5

10 files changed

Lines changed: 228 additions & 8 deletions

File tree

apps/electron/src/renderer/components/app-shell/ChatDisplay.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ export const ChatDisplay = React.forwardRef<ChatDisplayHandle, ChatDisplayProps>
584584
const [visibleTurnCount, setVisibleTurnCount] = React.useState(TURNS_PER_PAGE)
585585
// Sticky-bottom: When true, auto-scroll on content changes. Toggled by user scroll behavior.
586586
const isStickToBottomRef = React.useRef(true)
587+
// Show a floating "jump to latest" button when the user has scrolled far from the bottom.
588+
const [showScrollToBottom, setShowScrollToBottom] = React.useState(false)
587589
// Mirror isFocusedPanel into a ref so the ResizeObserver closure reads the latest value
588590
const isFocusedPanelRef = React.useRef(isFocusedPanel)
589591
isFocusedPanelRef.current = isFocusedPanel
@@ -1175,6 +1177,9 @@ export const ChatDisplay = React.forwardRef<ChatDisplayHandle, ChatDisplayProps>
11751177
const distanceFromBottom = scrollHeight - scrollTop - clientHeight
11761178
// 20px threshold for "at bottom" detection
11771179
isStickToBottomRef.current = distanceFromBottom < 20
1180+
// Reveal the jump-to-latest button once the user is well away from the bottom
1181+
// (200px hysteresis so it doesn't flicker while reading near the end).
1182+
setShowScrollToBottom(distanceFromBottom > 200)
11781183

11791184
// Load more turns when scrolling near top (within 100px)
11801185
if (scrollTop < 100) {
@@ -1205,6 +1210,13 @@ export const ChatDisplay = React.forwardRef<ChatDisplayHandle, ChatDisplayProps>
12051210
return () => viewport.removeEventListener('scroll', handleScroll)
12061211
}, [handleScroll])
12071212

1213+
// Jump back to the latest message and resume sticky-bottom auto-scroll.
1214+
const scrollToBottom = React.useCallback(() => {
1215+
isStickToBottomRef.current = true
1216+
setShowScrollToBottom(false)
1217+
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
1218+
}, [])
1219+
12081220
// Auto-scroll using ResizeObserver for streaming content
12091221
// Initial scroll is handled by ScrollOnMount (useLayoutEffect, before paint)
12101222
React.useEffect(() => {
@@ -1218,6 +1230,7 @@ export const ChatDisplay = React.forwardRef<ChatDisplayHandle, ChatDisplayProps>
12181230
if (isSessionSwitch) {
12191231
isStickToBottomRef.current = true
12201232
setVisibleTurnCount(TURNS_PER_PAGE)
1233+
setShowScrollToBottom(false)
12211234
}
12221235

12231236
// Debounced scroll for streaming - waits for layout to settle
@@ -1698,7 +1711,7 @@ export const ChatDisplay = React.forwardRef<ChatDisplayHandle, ChatDisplayProps>
16981711
WebkitMaskImage: 'linear-gradient(to bottom, transparent 0%, black 32px, black calc(100% - 32px), transparent 100%)'
16991712
}}
17001713
>
1701-
<ScrollArea className="h-full min-w-0" viewportRef={scrollViewportRef}>
1714+
<ScrollArea className="h-full min-w-0" viewportRef={scrollViewportRef} data-testid="chat-transcript">
17021715
<div className={cn(
17031716
CHAT_LAYOUT.maxWidth,
17041717
"mx-auto min-w-0",
@@ -2073,6 +2086,32 @@ export const ChatDisplay = React.forwardRef<ChatDisplayHandle, ChatDisplayProps>
20732086
</div>
20742087
</ScrollArea>
20752088
</div>
2089+
2090+
{/* Jump-to-latest: floating button shown when scrolled up from the bottom */}
2091+
<AnimatePresence>
2092+
{showScrollToBottom && (
2093+
<motion.button
2094+
type="button"
2095+
onClick={scrollToBottom}
2096+
aria-label={t('chat.scrollToBottom')}
2097+
title={t('chat.scrollToBottom')}
2098+
data-testid="scroll-to-bottom"
2099+
initial={{ opacity: 0, y: 8 }}
2100+
animate={{ opacity: 1, y: 0 }}
2101+
exit={{ opacity: 0, y: 8 }}
2102+
transition={{ duration: 0.12, ease: 'easeOut' }}
2103+
className={cn(
2104+
"absolute bottom-4 left-1/2 -translate-x-1/2 z-10",
2105+
"flex items-center justify-center h-9 w-9 rounded-full",
2106+
"bg-background/90 backdrop-blur border border-border shadow-md",
2107+
"text-muted-foreground hover:text-foreground hover:bg-accent",
2108+
"transition-colors"
2109+
)}
2110+
>
2111+
<ChevronDown className="h-5 w-5" />
2112+
</motion.button>
2113+
)}
2114+
</AnimatePresence>
20762115
</div>
20772116

20782117
{/* === INPUT CONTAINER: FreeForm or Structured Input === */}

docs/loop/feature-ledger.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ log, not the system of record.
1212

1313
| status | meaning |
1414
| --- | --- |
15+
| reduce-motion | "Reduce motion" accessibility setting in Appearance | Claude desktop / macOS / Windows reduce-motion + `prefers-reduced-motion` | frontend-only | pr-open | [#50](https://github.com/modelstudioai/openwork/issues/50) | [#51](https://github.com/modelstudioai/openwork/pull/51) | loop/reduce-motion | 2026-07-03 | Renderer-only pref (localStorage) applied app-wide via `<MotionConfig reducedMotion>` + `data-reduce-motion` on `<html>` + global CSS guard. Off ⇒ `reducedMotion="user"` (still honors OS). New `ReduceMotionProvider` in `main.tsx`; toggle in Appearance→Interface; 2 new i18n keys ×7 locales. typecheck/`bun test` zero-delta vs main (56-failure set byte-identical); renderer build ✅; i18n parity ✅. CDP assertion included; **could not run locally** (egress 403s Electron binary download). |
1516
| `proposed` | Identified as a gap, not started. |
1617
| `in-progress` | Issue filed, branch open, implementation underway. |
1718
| `pr-open` | PR submitted, awaiting human review/merge. |
@@ -33,12 +34,8 @@ log, not the system of record.
3334
| slug | title | source | feasibility | status | issue | pr | branch | updated | notes |
3435
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
3536
| shortcuts-search | Search box on the Settings → Keyboard Shortcuts page | Codex "keypress search" + VS Code / Claude keybindings search; mirrors OpenWork's own settings-navigator search (#40) | frontend-only | pr-open | [#58](https://github.com/modelstudioai/openwork/issues/58) | [#59](https://github.com/modelstudioai/openwork/pull/59) | loop/shortcuts-search | 2026-07-05 | Pure renderer view over the action registry (`actionsByCategory` + `getHotkeyDisplay`); filters rows by action label **and** rendered key tokens ("keypress search"), hides empty sections, shows empty state. Reuses `common.search`/`noResultsFound`/`clear` (**zero** new i18n keys). Added `data-testid="settings-item-<id>"` to settings-nav items for e2e navigation. typecheck/renderer-build/i18n-parity zero-delta vs main; touched-area tests pass. CDP assertion written (app launch egress-blocked locally, same as prior rounds). |
36-
| command-palette-recents | Recently-used group in the Command Palette (⌘K) | VS Code ⌘⇧P / Raycast / Linear ⌘K / Claude Code Desktop command menu | frontend-only | pr-open | [#56](https://github.com/modelstudioai/openwork/issues/56) | [#57](https://github.com/modelstudioai/openwork/pull/57) | loop/command-palette-recents | 2026-07-05 | Prior round: branch + PR #57 already on GitHub (this run reconciled the ledger; PR #57 was missing the `loop-bot` label — added). |
37-
| thinking-menu-shortcut | ⌘⇧E keyboard shortcut to open the composer thinking menu | Claude Code Desktop effort-menu shortcut (⌘⇧E) | frontend-only | pr-open | [#54](https://github.com/modelstudioai/openwork/issues/54) | [#55](https://github.com/modelstudioai/openwork/pull/55) | loop/thinking-menu-shortcut | 2026-07-04 | Prior round; PR open awaiting review. |
38-
| prompt-history | Recall previously-sent prompts with Up / Down in the composer | Codex desktop composer up-arrow recall / shell history | frontend-only | pr-open | [#52](https://github.com/modelstudioai/openwork/issues/52) | [#53](https://github.com/modelstudioai/openwork/pull/53) | loop/composer-prompt-history | 2026-07-04 | Prior round; PR open awaiting review. |
39-
| reduce-motion | "Reduce motion" accessibility setting in Appearance | Claude desktop / macOS / Windows reduce-motion + `prefers-reduced-motion` | frontend-only | merged | [#50](https://github.com/modelstudioai/openwork/issues/50) | [#51](https://github.com/modelstudioai/openwork/pull/51) | loop/reduce-motion | 2026-07-08 | **Merged** into `main` (2026-07-06). Renderer-only pref (localStorage) applied app-wide via `<MotionConfig reducedMotion>` + `data-reduce-motion` on `<html>` + global CSS guard. Off ⇒ `reducedMotion="user"` (still honors OS). New `ReduceMotionProvider` in `main.tsx`; toggle in Appearance→Interface; 2 new i18n keys ×7 locales. |
40-
| composer-expand | Expand / collapse (maximize) toggle for the chat composer | Claude / ChatGPT / Codex desktop composer maximize | frontend-only | pr-open | [#48](https://github.com/modelstudioai/openwork/issues/48) | [#49](https://github.com/modelstudioai/openwork/pull/49) | loop/composer-expand | 2026-07-03 | Prior round; PR open awaiting review. |
41-
| scroll-to-bottom | "Jump to latest" (scroll-to-bottom) button in the transcript | Claude Code Desktop / ChatGPT / Codex desktop jump-to-latest | frontend-only | pr-open | [#46](https://github.com/modelstudioai/openwork/issues/46) | [#47](https://github.com/modelstudioai/openwork/pull/47) | loop/scroll-to-bottom | 2026-07-02 | Prior round; PR open awaiting review. Added a reusable `seed()` harness hook (not yet on `main`). |
42-
| thinking-level-picker | Thinking-level (reasoning effort) picker in the chat composer | Claude Code Desktop effort menu (⌘⇧E) + OpenWork's own model picker | frontend-only | merged | [#44](https://github.com/modelstudioai/openwork/issues/44) | [#45](https://github.com/modelstudioai/openwork/pull/45) | loop/thinking-level-picker | 2026-07-05 | **Merged into `main`.** `thinkingLevel`/`onThinkingLevelChange` were already plumbed to `FreeFormInput`; only the UI trigger was missing. Reuses `thinking.*` + `settings.ai.thinking` i18n keys (zero new keys). |
37+
| scroll-to-bottom | "Jump to latest" (scroll-to-bottom) button in the chat transcript | Claude Code Desktop / ChatGPT / Codex desktop jump-to-latest affordance | frontend-only | pr-open | [#46](https://github.com/modelstudioai/openwork/issues/46) | [#47](https://github.com/modelstudioai/openwork/pull/47) | loop/scroll-to-bottom | 2026-07-02 | Reuses existing `ChatDisplay` scroll state (`distanceFromBottom`, `isStickToBottomRef`, `messagesEndRef`); floating `AnimatePresence` button shown when >200px from bottom. One new i18n key `chat.scrollToBottom` across all 6 locales. Added a reusable `seed(profileDirs)` hook to the e2e harness (`app.ts`/`runner.ts`) so assertions can pre-seed an on-disk session (backend-independent) — the scroll assertion seeds a 40-message session, opens it, scrolls up, asserts the button appears, clicks it, asserts return-to-bottom + hide. typecheck/`bun test` zero-delta vs main (11 pre-existing tsc errors, 56 pre-existing test fails, identical sets); renderer build ✅. **CDP could not run locally**: the Electron binary download is 403'd by the sandbox egress policy (github release host), so the app can't launch here — assertion transpiles and is included for CI/reviewer. |
38+
| thinking-level-picker | Thinking-level (reasoning effort) picker in the chat composer | Claude Code Desktop effort menu (⌘⇧E) + OpenWork's own model picker | frontend-only | merged | [#44](https://github.com/modelstudioai/openwork/issues/44) | [#45](https://github.com/modelstudioai/openwork/pull/45) | loop/thinking-level-picker | 2026-07-02 | Merged into `main`. `thinkingLevel`/`onThinkingLevelChange` already plumbed to `FreeFormInput`; only the UI trigger was missing. Reuses `thinking.*` + `settings.ai.thinking` i18n keys (zero new keys). typecheck/`bun test` zero-delta vs main. |
39+
| composer-expand | Expand / collapse (maximize) toggle for the chat composer | Claude/ChatGPT/Codex desktop composer maximize | frontend-only | pr-open | [#48](https://github.com/modelstudioai/openwork/issues/48) | [#49](https://github.com/modelstudioai/openwork/pull/49) | loop/composer-expand | 2026-07-03 | Opened by a prior run. Adds `isComposerExpanded` toggle in `FreeFormInput`; 2 new i18n keys. Awaiting review. |
4340
| command-palette | Global command palette (⌘K/Ctrl+K) to search & run any action | Claude Code Desktop ⌘K / VS Code & Codex ⌘⇧P / Linear ⌘K | frontend-only | merged | [#41](https://github.com/modelstudioai/openwork/issues/41) | [#42](https://github.com/modelstudioai/openwork/pull/42) | loop/command-palette | 2026-07-02 | Merged into `main`. Reuses action registry `execute()` + cmdk primitives; zero new i18n keys. CDP e2e 2/2 pass. typecheck/test +0 vs main. |
4441
| settings-search | Searchable/filterable settings navigation | Claude Code Desktop / VS Code / Codex desktop settings search | frontend-only | merged | [#39](https://github.com/modelstudioai/openwork/issues/39) | [#40](https://github.com/modelstudioai/openwork/pull/40) | loop/settings-search | 2026-07-01 | Merged into `main`. Filters `SettingsNavigator` by title+description; reuses `common.search`/`common.noResultsFound` (no new locale keys). Also hardened `e2e/app.ts` teardown (per-launch profile dir + setsid process-group kill) so multiple CDP assertions run under headless xvfb. |
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/**
2+
* Feature assertion: the chat transcript's "jump to latest" (scroll-to-bottom)
3+
* button.
4+
*
5+
* Drives the real built app over CDP through the full path:
6+
* seed a 40-message session on disk → open it → transcript renders at the
7+
* bottom with the button hidden → scroll up → the floating button appears →
8+
* click it → the transcript returns to the bottom and the button disappears.
9+
*
10+
* The final steps prove the button actually *scrolls* the transcript back to
11+
* the latest message, not merely that it renders.
12+
*
13+
* A backend is NOT required: the session is pre-seeded as a plain `session.jsonl`
14+
* file under the isolated profile's default-workspace root before the app boots,
15+
* so the transcript is real, local, and scrollable without invoking qwen-code.
16+
*/
17+
18+
import { mkdirSync, writeFileSync } from 'node:fs';
19+
import { join } from 'node:path';
20+
import type { Assertion } from '../runner';
21+
import type { ProfileDirs } from '../app';
22+
23+
const SESSION_ID = 'e2e-scroll-seeded';
24+
const SESSION_NAME = 'Scroll seed';
25+
const MESSAGE_COUNT = 40;
26+
27+
const ROW = `[data-session-id="${SESSION_ID}"]`;
28+
const BUTTON = '[data-testid="scroll-to-bottom"]';
29+
30+
/** The scrollable transcript viewport (Radix ScrollArea viewport inside our tagged region). */
31+
const VIEWPORT = `document.querySelector('[data-testid="chat-transcript"] [data-radix-scroll-area-viewport]')`;
32+
33+
/** distanceFromBottom of the transcript viewport, or -1 when it isn't mounted yet. */
34+
const DISTANCE_EXPR = `(() => {
35+
const v = ${VIEWPORT};
36+
if (!v) return -1;
37+
return v.scrollHeight - v.scrollTop - v.clientHeight;
38+
})()`;
39+
40+
/**
41+
* Pre-seed a session with many messages so the transcript overflows the
42+
* viewport. Written before Electron launches; the app lists it on boot.
43+
*/
44+
function seed({ workspaceDir }: ProfileDirs): void {
45+
const sessionDir = join(workspaceDir, 'sessions', SESSION_ID);
46+
mkdirSync(sessionDir, { recursive: true });
47+
48+
const base = 1700000000000;
49+
const header = {
50+
id: SESSION_ID,
51+
workspaceRootPath: workspaceDir,
52+
name: SESSION_NAME,
53+
createdAt: base,
54+
lastUsedAt: base + MESSAGE_COUNT,
55+
lastMessageAt: base + MESSAGE_COUNT,
56+
sessionStatus: 'todo',
57+
messageCount: MESSAGE_COUNT,
58+
lastMessageRole: 'assistant',
59+
preview: 'Seeded conversation for scroll-to-bottom testing',
60+
};
61+
62+
const lines = [JSON.stringify(header)];
63+
for (let i = 1; i <= MESSAGE_COUNT; i++) {
64+
const isUser = i % 2 === 1;
65+
// Long, multi-paragraph body so 40 messages reliably overflow the viewport.
66+
const body =
67+
`${isUser ? 'User' : 'Assistant'} message ${i}.\n\n` +
68+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '.repeat(6);
69+
const msg: Record<string, unknown> = {
70+
id: `m${i}`,
71+
type: isUser ? 'user' : 'assistant',
72+
content: body,
73+
timestamp: base + i,
74+
};
75+
if (!isUser) msg.turnId = `t${i}`;
76+
lines.push(JSON.stringify(msg));
77+
}
78+
writeFileSync(join(sessionDir, 'session.jsonl'), lines.join('\n') + '\n', 'utf-8');
79+
}
80+
81+
const assertion: Assertion = {
82+
name: 'chat scroll-to-bottom button appears when scrolled up and jumps to latest',
83+
seed,
84+
async run(app) {
85+
const { session } = app;
86+
87+
// App fully mounted and at the ready AppShell (same anchors other assertions use).
88+
await session.waitForFunction(
89+
'!document.getElementById("_loader") && (document.getElementById("root")?.childElementCount ?? 0) > 0',
90+
{ timeoutMs: 30000, message: 'React UI did not mount' },
91+
);
92+
await session.waitForSelector('[aria-label="Craft menu"]', {
93+
timeoutMs: 30000,
94+
message: 'app did not reach the ready AppShell state',
95+
});
96+
97+
// 1. The seeded session appears in the sidebar list.
98+
await session.waitForSelector(ROW, {
99+
timeoutMs: 20000,
100+
message: 'seeded session row did not appear in the session list',
101+
});
102+
103+
// 2. Open it. The row selects on `mousedown` (not click), so dispatch a real
104+
// left-button pointer press on the row's button.
105+
const opened = await session.evaluate<boolean>(`(() => {
106+
const btn = document.querySelector(${JSON.stringify(ROW)} + ' button.entity-row-btn')
107+
|| document.querySelector(${JSON.stringify(ROW)} + ' button')
108+
|| document.querySelector(${JSON.stringify(ROW)});
109+
if (!btn) return false;
110+
btn.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, cancelable: true, button: 0 }));
111+
btn.dispatchEvent(new MouseEvent('mouseup', { bubbles: true, cancelable: true, button: 0 }));
112+
return true;
113+
})()`);
114+
if (!opened) throw new Error('could not find/press the seeded session row');
115+
116+
// 3. The transcript renders and overflows the viewport (proof the seeded
117+
// conversation actually loaded, not the empty/draft state).
118+
await session.waitForFunction(
119+
`(() => { const v = ${VIEWPORT}; return !!v && v.clientHeight > 0 && v.scrollHeight > v.clientHeight + 200; })()`,
120+
{ timeoutMs: 20000, message: 'seeded transcript did not render as a scrollable viewport' },
121+
);
122+
123+
// 4. On open the transcript sticks to the bottom, so the jump button is hidden.
124+
await session.waitForFunction(`${DISTANCE_EXPR} >= 0 && ${DISTANCE_EXPR} < 40`, {
125+
timeoutMs: 8000,
126+
message: 'transcript did not settle at the bottom on open',
127+
});
128+
const buttonVisibleAtBottom = await session.evaluate<boolean>(
129+
`!!document.querySelector(${JSON.stringify(BUTTON)})`,
130+
);
131+
if (buttonVisibleAtBottom) {
132+
throw new Error('scroll-to-bottom button was visible while already at the bottom');
133+
}
134+
135+
// 5. Scroll to the top. Setting scrollTop fires a scroll event; also dispatch
136+
// one explicitly so the handler recomputes regardless.
137+
await session.evaluate(`(() => {
138+
const v = ${VIEWPORT};
139+
if (!v) return false;
140+
v.scrollTop = 0;
141+
v.dispatchEvent(new Event('scroll', { bubbles: true }));
142+
return true;
143+
})()`);
144+
145+
// 6. Now well away from the bottom, the button appears.
146+
await session.waitForFunction(`${DISTANCE_EXPR} > 200`, {
147+
timeoutMs: 5000,
148+
message: 'scrolling to top did not move the viewport away from the bottom',
149+
});
150+
await session.waitForSelector(BUTTON, {
151+
timeoutMs: 5000,
152+
message: 'scroll-to-bottom button did not appear after scrolling up',
153+
});
154+
155+
// 7. Click it — it must scroll the transcript back to the latest message...
156+
const clicked = await session.evaluate<boolean>(`(() => {
157+
const btn = document.querySelector(${JSON.stringify(BUTTON)});
158+
if (!btn) return false;
159+
btn.click();
160+
return true;
161+
})()`);
162+
if (!clicked) throw new Error('could not click the scroll-to-bottom button');
163+
164+
await session.waitForFunction(`${DISTANCE_EXPR} >= 0 && ${DISTANCE_EXPR} < 40`, {
165+
timeoutMs: 8000,
166+
message: 'clicking the button did not return the transcript to the bottom',
167+
});
168+
169+
// 8. ...and hide itself again once back at the bottom.
170+
await session.waitForFunction(`!document.querySelector(${JSON.stringify(BUTTON)})`, {
171+
timeoutMs: 5000,
172+
message: 'scroll-to-bottom button did not disappear after returning to the bottom',
173+
});
174+
},
175+
};
176+
177+
export default assertion;

0 commit comments

Comments
 (0)