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
1 change: 1 addition & 0 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"test:e2e:ask": "pnpm build && electron scripts/ask-face-e2e.mjs",
"test:e2e:askrace": "pnpm build && electron scripts/ask-race-e2e.mjs",
"test:e2e:pill": "pnpm build && electron scripts/pill-e2e.mjs",
"test:e2e:notetaker-history": "pnpm build && electron scripts/notetaker-history-e2e.mjs",
"test:e2e:screen-surface": "pnpm --filter @openinfo/contracts build && pnpm --filter @openinfo/engine build && pnpm build && electron scripts/screen-surface-e2e.mjs",
"test:e2e:vision-live": "pnpm build && electron scripts/vision-live-e2e.mjs",
"start": "pnpm build && electron .",
Expand Down
193 changes: 193 additions & 0 deletions apps/client/scripts/notetaker-history-e2e.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
/**
* Driven served e2e for the note-taker SESSION-HISTORY DRILL-DOWN (#247). Green unit/controller tests are not
* proof the SERVED window behaves: this launches REAL Electron with the REAL hud.html + REAL compiled preload
* against a minimal fake engine, opens surf-openinfo-notetaker through the PRODUCTION window constructor, and
* proves the drill-down end-to-end in the served DOM:
*
* 1) the pad boots as the three-zone note-taker and self-identifies; the left rail shows the session-history
* list with clickable rows (the wired `session-open` verb) and NO dead feature-nav tabs.
* 2) the CENTER opens on the live current-session pad.
* 3) clicking a PAST session row shows THAT session's read-only record in the center — its session summary
* and its moments, NOT the live session's — under a "Past session" header with a Back-to-live control,
* and NO Record affordance (read-only; the consent boundary — a history click starts/stops nothing).
* 4) clicking Back-to-live returns the center to the live current-session view.
* 5) a past session whose detail query comes back empty surfaces honest text ("Nothing was captured…"),
* never a blank center.
*
* THE PRODUCTION WINDOW PATH (#194, as pill-e2e): the window is built by `constructSurfaceWindow` — the EXACT
* function the shell's factory runs — so the contract assertion, spec resolution, title stamp, preload, and
* hud.html load are the production body. The fake engine bearer is injected at the defaultSession webRequest
* seam (production pins per-webContents), mirroring pill-e2e; the renderer path is the REAL shipped code.
*
* Run: pnpm --filter @openinfo/client test:e2e:notetaker-history (builds first). Needs a GUI (darwin).
*/
import http from 'node:http'
import crypto from 'node:crypto'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { dirname, join } from 'node:path'
import { app, BrowserWindow, session as electronSession } from 'electron'
import { configForSurface } from '../dist/main/window-options.js'
import { constructSurfaceWindow } from '../dist/main/surface-window.js'

const NOTETAKER_ID = 'surf-openinfo-notetaker'
const ENGINE_TOKEN = 'notetaker-history-e2e-bearer-000000000000000000001'
const LIVE_ID = 'ses-live'
const PAST_ID = 'ses-past'
const LIVE_MOMENT = 'Live: shipping the beta today'
const PAST_MOMENT = 'Past: agreed to renew for a year'
const PAST_SUMMARY = 'they agreed the one-year renewal'
const PAST_TITLE = 'Q3 renewal — security review'

const LIVE_SESSION = { id: LIVE_ID, workspaceId: 'default', modeId: 'mode-meeting', startedAt: '2026-07-16T14:00:00.000Z', title: 'Live standup', attribution: { evidence: [], confidence: 1 } }
const PAST_SESSION = { id: PAST_ID, workspaceId: 'default', modeId: 'mode-meeting', startedAt: '2026-07-10T09:00:00.000Z', endedAt: '2026-07-10T09:31:00.000Z', title: PAST_TITLE, attribution: { evidence: [], confidence: 1 } }
const moment = (id, sessionId, text, at) => ({ id, sessionId, workspaceId: 'default', at, kind: 'decision', text, refs: [], source: 'mic', confidence: 0.9 })
const summary = (id, sessionId, level, text) => ({ id, workspaceId: 'default', sessionId, level, windowStart: '2026-07-10T09:00:00Z', windowEnd: '2026-07-10T09:05:00Z', text, proposal: true, children: [], provenance: { slot: 'llm', endpoint: 'this-mac', model: 'qwen2.5-7b' }, schemaVersion: 1, createdAt: '2026-07-10T09:05:01Z' })

// A past session that captured nothing — flip via ?empty on the query (scene 5 opens its own window).
let pastEmpty = false

