diff --git a/app/AGENTS.md b/app/AGENTS.md index 764a0e15..6f499545 100644 --- a/app/AGENTS.md +++ b/app/AGENTS.md @@ -1,11 +1,11 @@ # Flutter client — working agreement ## Scope and acceptance -- Only change files under `app/`. The Go server, the web proxy (`web/`), installation and deployment are read-only. Never restart shared services or manipulate real operator chats/runs for testing. +- Only change source files under `app/`. The Go server, web proxy (`web/`) and installation scripts are read-only. User-requested web/server deployment and APK publication are allowed through the installer after checking quiescence and preserving a rollback. Never restart shared services merely for client tests or manipulate real operator chats/runs for testing. - This Flutter app is the only client: it replaced the former JavaScript web client and the Kotlin Android app. - No backend changes; report missing capabilities. - Standard Material and Cupertino controls, including buttons/menus in custom graphs/diffs/chat. System typography, theme colors, light/dark, content-driven layout and text scaling. No fixed row/bubble/button dimensions, bespoke palette or CSS token port. Platform differences are intentional. Centralize necessary layout constraints; do not ban legitimate native default spacing or graph coordinates. -- Develop and test ONLY web now. No ADB, emulators, device changes, Android/iOS builds or installs. Keep source portable to all three targets. Explicitly report mobile as unverified. +- Develop and test on web by default; user-requested Android release APK builds and publication are allowed. Device testing/installations still require explicit authorization and the leases below: no ad-hoc ADB, emulators or device changes. Keep source portable to all three targets. Distinguish APK build/publication from on-device verification; report mobile behavior as unverified when no device test ran. - Small cohesive files (aim below 250 lines; split by responsibility, not arbitrary fragments). Each task owns a directory and its tests. Do not edit another lane or root pubspec/main unless assigned. - Code quality is a delivery requirement. No minified implementations, silent capability fallbacks, fake data masking missing features, or workarounds that bypass the real defect. A pipeline success does not waive missing behavior, native controls, regression coverage or rendered evidence. Label incomplete work honestly and complete it before claiming parity. - The manager drives authorized routine integration and recovery without repeatedly stopping for permission. Feature implementation stays in pipelines where appropriate; infrastructure blockers can be resolved directly within the user's authorized scope. Verify quiescence, preserve data and rollback, act, and report actual results. Ask only for genuinely new scope or unresolved destructive choices. @@ -20,7 +20,7 @@ ## Tools and verification Flutter: `/Users/alan/development/flutter/bin/flutter`; Dart beside it. Run pub get per worktree; never upgrade shared SDK. Focused `flutter test test/` while editing, `flutter analyze` and `flutter build web` for integrated acceptance. No Go/legacy client checks needed for app-only changes. Rendered changes require real browser interaction/captures; widget tests alone are not browser evidence. Use isolated loopback servers and OS-assigned ports. Browser automation may use Chrome DevTools, with independent scripts under `app/tool/`; do not modify legacy browser drivers. Never disable authentication on exposed services. -Keep commits referenced; do not discard unrelated work or delete branches. No deployment/canonical URL cutover. Land candidates per selected pipeline; manager verifies actual ancestry and serves a separate preview. +Keep commits referenced; do not discard unrelated work or delete branches. Deploy only when requested by the user; preserve existing public URLs unless a cutover is part of that request. Land candidates per selected pipeline; manager verifies actual ancestry and records source, checks, landing and deployment separately. ## Devices and the resource pool (Android builds) diff --git a/app/notes/chat-stage-debug-queue.md b/app/notes/chat-stage-debug-queue.md index cd942839..52da1932 100644 --- a/app/notes/chat-stage-debug-queue.md +++ b/app/notes/chat-stage-debug-queue.md @@ -5,10 +5,27 @@ tests or phone installation are authorized/claimed; deployment is web + APK feed | Item | Source | Verification | Landing | Deployment | | --- | --- | --- | --- | --- | -| Send follow-ups while busy | Composer keeps Send beside a separate Stop; server queues without interruption | Both UI hosts: repeat follow-ups, pending-ack duplicate guard, newer draft preservation, 320px/2x text. 14 composer widget tests pass; attachment-send tests passed; server queued-prompt regression passes | Pending manager commit | Pending combined release | -| Streamed reasoning | Independent reasoning worktree | Pending | Pending | Pending | -| Collapsed stage input/output | Independent stage-debug worktree | Pending | Pending | Pending | -| Exact-visit raw input/output/memory/session debugging | Independent stage-debug worktree | Pending | Pending | Pending | +| Send follow-ups while busy | `91854148`: Send beside separate Stop; server queues without interruption | Both hosts: repeated follow-ups, pending-ack duplicate guard, newer draft preservation, 320px/2x text; server queued-prompt regression passes | Main | APK building; web installer next | +| Streamed reasoning | `fa818341` + integration `8e980564`: live inline disclosure, active reply identity survives queued follow-ups | Full integrated check + browser visible streaming/OCR and post-follow-up update pass | Merged main; ancestry verified | APK building; web installer next | +| Collapsed stage input/output | `027be68a`: Summary sections start closed | Both-host regressions fail before fixes; real browser confirms hidden bodies initially | Merged main; ancestry verified | APK building; web installer next | +| Exact-visit raw input/output/memory/session debugging | `28539298`: recorded turn documents in Session with safe viewer | Both-host missing/capture/repair/repeated-visit isolation tests; real browser opens all three exact recorded files | Merged main; ancestry verified | APK building; web installer next | + +## Integrated acceptance + +- `tool/check_full.sh`: clean analysis, all 1,762 tests pass. +- `flutter build web --no-pub -o build/chat_stage_debug_web`: pass. Avoid concurrent + pub-get jobs in one checkout; their generated iOS plugin symlink updates race. +- `node tool/chat_stage_debug_probe.mjs build/chat_stage_debug_web build/chat-stage-debug-evidence`: + 17 checks/8 captures pass. Uses the normal app and loopback protocol/artifact + fixtures, actual pointer/text input and OCR for canvas-painted SelectableText. + Confirms live reasoning plus text, queued follow-up without interrupt, further + reasoning updates, collapsed stage fields, session export action, and exact + input.md/output.md/memory.md bytes with Back restoring the same visit. +- OpenCode normalization regressions `TestChatStreamRealV2Shapes` and + `TestChatDeltaPartIDsNeverCollide` pass (no backend changes). +- All UI code remains under app/; no production chat/run mutations or device use. +- App working agreement updated as requested: authorized installers/APK delivery + are allowed; default testing stays on web and device leases remain required. ## Build recovery diff --git a/app/notes/standard-back-navigation.md b/app/notes/standard-back-navigation.md index 9b29c72c..d9f39936 100644 --- a/app/notes/standard-back-navigation.md +++ b/app/notes/standard-back-navigation.md @@ -30,4 +30,33 @@ The user explicitly approved overriding the app's no-deploy/no-APK rules for the requested web/server installation and APK publication, without device tests. -Deployment results are recorded after running the installers. +Source landed on main as `7f88f14a`; ancestry checked after commit. Unrelated +untracked `.claude/` remains untouched (the installer therefore labels the server +build dirty). + +- `./install --web-port 8083`: built and installed the Docker web bundle and + native server. Port 8082 belongs to an unrelated scratch server and was not + disturbed. No pipeline definitions or versions were created or changed. +- The old server/ntfy were managed by separate legacy LaunchAgents, not the + installer supervisor. After checking no executing runs or active chats, the + legacy server/ntfy agents were disabled/unloaded (their plist files retained), + and `net.a-wan.pipelines` now supervises server/ntfy/web on 8080/8090/8083. + Server ping identifies commit `7f88f14a`; the original OpenCode endpoint and + existing database/artifacts are retained. The legacy web agent remains running + so existing public URLs do not change. +- Installation/config/binary/SQLite rollback material: + `~/.local/share/pipelines/backups/navigation-20261024-014504/`. +- Copied the installed web bundle to the existing preview's root using a rename + swap. Rollback: `app/build/web-before-native-navigation-1792802826/`. +- Authenticated JS byte hashes match the installed bundle at localhost ports + 8083, 8095, 8098 and the existing tailnet HTTPS ports 8443 and 8096. All five + still reject unauthenticated bundle requests. JS SHA256: + `49915ab0084e9b6437db2e8151e07397d187ab064a23687664cbf09ea7410a9e`. +- Reran all 12 browser checks against the Docker-built installed bundle through + isolated fixtures; captures/results: `app/build/navigation-deployed-evidence/`. +- `./install --apk` began the Docker APK build. The tool invocation timed out + after 120 seconds but left its container building. Waiting for that exact + container found a later Gradle daemon failure and confirmed Docker OOM event. + No APK from that failed build was published. Docker build-only memory limits + are corrected in `49b92ee0`; publication proceeds with the combined follow-up + release tracked in `chat-stage-debug-queue.md`. diff --git a/app/tool/chat_stage_debug_probe.mjs b/app/tool/chat_stage_debug_probe.mjs new file mode 100644 index 00000000..9b67e98e --- /dev/null +++ b/app/tool/chat_stage_debug_probe.mjs @@ -0,0 +1,161 @@ +// Real normal-app interaction against isolated, deterministic protocol data. +// node tool/chat_stage_debug_probe.mjs +import assert from 'node:assert/strict'; +import { mkdtemp, mkdir, writeFile } from 'node:fs/promises'; +import { once } from 'node:events'; +import { execFile } from 'node:child_process'; +import { promisify } from 'node:util'; +import { tmpdir } from 'node:os'; +import { join, resolve } from 'node:path'; +import { startFixture } from './runs_probe_server.mjs'; +import { launchChrome, waitForPort, waitForPage, connect, sleep } from './pipelines_probe_cdp_lib.mjs'; +import { enableSemantics, assertName, capture, waitFor, axNodes, clickAt } from './pipelines_probe_cdp_input.mjs'; + +const output = resolve(process.argv[3] ?? 'build/chat-stage-debug-evidence'); +await mkdir(output, { recursive: true }); +const files = { + '/artifacts/77/1/input.md': '# Raw input\nExact original harness input.\n', + '/artifacts/77/1/output.md': '# Raw output\nExact original harness output.\n', + '/artifacts/77/1/memory.md': '# Memory\nExact memory read by the stage.\n', + '/artifacts/77/1/session.html': 'Recorded session

