Merge branch 'main' into flutter/chat-activity-overlay

This commit is contained in:
2026-10-22 03:34:39 +01:00
6 changed files with 257 additions and 2 deletions
+2 -2
View File
@@ -36,7 +36,7 @@ or scratch servers only, never real operator sessions/runs/workflows.
| Run graph | Preview: Graph tab with legend, recorded-stage selection, canvas pan/zoom and an expanded view | live activity pulse |
| Timeline/recorded visit pane | Preview: selection opens the recorded facts with Input/Output/Artifacts/Session/Definition sections and exact absence wording | per-visit session-repair choices (separate row) |
| Changes/diffs | Preview via run detail | settled-run aggregate gate, recorded file/diff/close/back verified in the real app; per-visit capture entry and paging remain |
| Artifact groups | Preview: run detail → recorded groups, selection facts, external Open/Copy link | present the visit's turn documents (input.md/memory.md/output.md, session.html) as gallery entries; in-app viewer next |
| Artifact groups | Preview: recorded groups in run detail, per-visit drill-down, turn documents (input/memory/output, session.html) in the run gallery | video/HTML preview remains external-only |
| Artifact preview | Preview: image + markdown/text in-app through the chat renderer, paging, honest unsupported/external/HTTP states | video and HTML remain external-only |
| Artifact actions | Preview: external Open, Copy link, download and native share carry the recorded name/MIME bytes; progress, cancel, HTTP failure and unsupported-share states | OS share/download on Android/iOS remain unverified until the final build |
| Session audit/export repair facts | Missing UI | session.html read-only open, partial/missing/skipped/repair choices without fabricating complete evidence |
@@ -45,7 +45,7 @@ or scratch servers only, never real operator sessions/runs/workflows.
| Chat message surfaces | Preview: formatted assistant markdown (safe links/headings/lists/tables/fences), user text exact, disclosures plain | exact attachments, unknown-part rendering beyond retained placeholders |
| Chat activity/reasoning/tools | Source raw fields only | one activity line, compaction, native reasoning/tools overlays, lifecycle/input/output/error/duration/edit diff |
| Chat composer | Preview: field, Send/Stop, persisted draft, queued/refusal lines; one verified send in the real app flow | attachments, paste and slash palette remain |
| Chat attachments | Source request facade | picker/paste, latest1MiB total wire bound, base64 files, removable named chips, exact history reconciliation |
| Chat attachments | Source: bounded draft model (1 MiB) and a native host file picker seam | composer chips, base64 send payload, paste, history reconciliation |
| Chat permissions/questions | Source: native approval/risk and question cards in the conversation view | authenticated smoke with a real pending approval/question; live multi-client resolution; no production decision sent |
| Chat model/Info/background tasks | Source request facade | current-model selection, numeric Info modal (unknown !=0), bounded running shell pages |
| Chat commands/notices/scroll | Missing | slash palette/actions, unknown-command send-as-message, dismissible local notices, saved scroll/follow intent |
+4
View File
@@ -68,6 +68,10 @@ All work under app/. Existing applications remain running and unchanged.
| Activity line | One line per recorded activity | run104 micro | single behaviour, no probe; chat tests | merged main | overlay landed |
| Attachment model | Bounded draft (1 MiB) | run106 micro | single behaviour; chat tests | merged main | picker/send next |
| Visit changes | Changes for one recorded visit | run107 micro | single behaviour; runs tests | merged main | paging next |
| Chat sessions | Create/rename/star/close/hide | run98 retained + canceled | oversized run cancelled after 3h; manager verified 155 chat tests, rebased, merged; 1259 suite | merged main | directory groups/search |
| Turn documents | Gallery document slots | run102 retained + canceled | oversized run cancelled; 148 artifact tests, rebased; manager fixed visit drill-down to keep session.html out of stage files | merged main | 1284 suite |
| Attach picker | Host file input seam | run112 micro | single behaviour; 193 chat tests | merged main | chips/send next |
| Schedules list | (no change needed) | run109 no-op | list screen already landed; only route registration remains (manager) | - | route wiring |
| Pipeline metadata | Recorded list-row facts | run108 micro | single behaviour; pipelines tests | merged main | miniature next |
| Search target | Exact hit identity model | run105 /cbba026c | micro lane (single behaviour, no probe); 41 search tests | merged main | navigation wiring next |
| Start pipeline | Native launch dialog | run97 /f6575fff | succeeded after 1h21m (oversized slice); manager ran304 pipelines/application/runs tests + 3-check/10-capture both-host probe | merged main; ancestry verified | production launch unverified |
@@ -0,0 +1,87 @@
import 'dart:typed_data';
import 'chat_attachment_draft.dart';
import 'chat_attachment_picker_stub.dart'
if (dart.library.js_interop) 'chat_attachment_picker_web.dart'
as impl;
/// One file the operator chose in the host's file picker, with the bytes the
/// host handed back.
///
/// The seam records only what the picker supplied: the file's own name, its
/// MIME type and its bytes. It applies no name fallback and no size or count
/// policy; [ChatAttachmentDraft] owns those decisions.
class ChatPickedFile {
const ChatPickedFile({
required this.name,
required this.mime,
required this.bytes,
});
/// The file name exactly as the host recorded it, blank when the host
/// supplied none. [ChatAttachmentDraft.add] refuses a blank name rather than
/// replacing it.
final String name;
/// The MIME type the host recorded, empty when the host supplied none.
final String mime;
/// The file's complete contents as read when it was chosen.
final Uint8List bytes;
/// The recorded size, taken from the bytes that were actually read.
int get sizeBytes => bytes.length;
/// The draft row for this file. The draft still owns the blank-name and
/// total-size decisions.
ChatAttachment get attachment =>
ChatAttachment(name: name, mime: mime, sizeBytes: sizeBytes);
}
/// Opens the host's file selection and returns the files the operator chose.
///
/// A null result means the operator dismissed the picker without choosing
/// anything, which is different from an empty list. Only one selection is
/// returned per call.
typedef ChatFileSelection = Future<List<ChatPickedFile>?> Function();
/// The file picker seam for one host.
///
/// [pick] is the operator's explicit pick action: on web it opens the host's
/// native file input, and the chosen files are read before the future
/// completes. A host without a picker constructs
/// [ChatAttachmentPicker.unsupported] so the missing capability is reported
/// plainly instead of silently returning nothing. Tests inject a fake
/// [select] to exercise the seam without a browser.
class ChatAttachmentPicker {
const ChatAttachmentPicker({required ChatFileSelection this.select})
: unsupportedMessage = null;
const ChatAttachmentPicker.unsupported(String message)
: select = null,
unsupportedMessage = message;
/// The host selection, or null when this host cannot pick files.
final ChatFileSelection? select;
/// Why this host cannot pick files, when [select] is null.
final String? unsupportedMessage;
/// Whether this host can open a file selection at all.
bool get isSupported => select != null;
/// Opens the host's file selection and resolves with the chosen files, or
/// null when the operator cancelled.
///
/// Throws [UnsupportedError] with [unsupportedMessage] on a host that cannot
/// pick files.
Future<List<ChatPickedFile>?> pick() async {
final select = this.select;
if (select == null) throw UnsupportedError(unsupportedMessage!);
return select();
}
}
/// The picker for the running host.
ChatAttachmentPicker get hostChatAttachmentPicker =>
impl.hostChatAttachmentPicker;
@@ -0,0 +1,13 @@
import 'chat_attachment_picker.dart';
/// Native fallback for the chat attachment picker.
///
/// No native file-picker plugin is a dependency of this slice, so a non-web
/// host reports the missing capability instead of pretending the operator
/// cancelled. The attach control can disable itself from [isSupported] and
/// show this exact explanation.
const String chatAttachmentUnsupportedMessage =
'Attaching files is not supported on this platform yet.';
ChatAttachmentPicker get hostChatAttachmentPicker =>
const ChatAttachmentPicker.unsupported(chatAttachmentUnsupportedMessage);
@@ -0,0 +1,71 @@
import 'dart:async';
import 'dart:js_interop';
import 'package:web/web.dart' as web;
import 'chat_attachment_picker.dart';
/// The web file picker: one explicit pick action creates the host's native
/// file input, opens it and reads the files the operator chose.
///
/// The input is `multiple` and has no `accept` filter, matching the web
/// composer's attach control. Only a selection or a cancel completes the
/// future; a document without a body has nothing to open and yields null.
ChatAttachmentPicker get hostChatAttachmentPicker =>
const ChatAttachmentPicker(select: _selectFiles);
Future<List<ChatPickedFile>?> _selectFiles() {
final input = web.HTMLInputElement()
..type = 'file'
..multiple = true;
input.style.display = 'none';
final completer = Completer<List<ChatPickedFile>?>();
void finish(List<ChatPickedFile>? files) {
if (completer.isCompleted) return;
input.remove();
completer.complete(files);
}
Future<void> readSelection() async {
final selected = input.files;
if (selected == null || selected.length == 0) {
finish(null);
return;
}
try {
final files = <ChatPickedFile>[];
for (var index = 0; index < selected.length; index += 1) {
final file = selected.item(index);
if (file == null) continue;
final buffer = await file.arrayBuffer().toDart;
files.add(
ChatPickedFile(
name: file.name,
mime: file.type,
bytes: buffer.toDart.asUint8List(),
),
);
}
finish(files);
} catch (error, stackTrace) {
if (completer.isCompleted) return;
input.remove();
completer.completeError(error, stackTrace);
}
}
input.addEventListener('change', ((web.Event _) {
unawaited(readSelection());
}).toJS);
input.addEventListener('cancel', ((web.Event _) {
finish(null);
}).toJS);
final body = web.document.body;
if (body == null) return Future.value(null);
body.appendChild(input);
input.click();
return completer.future;
}
@@ -0,0 +1,80 @@
import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/domain/chat_attachment_draft.dart';
import 'package:pipelines_app/features/chat/domain/chat_attachment_picker.dart';
void main() {
test('passes the chosen names, MIME types and bytes through', () async {
final bytes = Uint8List.fromList([0, 1, 2, 250]);
final picked = ChatPickedFile(
name: 'screen.png',
mime: 'image/png',
bytes: bytes,
);
final picker = ChatAttachmentPicker(select: () async => [picked]);
expect(picker.isSupported, isTrue);
final files = await picker.pick();
expect(files, hasLength(1));
expect(files!.single.name, 'screen.png');
expect(files.single.mime, 'image/png');
expect(files.single.bytes, bytes);
expect(files.single.sizeBytes, 4);
});
test('feeds the picked file to the attachment draft', () async {
final picker = ChatAttachmentPicker(
select: () async => [
ChatPickedFile(
name: 'notes.txt',
mime: 'text/plain',
bytes: Uint8List.fromList([1, 2, 3]),
),
],
);
final draft = ChatAttachmentDraft();
final files = await picker.pick();
expect(draft.add(files!.single.attachment), isNull);
expect(
draft.attachments.single,
const ChatAttachment(
name: 'notes.txt',
mime: 'text/plain',
sizeBytes: 3,
),
);
});
test('returns nothing when the operator dismisses the picker', () async {
var opened = 0;
final picker = ChatAttachmentPicker(
select: () async {
opened += 1;
return null;
},
);
expect(await picker.pick(), isNull);
expect(opened, 1);
});
test('the host picker reports its unsupported capability honestly', () async {
final picker = hostChatAttachmentPicker;
expect(picker.isSupported, isFalse);
await expectLater(
picker.pick(),
throwsA(
isA<UnsupportedError>().having(
(error) => error.message,
'message',
'Attaching files is not supported on this platform yet.',
),
),
);
});
}