const loadSurface = async () => {
const here = dirname(fileURLToPath(import.meta.url))
const raw = await readFile(join(here, '..', '..', '..', 'templates', 'openinfo-notetaker', 'surface.json'), 'utf8')
return JSON.parse(raw)
}
let NOTETAKER_SURFACE

const sockets = new Set()
const authenticated = []
const unauthorized = []
const authorize = (req, res) => {
if (req.headers.authorization === `Bearer ${ENGINE_TOKEN}`) { authenticated.push(`${req.method} ${req.url}`); return true }
unauthorized.push(`${req.method} ${req.url}`)
res.writeHead(401, { 'content-type': 'application/json' }); res.end(JSON.stringify({ error: 'authentication required' })); return false
}

const server = http.createServer((req, res) => {
const url = new URL(req.url, 'http://127.0.0.1')
const json = (body) => { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify(body)) }
if (url.pathname === '/health') return json({ status: 'ok', version: 'e2e' })
if (!authorize(req, res)) return
if (url.pathname.startsWith('/layouts/surfaces/')) return json(NOTETAKER_SURFACE)
if (url.pathname === '/sessions') return json([LIVE_SESSION])
if (url.pathname === '/query' && req.method === 'POST') {
let raw = ''
req.on('data', (c) => (raw += c))
req.on('end', () => {
let query = { source: 'moments', params: {} }
try { query = JSON.parse(raw) } catch { /* default */ }
const sess = query.params?.session
if (query.source === 'sessions') return json({ source: 'sessions', items: [LIVE_SESSION, PAST_SESSION], truncated: false })
if (query.source === 'moments') {
if (sess === 'current') return json({ source: 'moments', items: [moment('m-live', LIVE_ID, LIVE_MOMENT, '2026-07-16T14:02:00Z')], truncated: false })
if (sess === PAST_ID) return json({ source: 'moments', items: pastEmpty ? [] : [moment('m-past', PAST_ID, PAST_MOMENT, '2026-07-10T09:03:00Z')], truncated: false })
return json({ source: 'moments', items: [], truncated: false })
}
if (query.source === 'summaries') {
const level = query.params?.level
if (sess === PAST_ID && !pastEmpty) return json({ source: 'summaries', items: [summary(`s-${level}`, PAST_ID, level ?? 'session', PAST_SUMMARY)], truncated: false })
return json({ source: 'summaries', items: [], truncated: false })
}
return json({ source: query.source ?? 'moments', items: [], truncated: false })
})
return
}
res.writeHead(404); res.end()
})