Exact session export

', +}; +const step = { + sequence: 1, stage: 'plan', status: 'completed', outcome: 'success', + input: { prompt: 'Parsed stage input, initially hidden' }, + output: { result: 'Parsed stage output, initially hidden' }, + session_id: 'stage-debug-session', + session_export: { html: 'session.html', status: 'complete', messages: 3, html_bytes: 100 }, + artifacts: Object.entries(files).map(([url, text]) => ({ + name: url.split('/').at(-1), url, size_bytes: Buffer.byteLength(text), + content_type: url.endsWith('.html') ? 'text/html' : 'text/markdown', + })), +}; +const fixture = await startFixture({ + root: resolve(process.argv[2] ?? 'build/chat_stage_debug_web'), files, + runDetail: { + id: 77, title: 'Stage debugging fixture', status: 'succeeded', + graph: { stages: [{ key: 'plan', type: 'model', edges: { success: '#success' } }] }, + steps: [step], + }, +}); +const profile = await mkdtemp(join(tmpdir(), 'chat-stage-debug-')); +const chrome = launchChrome('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', profile, 'about:blank'); +const log = { checks: [], captures: [] }; +let connection; +try { + const port = await waitForPort(join(profile, 'DevToolsActivePort')); + connection = await connect((await waitForPage(port)).webSocketDebuggerUrl); + await connection.send('Page.enable'); + await connection.send('Emulation.setDeviceMetricsOverride', { + width: 390, height: 844, deviceScaleFactor: 1, mobile: true, + }); + const visit = async (path) => { + await connection.send('Page.navigate', { url: fixture.url + path }); + assert.ok(await waitFor(() => connection.evaluate( + "Boolean(document.querySelector('flt-semantics-placeholder'))"), 12000)); + await enableSemantics(connection); + }; + const click = async (label, prefix = false) => { + const target = (await axNodes(connection)).find(node => + (node.name?.value === label || (prefix && node.name?.value?.startsWith(label))) && node.backendDOMNodeId && + ['button', 'tab', 'group', 'link'].includes(node.role?.value)); + assert.ok(target, `No accessible control named ${label}`); + const { model } = await connection.send('DOM.getBoxModel', { backendNodeId: target.backendDOMNodeId }); + const [x1, y1, , , x3, y3] = model.content; + await clickAt(connection, (x1 + x3) / 2, (y1 + y3) / 2); + }; + const event = async (body) => { + const response = await fetch(fixture.url + '/fixture/chat-event', { + method: 'POST', body: JSON.stringify(body), + }); + assert.equal(response.status, 200); + await sleep(300); + }; + // Flutter web paints SelectableText reasoning/raw documents on its canvas; + // those bodies are not consistently present in Chrome's accessibility tree. + const assertPainted = async (text, label, name) => { + await capture(connection, output, log, name); + const { stdout } = await promisify(execFile)('tesseract', [ + log.captures.at(-1), 'stdout', + ]); + const normalize = value => value.toLowerCase().replace(/[^a-z0-9]/g, ''); + assert.ok(normalize(stdout).includes(normalize(text)), `${label}: ${stdout}`); + log.checks.push(label); + }; + await visit('/chat/ses_probechat'); + await assertName(connection, 'Stored probe answer.', 'stored chat loaded', log); + await event({ kind: 'step', step: { status: 'running', turn_id: 'stream-turn' } }); + await event({ kind: 'reasoning', message_id: 'live-answer', + part: { id: 'reasoning-0', type: 'reasoning' }, delta: 'Checking the recorded evidence.' }); + await event({ kind: 'text', message_id: 'live-answer', + part: { id: 'text-0', type: 'text' }, delta: 'The answer is arriving.' }); + await assertPainted('Checking the recorded evidence.', 'reasoning visible while text streams', 'chat-live-reasoning'); + await assertName(connection, 'The answer is arriving.', 'streamed answer visible', log); + const field = (await axNodes(connection)).find(node => node.role?.value === 'textbox'); + assert.ok(field, 'composer text field'); + const { model } = await connection.send('DOM.getBoxModel', { backendNodeId: field.backendDOMNodeId }); + const [x1, y1, , , x3, y3] = model.content; + await clickAt(connection, (x1 + x3) / 2, (y1 + y3) / 2); + await connection.send('Input.insertText', { text: 'A follow-up while you work' }); + // The empty Cupertino hint is two lines; typing shrinks the field to one. + // Wait for that layout before taking the Send control's bounds. + await sleep(300); + await click('Send'); + assert.ok(await waitFor(async () => { + const state = await (await fetch(fixture.url + '/fixture/state')).json(); + return state.chatPrompts.length === 1; + }, 12000)); + const state = await (await fetch(fixture.url + '/fixture/state')).json(); + assert.equal(state.chatPrompts[0].text, 'A follow-up while you work'); + assert.equal(state.chatInterrupts, 0); + assert.equal(state.chatRunning, true); + log.checks.push('follow-up sent while running, without interrupting'); + await assertName(connection, 'Queued', 'server queue acknowledgement visible', log); + await capture(connection, output, log, 'chat-queued-follow-up'); + await event({ kind: 'reasoning', message_id: 'live-answer', + part: { id: 'reasoning-0', type: 'reasoning' }, delta: ' The reasoning continues live.' }); + await assertPainted('The reasoning continues live.', 'reasoning keeps updating after follow-up', 'chat-reasoning-updated'); + + // Stage-specific acceptance is completed alongside the Session-tab widget. + await visit('/runs/77/stage/plan?visit=0'); + await assertName(connection, 'Input', 'stage summary loaded', log); + const names = (await axNodes(connection)).map(node => node.name?.value ?? '').join('\n'); + assert.ok(!names.includes('Parsed stage input, initially hidden')); + assert.ok(!names.includes('Parsed stage output, initially hidden')); + log.checks.push('stage input/output initially collapsed'); + await capture(connection, output, log, 'stage-summary-collapsed'); + await click('Session'); + await assertName(connection, 'stage-debug-session', 'exact session identity visible', log); + await assertName(connection, 'Open session.html', 'recorded session export available', log); + await capture(connection, output, log, 'stage-session-debug'); + for (const [name, text] of [ + ['input.md', 'Exact original harness input.'], + ['output.md', 'Exact original harness output.'], + ['memory.md', 'Exact memory read by the stage.'], + ]) { + await click(name, true); + await sleep(700); + await assertPainted(text, `${name} exact raw document readable`, `stage-${name.replace('.', '-')}`); + await click('Back'); + await assertName(connection, 'stage-debug-session', `${name} Back restores same visit`, log); + } + const finalState = await (await fetch(fixture.url + '/fixture/state')).json(); + for (const name of ['input.md', 'output.md', 'memory.md']) { + assert.ok(finalState.fileReads.includes(`/artifacts/77/1/${name}`), name); + } + log.checks.push('all raw document fetches use this exact recorded visit'); + console.log(JSON.stringify(log, null, 2)); +} catch (error) { + if (connection) { + await capture(connection, output, log, 'failure'); + await writeFile(join(output, 'failure-ax.json'), JSON.stringify(await axNodes(connection), null, 2)); + } + throw error; +} finally { + await writeFile(join(output, 'result.json'), JSON.stringify(log, null, 2)); + connection?.close(); + const exited = once(chrome, 'exit'); + chrome.kill(); + await exited; + await fixture.close(); +} diff --git a/app/tool/runs_probe_server.mjs b/app/tool/runs_probe_server.mjs index 267a34a5..a5100f74 100644 --- a/app/tool/runs_probe_server.mjs +++ b/app/tool/runs_probe_server.mjs @@ -310,7 +310,7 @@ async function staticFile(base, pathname, req, res) { * It serves the built probe bundle and upgrades /connect on the same origin, so * the normal web composition infers this server from Uri.base. */ -export async function startFixture({ root, runs = RUNS }) { +export async function startFixture({ root, runs = RUNS, runDetail, files = {} }) { const base = await realpath(root); const connections = new Set(); const sockets = new Set(); @@ -327,6 +327,9 @@ export async function startFixture({ root, runs = RUNS }) { let chatSubscribed = 0; let chatHistory = 0; const chatPrompts = []; + const fileReads = []; + let chatRunning = false; + let chatInterrupts = 0; const searchRequests = []; const CHAT_SESSION = { id: 'ses_probechat', @@ -348,6 +351,22 @@ export async function startFixture({ root, runs = RUNS }) { const server = createServer(async (req, res) => { const pathname = new URL(req.url, 'http://fixture').pathname; + if (pathname === '/fixture/chat-event' && req.method === 'POST') { + const chunks = []; + for await (const chunk of req) chunks.push(chunk); + const event = JSON.parse(Buffer.concat(chunks).toString('utf8')); + if (event.kind === 'step') chatRunning = event.step?.status !== 'ended'; + broadcast({ type: 'chat_event', chat_event: { + session_id: CHAT_SESSION.id, ...event, + } }); + res.writeHead(200, { 'content-type': 'application/json' }).end('{"ok":true}'); + return; + } + if (Object.hasOwn(files, pathname)) { + fileReads.push(pathname); + res.writeHead(200, { 'content-type': 'text/plain; charset=utf-8' }).end(files[pathname]); + return; + } if (pathname === '/fixture/live' && req.method === 'POST') { live = true; broadcast(LIVE_EVENT); @@ -386,6 +405,9 @@ export async function startFixture({ root, runs = RUNS }) { chatSubscribed, chatHistory, chatPrompts, + chatRunning, + chatInterrupts, + fileReads, searchRequests, })); return; @@ -443,6 +465,10 @@ export async function startFixture({ root, runs = RUNS }) { } if (request.type === 'get_run') { getRun++; + if (runDetail) { + client.send({ id: request.id, type: 'run', run_detail: runDetail }); + return; + } const id = request.run_id; if (id === 2) { // Deliberately slow so the browser sees the pending/Back state; @@ -521,7 +547,16 @@ export async function startFixture({ root, runs = RUNS }) { const body = request.chat_prompt ?? {}; chatPrompts.push({ session_id: body.session_id, text: body.text, operation_id: body.operation_id, native_message_id: body.native_message_id }); - setTimeout(() => client.send({ id: request.id, type: 'chat_prompt' }), 300); + setTimeout(() => client.send({ id: request.id, type: 'chat_prompt', chat_queued: chatRunning }), 300); + return; + } + if (request.type === 'chat_shells') { + client.send({ id: request.id, type: 'chat_shells', chat_shells: [] }); + return; + } + if (request.type === 'chat_interrupt') { + chatInterrupts++; + client.send({ id: request.id, type: 'chat_interrupt' }); return; } if (request.type === 'chat_messages') {