feat(app): split chat sessions into native Material and Cupertino views

Split the 406-line chat session browser into a controller, body, shared
adaptive primitives and separate standard Material and Cupertino lists and
dialogs. Preserve the existing server directory/backend catalogs,
instructions field, closed/starred grouping, directory headings and
empty/no-match states.

- keep refresh generations so stale replies are discarded
- open a created chat immediately and refresh the list in the background
- disable rename Save while the trimmed name is blank
- label row actions per session, with the id on duplicate titles
- wrap Cupertino empty/no-match/error messages instead of clipping, and
  give them a Cupertino text style under a bare MaterialApp
- allow the Material rename helper to wrap at large text scales
- cover both native branches, lifecycle ordering, create/rename/close/star
  and the Cupertino theme path with widget tests
This commit is contained in:
2026-10-21 17:42:39 +01:00
parent 13d8ddac5d
commit 41d30a4280
21 changed files with 2640 additions and 363 deletions
+26 -8
View File
@@ -5,9 +5,12 @@ import { once } from 'node:events';
import { setTimeout as delay } from 'node:timers/promises';
import { join, extname, resolve, sep } from 'node:path';
import { tmpdir } from 'node:os';
import { mkdtemp, rm } from 'node:fs/promises';
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
const root = join(process.cwd(), 'build/web');
const root = resolve(process.env.PROBE_WEB_ROOT ?? join(process.cwd(), 'build/web'));
const variant = process.env.PROBE_VARIANT ?? 'material';
const artifactDir = process.env.OPENCODE_ARTIFACT_DIR ?? join(tmpdir(), 'chat-sessions-capture');
await mkdir(artifactDir, { recursive: true });
const mime = { '.html': 'text/html', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm', '.png': 'image/png', '.ico': 'image/x-icon' };
const server = createServer(async (req, res) => {
try {
@@ -66,25 +69,40 @@ try {
if (!loaded?.url.includes(`127.0.0.1:${port}`)) throw new Error(`Fixture did not load: ${JSON.stringify(loaded)}`);
await evaluate("document.querySelector('flt-semantics-placeholder')?.click()");
await delay(2500);
const clickLabel = async label => evaluate(`(() => { const e=[...document.querySelectorAll('flt-semantics')].find(x => (x.getAttribute('aria-label') || x.innerText || '') === ${JSON.stringify(label)}); if (!e) return false; e.click(); return true; })()`);
const clickLabel = async label => {
const point = await evaluate(`(() => { const needle = ${JSON.stringify(label)}; const e=[...document.querySelectorAll('flt-semantics')].find(x => (x.getAttribute('aria-label') || x.innerText || '') === needle); if (!e) return null; const r=e.getBoundingClientRect(); return {x:r.x+r.width/2,y:r.y+r.height/2}; })()`);
if (!point) return false;
await send('Input.dispatchMouseEvent', { type: 'mousePressed', x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
await send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
return true;
};
const labels = await evaluate("[...document.querySelectorAll('flt-semantics')].map(x=>x.getAttribute('aria-label')||x.innerText).filter(Boolean)");
if (!labels?.some(x => x.includes('New chat'))) throw new Error(`Chat fixture semantics unavailable: ${JSON.stringify(labels)}`);
if (process.env.PROBE_DEBUG) console.log(JSON.stringify(labels));
const capture = async (name, width, height) => {
await send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: width < 600 }, session);
await delay(350);
const data = (await send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: false }, session)).result.data;
await (await import('node:fs/promises')).writeFile(`${process.env.OPENCODE_ARTIFACT_DIR}/${name}.png`, Buffer.from(data, 'base64'));
await (await import('node:fs/promises')).writeFile(`${artifactDir}/${variant}-${name}.png`, Buffer.from(data, 'base64'));
};
await capture('chat-sessions-desktop', 1280, 800);
await capture('chat-sessions-phone', 390, 844);
if (!await clickLabel('New chat')) throw new Error('Could not open create dialog');
await delay(500);
await delay(600);
await send('Input.dispatchMouseEvent', { type: 'mouseWheel', x: 195, y: 680, deltaY: 598 }, session);
await delay(350);
const changedBody = await evaluate('document.body.innerText');
await capture('chat-sessions-create-dialog', 390, 844);
if (!changedBody.includes('Server directory') || !changedBody.includes('Backend') || !changedBody.includes('New chats use the server default model.') || changedBody.includes('Open fixture')) throw new Error(`Create dialog did not change rendered body to catalog controls: ${changedBody}`);
await capture('chat-sessions-desktop', 1280, 800);
console.log(JSON.stringify({ labels, captures: ['chat-sessions-phone.png', 'chat-sessions-create-dialog.png', 'chat-sessions-desktop.png'], bodyChanged: true }, null, 2));
if (!changedBody.includes('Server directory') || !changedBody.includes('Backend') || !changedBody.includes('New chats use the server default model.')) throw new Error(`Create dialog did not change rendered body to catalog controls: ${changedBody}`);
if (!await clickLabel('Cancel')) throw new Error('Could not close create dialog');
await delay(600);
if (!await clickLabel('Chat actions for Open fixture')) throw new Error('Could not open row actions');
await delay(600);
const actionsBody = await evaluate('document.body.innerText');
const actionLabels = await evaluate("[...document.querySelectorAll('flt-semantics')].map(x => x.getAttribute('aria-label') || x.innerText || '').filter(Boolean)");
await capture('chat-sessions-actions', 390, 844);
if (!actionLabels.some(label => label.includes('Rename…'))) throw new Error(`Row actions unavailable: ${actionsBody} / ${actionLabels}`);
console.log(JSON.stringify({ variant, labels, captures: [`${variant}-chat-sessions-desktop.png`, `${variant}-chat-sessions-phone.png`, `${variant}-chat-sessions-create-dialog.png`, `${variant}-chat-sessions-actions.png`], bodyChanged: true }, null, 2));
} finally {
ws?.close();
chrome.kill('SIGTERM');
+18 -4
View File
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -55,8 +56,21 @@ class _FixtureGateway implements ApiGateway {
}
}
void main() => runApp(
MaterialApp(
home: ChatSessionsScreen(gateway: _FixtureGateway(), onOpen: (_) {}),
),
const _probeStyle = String.fromEnvironment(
'CHAT_PROBE_STYLE',
defaultValue: 'material',
);
void main() {
final home = ChatSessionsScreen(gateway: _FixtureGateway(), onOpen: (_) {});
if (_probeStyle == 'cupertino') {
runApp(CupertinoApp(home: home));
return;
}
runApp(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: home,
),
);
}