server.on('upgrade', (req, socket) => {
if (req.headers.authorization !== `Bearer ${ENGINE_TOKEN}`) {
unauthorized.push(`UPGRADE ${req.url}`); socket.write('HTTP/1.1 401 Unauthorized\r\nConnection: close\r\n\r\n'); socket.destroy(); return
}
authenticated.push(`UPGRADE ${req.url}`)
const accept = crypto.createHash('sha1').update(req.headers['sec-websocket-key'] + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11').digest('base64')
socket.write('HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n' + `Sec-WebSocket-Accept: ${accept}\r\n\r\n`)
sockets.add(socket); socket.on('close', () => sockets.delete(socket)); socket.on('error', () => sockets.delete(socket))
})

const fail = (msg) => { console.error(`\n[e2e] FAIL: ${msg}`); app.exit(1) }
const delay = (ms) => new Promise((r) => setTimeout(r, ms))
const makeWindow = (engineUrl) => {
const w = constructSurfaceWindow(NOTETAKER_ID, { chrome: configForSurface(NOTETAKER_ID).chrome, isDefaultHud: false, startVisible: true }, { engineUrl })
w.showInactive()
return w
}

const run = async (win) => {
const drive = (expr) => win.webContents.executeJavaScript(expr)
const waitFor = async (expr, what, tries = 100) => {
for (let i = 0; i < tries; i += 1) { if (await drive(expr).catch(() => false)) return; await delay(100) }
throw new Error(`${what} never became true`)
}
const centerText = () => drive(`document.querySelector('.nt-center')?.textContent ?? ''`)

// 1) the pad boots as the three-zone note-taker with a clickable history list and NO dead nav tabs.
await waitFor(`!!document.querySelector('.nt-app') && document.querySelectorAll('.sess-nav').length >= 2`, 'the note-taker + its clickable history rows')
if (await drive(`!!document.querySelector('.nt-navitem')`)) return fail('the dead feature-nav tabs are still rendered')
if (await drive(`document.querySelectorAll('button.nt-home').length > 0`)) return fail('the Home brand mark is still a (dead) button')
if (await drive(`document.body.textContent.includes('Enrichments')`)) return fail('the machine-word "Enrichments" header is still rendered')
console.log('[e2e] note-taker booted: clickable history, no dead nav, no machine header')

// 2) the center opens on the live current-session pad.
await waitFor(`(document.querySelector('.nt-center')?.textContent ?? '').includes(${JSON.stringify(LIVE_MOMENT)})`, 'the live moment in the center')
if (await drive(`!!document.querySelector('.nt-past-head')`)) return fail('a past-session header is showing before any row was clicked')

// 3) click the PAST session row → the center shows THAT session, not the live one.
await drive(`document.querySelector('.sess-nav[data-session="${PAST_ID}"]').click()`)
await waitFor(`!!document.querySelector('.nt-past-head')`, 'the past-session header after the click')
const past = await centerText()
if (!past.includes(PAST_TITLE)) return fail(`the past header did not name the session: ${JSON.stringify(past.slice(0, 120))}`)
if (!past.includes(PAST_MOMENT)) return fail('the past session moment is not in the center')
if (!past.includes(PAST_SUMMARY)) return fail('the past session summary is not in the center')
if (past.includes(LIVE_MOMENT)) return fail('the LIVE moment is still showing in the center of a past-session view')
if (await drive(`!!document.querySelector('.nt-center .session-record')`)) return fail('a Record control is showing in the read-only past view (consent boundary)')
if (!(await drive(`!!document.querySelector('.nt-center [data-verb="session-back"]')`))) return fail('the Back-to-live control is missing')
console.log('[e2e] past-session drill-down: center shows the past record, read-only, with Back-to-live')

// 4) Back-to-live → the live current-session view returns.
await drive(`document.querySelector('[data-verb="session-back"]').click()`)
await waitFor(`!document.querySelector('.nt-past-head')`, 'the past header clearing on Back-to-live')
const back = await centerText()
if (!back.includes(LIVE_MOMENT)) return fail('the live view did not return after Back-to-live')
console.log('[e2e] Back-to-live returned the center to the live current-session view')

if (unauthorized.length !== 0) return fail(`fake engine saw unauthenticated renderer traffic: ${unauthorized.join(', ')}`)
if (authenticated.length === 0) return fail('fake engine did not observe authenticated renderer traffic')
console.log('\n[e2e] PASS — note-taker history drill-down: clickable rows, past record in center, Back-to-live, no dead chrome')
}

const runEmptyScene = async (engineUrl) => {
// 5) a past session whose detail query returns nothing surfaces honest text, never a blank center.
pastEmpty = true
const win = makeWindow(engineUrl)
const drive = (expr) => win.webContents.executeJavaScript(expr)
const waitFor = async (expr, what, tries = 100) => {
for (let i = 0; i < tries; i += 1) { if (await drive(expr).catch(() => false)) return; await delay(100) }
throw new Error(`${what} never became true`)
}
await waitFor(`document.querySelectorAll('.sess-nav').length >= 2`, 'the empty-scene history rows')
await drive(`document.querySelector('.sess-nav[data-session="${PAST_ID}"]').click()`)
await waitFor(`!!document.querySelector('.nt-past-head')`, 'the empty-scene past header')
await waitFor(`(document.querySelector('.nt-center')?.textContent ?? '').includes('Nothing was captured in this session')`, 'the honest empty note')
if (await drive(`(document.querySelector('.nt-center')?.textContent ?? '').includes('turn on')`)) return fail('a live fresh-install prompt is showing over a finished session')
if (!(await drive(`!!document.querySelector('.nt-center [data-verb="session-back"]')`))) return fail('Back-to-live is unreachable in the empty past view')
console.log('[e2e] empty past session: honest "Nothing was captured" text, Back-to-live still reachable, never a blank')
win.destroy()
}

app.on('window-all-closed', () => {})
app.whenReady().then(async () => {
NOTETAKER_SURFACE = await loadSurface()
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve))
const engineUrl = `http://127.0.0.1:${server.address().port}`
const eventUrl = engineUrl.replace(/^http/, 'ws')
electronSession.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
const isEngine = details.url.startsWith(engineUrl) || details.url.startsWith(eventUrl)
callback({ requestHeaders: isEngine ? { ...details.requestHeaders, Authorization: `Bearer ${ENGINE_TOKEN}` } : details.requestHeaders })
})
run(makeWindow(engineUrl))
.then(() => runEmptyScene(engineUrl))
.then(() => app.exit(0))
.catch((err) => fail(String(err?.stack ?? err)))
})
setTimeout(() => fail('timed out after 60s'), 60_000)
27 changes: 27 additions & 0 deletions apps/client/src/surfaces/block-renderer/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ export interface ActionHandlers {
sessionStart?: () => void
/** Stop the live session from an on-surface control (#136) — the SAME shell `end-session` path (revokes consent). */
sessionStop?: () => void
/**
* Open a PAST session in the note-taker's center column (#247) — a client-local, READ-ONLY navigation, not
* a write and NOT a session-lifecycle action (it never starts/stops capture; the consent boundary is
* untouched). Like clarifyOpen it flips notetaker view-state and re-queries the center for the selected
* session, so no paintFeedback. The row carries the id + a resolved title + start time to name the view.
*/
sessionOpen?: (payload: { sessionId: string; title?: string; startedAt?: string }) => void
/** Return the note-taker center from a past session to the live current-session view (#247) — client-local. */
sessionBack?: () => void
}

