forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbar.spec.mjs
More file actions
642 lines (587 loc) · 30.8 KB
/
Copy pathbar.spec.mjs
File metadata and controls
642 lines (587 loc) · 30.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
/* eslint-disable @typescript-eslint/explicit-function-return-type -- plain-JS test harness */
// Bar E2E: drives the REAL built app (out/main/index.js) via Playwright's
// _electron and asserts the bar's focus contract + reveal machinery. Hermetic —
// no network needed (assertions are main-process facts; the bar renderer only
// needs Firebase to resolve a null user from empty persistence). Each launch
// gets its own throwaway --user-data-dir.
//
// Build first, then run: `pnpm test:e2e:bar` (scripts/run-bar-e2e.mjs).
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { _electron as electron } from 'playwright'
import { fileURLToPath } from 'node:url'
import { mkdtempSync, rmSync, mkdirSync } from 'node:fs'
import { tmpdir } from 'node:os'
import path from 'node:path'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const mainEntry = path.join(root, 'out', 'main', 'index.js')
const shotsDir = path.join(root, '.orb-out', 'bar-shots')
const baseEnv = {
...process.env,
OMI_E2E: '1',
OMI_AUTOMATION: '0',
OMI_SKIP_TUNNEL: '1'
}
async function launch(extraArgs = [], extraEnv = {}) {
const dir = mkdtempSync(path.join(tmpdir(), 'omi-bar-e2e-'))
const app = await electron.launch({
args: [mainEntry, `--user-data-dir=${dir}`, ...extraArgs],
env: { ...baseEnv, ...extraEnv }
})
const cleanup = async () => {
try {
await app.close()
} catch {
/* already closed */
}
try {
rmSync(dir, { recursive: true, force: true })
} catch {
/* best-effort */
}
}
return { app, cleanup }
}
/** Wait until the bar renderer reports ready and a show settles. */
async function barShow(app, mode) {
await app.evaluate((_electron, m) => {
globalThis.__omiE2E.barShow(m)
}, mode)
// The first show defers until the renderer mounts (bar:ready); poll.
for (let i = 0; i < 100; i++) {
const s = await app.evaluate(() => globalThis.__omiE2E.barState())
if (s.visible) return s
await new Promise((r) => setTimeout(r, 100))
}
throw new Error(`bar never became visible in mode ${mode}`)
}
/** The bar renderer's window is the one whose URL hash is #/bar. */
async function findBarPage(app) {
for (let i = 0; i < 100; i++) {
const page = (await app.windows()).find((w) => w.url().includes('#/bar')) ?? null
if (page) return page
await new Promise((r) => setTimeout(r, 100))
}
throw new Error('bar page (#/bar) not found')
}
test('bar focus contract: peek/ptt never take or steal focus; expanded does', async (t) => {
const { app, cleanup } = await launch()
t.after(cleanup)
await app.firstWindow()
// Instrument BEFORE any reveal: count focus events on the bar window and
// remember which window is focused now (the main window).
await app.evaluate(({ BrowserWindow, app: electronApp }) => {
globalThis.__barFocusEvents = 0
const before = BrowserWindow.getFocusedWindow()
globalThis.__focusedBefore = before ? before.id : null
// The bar window may not exist yet; hook it when it appears.
const hook = (win) => {
win.on('focus', () => {
if (globalThis.__omiE2E.barState().id === win.id) globalThis.__barFocusEvents++
})
}
BrowserWindow.getAllWindows().forEach(hook)
electronApp.on('browser-window-created', (_e, w) => hook(w))
})
// (a) PEEK: revealed inactive, unfocusable, and the previously-focused
// window keeps focus — a summoned pill must never interrupt typing.
const peek = await barShow(app, 'peek')
assert.equal(peek.visible, true, 'peek should reveal the bar')
assert.equal(peek.focusable, false, 'peek bar must be unfocusable')
assert.equal(peek.focused, false, 'peek bar must not be focused')
const afterPeek = await app.evaluate(({ BrowserWindow }) => ({
focusedNow: BrowserWindow.getFocusedWindow() ? BrowserWindow.getFocusedWindow().id : null,
barFocusEvents: globalThis.__barFocusEvents,
barId: globalThis.__omiE2E.barState().id
}))
// The load-bearing focus assertions: the bar itself never became the
// focused window and never even received a focus event. (We deliberately do
// NOT assert which window IS focused — this runs on a live desktop where
// the user's own focus changes are environment noise, and getFocusedWindow
// only reports this app's windows anyway.)
assert.notEqual(afterPeek.focusedNow, afterPeek.barId, 'peek must not move focus to the bar')
assert.equal(afterPeek.barFocusEvents, 0, 'bar fired a focus event on a summon reveal')
// (b) PTT mode: same contract — expanded listening WITHOUT focus.
await app.evaluate(() => globalThis.__omiE2E.barHide())
await new Promise((r) => setTimeout(r, 600))
const ptt = await barShow(app, 'ptt')
assert.equal(ptt.focusable, false, 'ptt bar must be unfocusable')
assert.equal(ptt.focused, false, 'ptt bar must not be focused')
// (c) EXPANDED (hotkey tap / pill click): the one mode that takes focus —
// but its window must STILL be click-through outside the visible surface
// (merge-blocker regression: a solid expanded window blocked clicks on
// everything under the invisible dead space around the panel).
await app.evaluate(() => globalThis.__omiE2E.barHide())
await new Promise((r) => setTimeout(r, 600))
const expanded = await barShow(app, 'expanded')
assert.equal(expanded.focusable, true, 'expanded bar must be focusable (chat typing)')
assert.equal(
expanded.interactive,
false,
'expanded bar must present CLICK-THROUGH — hit-testing only enables under the cursor'
)
})
test('bar hide returns cleanly and can re-reveal', async (t) => {
const { app, cleanup } = await launch()
t.after(cleanup)
await app.firstWindow()
await barShow(app, 'peek')
// Graceful hide: renderer slide-out (≤200ms) then requestHide; fallback 450ms.
// The persistent window is PARKED off-screen rather than win.hide()'d (parking
// avoids the OS window-show fade on the NEXT reveal — see window.ts), so there
// is no window 'hide' event to observe. Assert the LOGICAL visibility instead.
await app.evaluate(() => globalThis.__omiE2E.barHide())
let didHide = false
for (let i = 0; i < 20; i++) {
const s = await app.evaluate(() => globalThis.__omiE2E.barState())
if (!s.visible) {
didHide = true
break
}
await new Promise((r) => setTimeout(r, 100))
}
assert.equal(didHide, true, 'bar should hide (park off-screen) after the slide-out')
const again = await barShow(app, 'expanded')
assert.equal(again.visible, true, 'bar should re-reveal after a hide')
})
// C5 regression: pressing the summon hotkey must reveal the minimal PILL, NOT
// the expanded chat panel (Chris: "hotkey tap → pill; click the pill to expand").
// Top-edge hover reveal was removed entirely, so the summon gesture is the only
// reveal path. A pill is unfocusable (peek); the expanded chat is the one
// focusable mode — asserting !focusable proves the hotkey did NOT open the chat.
test('summon hotkey reveals the pill (peek), never the expanded chat (C5)', async (t) => {
const { app, cleanup } = await launch()
t.after(cleanup)
await app.firstWindow()
await app.evaluate(() => globalThis.__omiE2E.barEnable())
await findBarPage(app) // ensure the bar renderer has mounted (bar:ready)
await app.evaluate(() => globalThis.__omiE2E.barSummonFire())
let s = null
for (let i = 0; i < 100; i++) {
s = await app.evaluate(() => globalThis.__omiE2E.barState())
if (s.visible) break
await new Promise((r) => setTimeout(r, 50))
}
assert.ok(s && s.visible, 'summon hotkey should reveal the bar')
assert.equal(s.focusable, false, 'summon reveals the unfocusable PILL, not the focusable chat')
assert.equal(s.focused, false, 'the summoned pill must not steal focus')
})
// Reveal-size guard (fullscreen cross-DPI bug): a summoned bar must reveal at the
// computed size for its target monitor, never oversized. The live bug was a bar
// summoned while another app was FULLSCREEN on a mixed-DPI multi-monitor setup
// revealing ~1.5× too large (off-center + blurry) — Windows sized the final
// on-screen setBounds under the parked corner's monitor scale. unparkWindow now
// re-applies setBounds when the size drifted. This asserts the revealed window is
// not oversized relative to BAR_WINDOW_WIDTH/MAX_HEIGHT (+rounding slack); the
// drift predicate itself is unit-tested in placement.test.ts (boundsSizeDrifted).
test('summon reveals the bar at the computed size, never oversized (fullscreen DPI)', async (t) => {
const { app, cleanup } = await launch()
t.after(cleanup)
await app.firstWindow()
await app.evaluate(() => globalThis.__omiE2E.barEnable())
await findBarPage(app)
await app.evaluate(() => globalThis.__omiE2E.barSummonFire())
let st = null
for (let i = 0; i < 100; i++) {
st = await app.evaluate(() => globalThis.__omiE2E.barState())
if (st.visible) break
await new Promise((r) => setTimeout(r, 50))
}
assert.ok(st && st.visible, 'summon should reveal the bar')
const b = await app.evaluate(({ BrowserWindow }, id) => {
const win = id != null ? BrowserWindow.fromId(id) : null
return win ? win.getBounds() : null
}, st.id)
assert.ok(b, 'bar window bounds should be readable')
// BAR_WINDOW_WIDTH = 560, BAR_WINDOW_MAX_HEIGHT = 640; +4px absorbs the ±1px
// rounding a fractional (1.5×) monitor produces. The bug revealed 840×960.
assert.ok(b.width <= 564, `bar revealed oversized: width ${b.width} (expected ≤ 564)`)
assert.ok(b.height <= 644, `bar revealed oversized: height ${b.height} (expected ≤ 644)`)
})
// The user's reported trigger: with an Omi window ITSELF FULLSCREEN, a summoned
// bar revealed bigger/off-center. This drives that exact scenario — fullscreen the
// main window, then summon — and asserts the bar reveals at the computed size, not
// oversized. Note: on normally-composited hardware this passes without the fix
// (an Electron/borderless fullscreen does not de-composite the monitor, so the
// final on-screen setBounds sizes correctly); the fix's corrective re-apply is the
// safety net for the case where the monitor IS de-composited. This is the live
// guard for "fullscreen main window → correct bar size" regardless.
test('main window fullscreen: summoned bar still reveals at the computed size', async (t) => {
const { app, cleanup } = await launch()
t.after(cleanup)
await app.firstWindow()
// Fullscreen the largest visible non-bar window (the main window).
const fs = await app.evaluate(({ BrowserWindow }) => {
const wins = BrowserWindow.getAllWindows().filter(
(w) => !w.webContents.getURL().includes('#/bar') && w.isVisible()
)
wins.sort(
(a, b) =>
b.getBounds().width * b.getBounds().height - a.getBounds().width * a.getBounds().height
)
const main = wins[0] || BrowserWindow.getAllWindows()[0]
main.setFullScreen(true)
return { id: main.id, isFullScreen: main.isFullScreen() }
})
await new Promise((r) => setTimeout(r, 800))
await app.evaluate(() => globalThis.__omiE2E.barEnable())
await findBarPage(app)
await app.evaluate(() => globalThis.__omiE2E.barSummonFire())
let st = null
for (let i = 0; i < 100; i++) {
st = await app.evaluate(() => globalThis.__omiE2E.barState())
if (st.visible) break
await new Promise((r) => setTimeout(r, 50))
}
assert.ok(st && st.visible, 'summon should reveal the bar with the main window fullscreen')
const b = await app.evaluate(({ BrowserWindow }, id) => {
const win = id != null ? BrowserWindow.fromId(id) : null
return win ? win.getBounds() : null
}, st.id)
assert.ok(b, 'bar window bounds should be readable')
assert.ok(
b.width <= 564,
`bar revealed oversized with main fullscreen (fs=${fs.isFullScreen}): width ${b.width} (≤ 564)`
)
assert.ok(
b.height <= 644,
`bar revealed oversized with main fullscreen (fs=${fs.isFullScreen}): height ${b.height} (≤ 644)`
)
await app.evaluate(
({ BrowserWindow }, id) => BrowserWindow.fromId(id)?.setFullScreen(false),
fs.id
)
})
// Regression for the blank-bar paint race (C11): main used to showInactive()
// the HWND BEFORE the renderer had painted the revealing frame, so the compositor
// flashed the previous un-revealed frame — a blank window on first hover. The fix
// holds the HWND hidden until the renderer acks (double-rAF) it painted the
// revealed frame. This test proves (a) the structural invariant: the show is
// DEFERRED after arming, not synchronous; and (b) the observable outcome: the
// first frame the window shows is the revealing (fade/scale-in) frame, not the
// invisible pre-reveal one.
test('paint-ack: reveal defers the HWND show until the renderer paints slide-in', async (t) => {
const { app, cleanup } = await launch()
t.after(cleanup)
await app.firstWindow()
// Create the bar window (hidden) and locate its renderer page.
await app.evaluate(() => globalThis.__omiE2E.barEnable())
const barPage = await findBarPage(app)
// Settle bar:ready so the MEASURED reveal below goes through the present path
// (not the first-show pendingShow defer) — otherwise the structural assertion
// is meaningless. A quick reveal+hide does this; the window is re-hidden, so
// the next reveal still repaints slide-in from an off-screen start.
await barShow(app, 'peek')
await app.evaluate(
() =>
new Promise((resolve) => {
globalThis.__omiE2E.barHide()
setTimeout(resolve, 700) // > slide-out (200) + hide fallback (450)
})
)
// (a) Structural invariant (the fix, proven deterministically): arming a
// reveal must NOT show the HWND synchronously — it is deferred until the paint
// ack. Immediately after the barShow call resolves, the bar is still hidden
// (the ack needs a double-rAF + IPC round-trip, tens of ms away). Pre-fix,
// showInactive() ran synchronously inside showBar, so the bar was already
// visible here — THIS is the assertion that fails on the pre-fix code.
await app.evaluate(() => globalThis.__omiE2E.barShow('peek'))
const rightAfterArm = await app.evaluate(() => globalThis.__omiE2E.barState())
assert.equal(
rightAfterArm.visible,
false,
'reveal must defer the HWND show until the paint ack (pre-fix showed synchronously)'
)
// (b) Observable outcome: read .bar-slide the instant the window becomes
// visible. Because the show was gated on the paint ack, the reveal (a scale +
// fade GROW from the top-center seat, opacity 0→1) is already underway — so
// .bar-slide is fading/growing IN, never the invisible pre-reveal frame
// (opacity 0) the pre-fix code would have shown. (The entrance no longer uses
// an off-screen translateY(-110%); the anti-blank guarantee is stronger — the
// pre-reveal state is simply invisible, so a first opacity > 0 proves the show
// was gated on the revealing frame.)
let first = null
for (let i = 0; i < 100 && !first; i++) {
const s = await app.evaluate(() => globalThis.__omiE2E.barState())
if (s.visible) {
first = await barPage.evaluate(() => {
const el = document.querySelector('.bar-slide')
if (!el) return { opacity: 'no-element', transform: 'no-element' }
const cs = getComputedStyle(el)
return { opacity: cs.opacity, transform: cs.transform }
})
break
}
await new Promise((r) => setTimeout(r, 50))
}
assert.ok(first, 'bar never became visible after the paint ack')
assert.notEqual(first.opacity, 'no-element', '.bar-slide missing at reveal')
assert.ok(
parseFloat(first.opacity) > 0,
`visible frame was the invisible pre-reveal state (opacity ${first.opacity}, ` +
`transform "${first.transform}") — paint ack did not gate on the revealing frame`
)
})
// Bug A regression: a normal mouse move onto the pill + click must expand into
// the chat surface. The reported bug was the pill "not expanding": main
// left the window click-through until an async renderer mouseenter → IPC round
// trip flipped hit-testing on, so a fast click landed first and passed through.
// The fix drives interactivity from the OS cursor in main (peekTick). This test
// drives the REAL built app: reveal the pill, locate its rect, move+click it,
// and assert the bar expanded (focusable) with the hub composer shown.
// Signed-in (OMI_E2E_FAKE_AUTH) so the expanded surface renders the real hub,
// not the signed-out prompt. Repeated to prove it is reliable, not flaky.
//
// (Note: Playwright's page.mouse dispatches via CDP, below the OS window-message
// layer that setIgnoreMouseEvents gates, so this asserts the click→expand WIRING
// + rendered surface end-to-end; the OS-cursor→interactivity race itself is
// covered deterministically by the main/bar/watchdog.test.ts unit tests.)
test('pill click expands into the chat surface (Bug A)', async (t) => {
const { app, cleanup } = await launch([], { OMI_E2E_FAKE_AUTH: '1' })
t.after(cleanup)
await app.firstWindow()
// Live-desktop cursor sits outside the peek footprint; hold the pill open so
// the retract watchdog can't hide it between reveal and click.
await app.evaluate(() => globalThis.__omiE2E.barHoldPeekOpen(true))
const barPage = await findBarPage(app)
for (let i = 0; i < 5; i++) {
await barShow(app, 'peek')
// A REAL click on the pill. Playwright's locator.click auto-waits for the
// element to be visible + STABLE (so the slide-in animation has settled) and
// that it receives pointer events, then dispatches a real click — far more
// robust than a raw mouse.move+click at a rect read mid-animation.
await barPage.locator('.bar-content[role="button"]').click()
// Expand is async: the mode IPC flips focus in main immediately, but the
// renderer's pill→panel morph + content render lands a beat later. Wait for
// the expanded surface's content rather than reading once (that read raced the
// morph). Presence of the hub's "Ask Omi" inline input proves the click
// reached the real chat surface. (Mac parity: the hub has no idle connected-
// agent rows — see the pills-only regression below.)
await barPage.waitForFunction(() => {
const active = document.querySelector('.bar-content-active')
if (!active) return false
return !!active.querySelector('textarea[placeholder*="Ask Omi"]')
})
const s = await app.evaluate(() => globalThis.__omiE2E.barState())
assert.equal(s.focusable, true, `pill click #${i} must expand the bar (focusable)`)
// Back to a pill for the next iteration.
await app.evaluate(() => globalThis.__omiE2E.barHide())
await new Promise((r) => setTimeout(r, 700))
}
})
// Bug A live gap: a pill summoned by a HOTKEY HOLD (mode 'ptt') must expand on
// click just like a tap-summoned peek pill. The original interactivity watch was
// peek-only, so a ptt-mode pill (the one that lingers after a hold) had no watch
// arming click-to-expand. The fix runs the interactivity half of the watch in
// EVERY visible collapsed mode (peek + ptt); retract stays peek-only. This drives
// a ptt reveal + pill click and asserts it reaches the same expanded chat surface.
// (CDP click bypasses OS hit-testing; the OS-cursor path in ptt is proven by the
// barWatchPlan unit test + the real-cursor pywinauto run noted in the PR.)
test('pill click expands from a ptt-summoned pill too (Bug A live gap)', async (t) => {
const { app, cleanup } = await launch([], { OMI_E2E_FAKE_AUTH: '1' })
t.after(cleanup)
await app.firstWindow()
const barPage = await findBarPage(app)
await barShow(app, 'ptt')
// The ptt pill is collapsed (!expanded), so its content is clickable; a click
// must expand into the shared chat surface (the hub's Ask-Omi input).
await barPage.locator('.bar-content[role="button"]').click()
await barPage.waitForFunction(() => {
const active = document.querySelector('.bar-content-active')
if (!active) return false
return !!active.querySelector('textarea[placeholder*="Ask Omi"]')
})
const s = await app.evaluate(() => globalThis.__omiE2E.barState())
assert.equal(s.focusable, true, 'a ptt-summoned pill must expand on click (focusable)')
})
// Hub inline-input regression (fix/win-hub-inline-input): clicking/focusing the
// hub's "Ask Omi anything" input must NOT navigate — the surface only flips to the
// conversation on SEND (macOS AskAIInputView: .mainInput → .mainResponse on send).
// Drives the REAL built app (signed-in fake auth) end-to-end: expand the bar,
// confirm the hub hosts the inline input, focus+click it and assert we stay on the
// hub (no back chevron), then type + Enter and assert the conversation opens (the
// back chevron appears). The view flip is a renderer transition, independent of the
// backend, so it is deterministic under fake auth with no network.
test('hub Ask-Omi input: focus stays on the hub; only send opens the conversation', async (t) => {
mkdirSync(shotsDir, { recursive: true })
const { app, cleanup } = await launch([], { OMI_E2E_FAKE_AUTH: '1' })
t.after(cleanup)
await app.firstWindow()
await app.evaluate(() => globalThis.__omiE2E.barHoldPeekOpen(true))
const barPage = await findBarPage(app)
await barShow(app, 'expanded')
// The hub hosts the inline input, not a navigate-on-click row.
const input = barPage.locator('.bar-content-active textarea[placeholder*="Ask Omi"]')
await input.waitFor({ state: 'visible' })
// Auto-focus on expand (Mac AskAIInputView focusOnAppear): the hub input holds
// the cursor on the real expand path — no click needed. This is the end-to-end
// proof of the focus fix (BarChatSurface stays mounted while collapsed, so the
// focus effect must key on becoming-expanded, not just the view).
await barPage.waitForFunction(() => {
const el = document.querySelector('.bar-content-active textarea[placeholder*="Ask Omi"]')
return !!el && document.activeElement === el
})
// Focusing + clicking the input must not navigate: no back chevron appears.
await input.click()
await barPage.evaluate(() => document.querySelector('.bar-content-active textarea')?.focus())
await new Promise((r) => setTimeout(r, 250))
assert.equal(
await barPage.locator('[aria-label="Back to list"]').count(),
0,
'clicking/focusing the hub input must NOT open the conversation'
)
await barPage.screenshot({ path: path.join(shotsDir, 'bar-hub-input-idle.png') })
// Typing + Enter sends and opens the conversation (the back chevron appears).
await input.fill('hub input smoke test')
await input.press('Enter')
await barPage.locator('[aria-label="Back to list"]').waitFor({ state: 'visible' })
const s = await app.evaluate(() => globalThis.__omiE2E.barState())
assert.equal(s.focusable, true, 'the conversation surface stays focusable for typing')
await barPage.screenshot({ path: path.join(shotsDir, 'bar-hub-input-conversation.png') })
})
// Omi Chat row regression (fix/win-bar-omi-chat-row): after the hub input was made
// focus-only (#209) and the idle agent launcher rows were removed (#220), there was
// no way to open the shared Omi conversation from the bar WITHOUT sending a message.
// Mac's FloatingControlBarView renders a static notchOmiChatRow (the assistant's own
// chat entry) above the pills for exactly this. Drives the REAL built app (signed-in
// fake auth): expand the hub, confirm the "Omi Chat" row is present alongside the
// (still focus-only) input, click it, and assert the conversation opens (back chevron
// appears) — a pure view flip, NOT a send (the input was never touched, so an empty
// draft could not have produced a turn; the empty-thread invite renders instead).
test('hub Omi Chat row opens the conversation without sending (fix/win-bar-omi-chat-row)', async (t) => {
mkdirSync(shotsDir, { recursive: true })
const { app, cleanup } = await launch([], { OMI_E2E_FAKE_AUTH: '1' })
t.after(cleanup)
await app.firstWindow()
await app.evaluate(() => globalThis.__omiE2E.barHoldPeekOpen(true))
const barPage = await findBarPage(app)
await barShow(app, 'expanded')
// The hub renders both the focus-only Ask-Omi input AND the static Omi Chat row.
await barPage
.locator('.bar-content-active textarea[placeholder*="Ask Omi"]')
.waitFor({ state: 'visible' })
const omiChatRow = barPage.locator('.bar-content-active button', { hasText: 'Omi Chat' })
await omiChatRow.waitFor({ state: 'visible' })
// It is a ROW below the input, not the input itself.
assert.equal(await omiChatRow.count(), 1, 'the hub must render exactly one Omi Chat row')
await barPage.screenshot({ path: path.join(shotsDir, 'bar-hub-omi-chat-row.png') })
// A single click opens the shared conversation (the back chevron appears). The
// input was never touched, so this cannot be a send.
await omiChatRow.click()
await barPage.locator('[aria-label="Back to list"]').waitFor({ state: 'visible' })
const s = await app.evaluate(() => globalThis.__omiE2E.barState())
assert.equal(s.focusable, true, 'the opened conversation surface stays focusable for typing')
// Positive proof no message was sent: the empty-thread invite renders (a thread
// with any turn would show the message list instead of this copy).
await barPage
.locator('.bar-content-active', { hasText: 'Ask Omi anything, or hold Space to talk.' })
.waitFor({ state: 'visible' })
await barPage.screenshot({ path: path.join(shotsDir, 'bar-omi-chat-conversation.png') })
// Back returns to the hub, where the Omi Chat row is present again.
await barPage.locator('[aria-label="Back to list"]').click()
await omiChatRow.waitFor({ state: 'visible' })
})
// Mac-parity regression (fix/win-bar-pills-only): the expanded hub must NOT
// render idle connected-agent summon rows. Upstream Mac's bar list is strictly
// pills-for-actual-runs; connecting agents lives in Settings → Agents. Even
// though the built-in "Claude Code" adapter is CONNECTED under fake auth (so the
// OLD hub would have shown its row), the hub must now show only the Ask-Omi
// composer (no run pills are spawned in this hermetic launch). Drives the REAL
// built app, signed-in, and captures the surface for the skeptical review.
test('bar expanded hub renders no idle connected-agent rows (Mac parity)', async (t) => {
mkdirSync(shotsDir, { recursive: true })
const { app, cleanup } = await launch([], { OMI_E2E_FAKE_AUTH: '1' })
t.after(cleanup)
await app.firstWindow()
await app.evaluate(() => globalThis.__omiE2E.barHoldPeekOpen(true))
const barPage = await findBarPage(app)
await barShow(app, 'expanded')
// Wait for the expanded hub to render its composer.
await barPage.waitForFunction(() => {
const active = document.querySelector('.bar-content-active')
return !!active?.querySelector('textarea[placeholder*="Ask Omi"]')
})
await new Promise((r) => setTimeout(r, 900)) // morph + content dissolve settle
// No idle connected-agent row: the removed row rendered the adapter's
// displayName ("Claude Code") plus a "Ready"/"Working…" status line. Assert
// neither appears in the expanded hub, even though Claude Code IS connected.
const rowText = await barPage.evaluate(() => {
const active = document.querySelector('.bar-content-active')
if (!active) return { claudeCode: -1, ready: -1 }
const texts = [...active.querySelectorAll('*')].map((e) => (e.textContent ?? '').trim())
return {
claudeCode: texts.filter((t) => t === 'Claude Code').length,
ready: texts.filter((t) => t === 'Ready' || t === 'Working…').length
}
})
assert.equal(rowText.claudeCode, 0, 'expanded hub must not render a "Claude Code" summon row')
assert.equal(rowText.ready, 0, 'expanded hub must not render an agent Ready/Working status line')
await barPage.screenshot({ path: path.join(shotsDir, 'bar-expanded-hub.png') })
})
// Bug C: the collapsed pill shows "Listening" while the orb is in its listening
// pose (always-on mic live), and the resting "Omi" wordmark otherwise. Drives a
// REAL listening state: signed-in (fake auth) + the continuousRecording pref
// flipped on via the bar's own localStorage prefs channel — no test-only render
// hook. Asserts the label flips Omi→Listening and captures the pill for review.
test('pill shows the Listening label in the listening pose (Bug C)', async (t) => {
mkdirSync(shotsDir, { recursive: true })
const { app, cleanup } = await launch([], { OMI_E2E_FAKE_AUTH: '1' })
t.after(cleanup)
await app.firstWindow()
await app.evaluate(() => globalThis.__omiE2E.barHoldPeekOpen(true))
const barPage = await findBarPage(app)
await barShow(app, 'peek')
const labelText = () =>
barPage.evaluate(() => document.querySelector('.bar-pill-label')?.textContent ?? null)
// Resting pill: the "Omi" wordmark (continuous recording off).
await barPage.waitForFunction(
() => document.querySelector('.bar-pill-label')?.textContent === 'Omi'
)
assert.equal(await labelText(), 'Omi', 'resting pill should show the Omi wordmark')
// Flip always-on mic ON through the real preferences channel (the bar listens
// for the cross-window `storage` event and re-derives the orb pose).
await barPage.evaluate(() => {
const KEY = 'omi-windows-prefs-v1'
const prefs = JSON.parse(localStorage.getItem(KEY) || '{}')
prefs.continuousRecording = true
localStorage.setItem(KEY, JSON.stringify(prefs))
window.dispatchEvent(
new StorageEvent('storage', { key: KEY, newValue: localStorage.getItem(KEY) })
)
})
await barPage.waitForFunction(
() => document.querySelector('.bar-pill-label')?.textContent === 'Listening'
)
assert.equal(await labelText(), 'Listening', 'listening pose should show the Listening label')
await new Promise((r) => setTimeout(r, 400)) // let the orb settle for the shot
await barPage.screenshot({ path: path.join(shotsDir, 'bar-peek-listening.png') })
})
test('bar screenshots (collapsed / expanded) for the skeptical review', async (t) => {
mkdirSync(shotsDir, { recursive: true })
for (const [suffix, args] of [
['100', []],
['150', ['--force-device-scale-factor=1.5']]
]) {
const { app, cleanup } = await launch(args)
t.after(cleanup)
await app.firstWindow()
// Live-desktop capture: the cursor sits outside the peek footprint, so the
// retract watchdog would (correctly) hide the bar mid-screenshot — hold it
// open for the duration of the capture.
await app.evaluate(() => globalThis.__omiE2E.barHoldPeekOpen(true))
await barShow(app, 'peek')
// The bar page is the window whose URL hash is #/bar.
let barPage = null
for (let i = 0; i < 50 && !barPage; i++) {
barPage = (await app.windows()).find((w) => w.url().includes('#/bar')) ?? null
if (!barPage) await new Promise((r) => setTimeout(r, 100))
}
assert.ok(barPage, 'bar page not found')
await new Promise((r) => setTimeout(r, 700)) // let the slide-in + genesis settle
await barPage.screenshot({ path: path.join(shotsDir, `bar-peek-${suffix}.png`) })
await app.evaluate(() => globalThis.__omiE2E.barShow('expanded'))
await new Promise((r) => setTimeout(r, 900)) // morph + content dissolve
await barPage.screenshot({ path: path.join(shotsDir, `bar-expanded-${suffix}.png`) })
await cleanup()
}
})