/** Replace the target's content with a freshly rendered VNode (called on every live update). */
Expand Down Expand Up @@ -167,6 +176,8 @@ export const WIRED_VERBS: ReadonlySet<string> = new Set([
'pill-settings',
'session-start',
'session-stop',
'session-open',
'session-back',
])

/**
Expand Down Expand Up @@ -283,6 +294,22 @@ export const wireActions = (target: MountTarget, handlers: ActionHandlers): void
handlers.sessionStop()
return
}
if (verb === 'session-open' && handlers.sessionOpen) {
// #247 history drill-down: READ-ONLY navigation — flips notetaker view-state to the selected past
// session and re-queries the center. NOT a lifecycle action (no capture start/stop). No paintFeedback:
// the re-render into the past view IS the feedback. An inert row (no addressable id) is left untouched.
const sessionId = el.getAttribute('data-session')
if (sessionId === null) return
const title = el.getAttribute('data-session-title')
const startedAt = el.getAttribute('data-session-started')
handlers.sessionOpen({ sessionId, ...(title !== null ? { title } : {}), ...(startedAt !== null ? { startedAt } : {}) })
return
}
if (verb === 'session-back' && handlers.sessionBack) {
// #247: return the center from a past session to the live current-session view — client-local, no write.
handlers.sessionBack()
return
}
// Reached by a WIRED_VERBS verb whose handler was not injected, or whose button carries no payload:
// left untouched — visible-but-inert. Verbs outside WIRED_VERBS (pin, mark-for-follow-up, open,
// navigate, run-mode, draft-with) never get here — the gate above already ignored them (see
Expand Down
20 changes: 17 additions & 3 deletions apps/client/src/surfaces/blocks/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,21 @@ test('the sessions block renders a history row: derived title, start time, and a
assert.match(html, /Q3 renewal — security review/) // the resolved title
assert.match(html, /2:00p/) // the start time (viewer-local clock; UTC-pinned here)
assert.match(html, /Jul 10 · 42m/) // date + ended duration in the why line
assert.doesNotMatch(html, /ses-1/) // NEVER a raw session id at a human tier (hud-voice §2)
assert.doesNotMatch(html, /<button/) // read-only this slice: plain rows, never a fake-live click target
assert.doesNotMatch(html, />ses-1</) // NEVER a raw session id in HUMAN-VISIBLE text (hud-voice §2)…
// …but the row IS a clickable nav control (#247) carrying the id/title/start time in DATA attributes only,
// dispatching the wired `session-open` verb — a live affordance, not a dead one.
assert.match(html, /<button class="rel sess-nav" data-verb="session-open" data-session="ses-1"/)
assert.match(html, /data-session-title="Q3 renewal — security review"/)
assert.match(html, /data-session-started="2026-07-10T14:00:00Z"/)
})

test('the empty + overflow notes stay PLAIN — there is nothing to open, so no fake click target', () => {
assert.doesNotMatch(render([]), /<button/) // empty state: no session to navigate to
const many = Array.from({ length: 8 }, (_, i) => session({ id: `ses-${i}`, title: `Session ${i}` }))
const html = render(many, false, 6)
// the "N more" note is a plain div row (the earlier sessions are disclosed, not individually openable here)
assert.match(html, /<div class="rel"><span class="mk t">⋯<\/span>/)
assert.match(html, /2 earlier sessions in history/)
})

test('a live (unended) session reads "in progress", never a fabricated end', () => {
Expand All @@ -47,7 +60,8 @@ test('an untitled session falls back to an HONEST start-time name (#211), never
const { title: _title, ...untitled } = session() // omit title entirely
const html = render([untitled])
assert.match(html, /Session · Jul 10/) // the honest fallback title — the session named by when it started
assert.doesNotMatch(html, /ses-1/)
// the raw id may ride in DATA attributes (the nav payload), but never in human-visible text (hud-voice §2)
assert.doesNotMatch(html.replace(/\sdata-[a-z-]+="[^"]*"/g, ''), /ses-1/)
})

test('the empty state is explainable, not a blank card', () => {
Expand Down
Loading
Loading