Open a run or pipeline in a new chat

The run and pipeline More menus offer Open in chat: a new chat in the
run's (or the pipeline's latest run's) workspace opens on the Chat tab
with a draft naming the run or pipeline and how to inspect or change it.
This commit is contained in:
2026-11-13 12:38:27 +00:00
parent df0614e2f7
commit e5403ae257
20 changed files with 680 additions and 15 deletions
@@ -91,6 +91,7 @@ Widget buildChatPaneContent({
sessionId: sessionId,
title: '${row?['title'] ?? ''}'.trim(),
session: row,
initialDraft: runtime.pendingDrafts.remove(sessionId),
syncToken: placement.syncToken,
scrollPositions: runtime.scrollPositions,
transcripts: runtime.transcripts,
+4
View File
@@ -96,6 +96,10 @@ class ChatRuntime extends ChangeNotifier {
/// link) resolves the same row without a second list request.
final Map<String, JsonMap> opened = {};
/// Drafts seeded by an external action such as Open in chat. They are
/// consumed by the first composer for that session.
final Map<String, String> pendingDrafts = {};
/// Each row as the list last reported it (without its live `running`), so
/// [adoptRows] adopts only what a re-read changed.
final Map<String, JsonMap> _listed = {};
@@ -114,6 +114,7 @@ class ChatThreadView extends StatefulWidget {
this.scrollPositions,
this.transcripts,
this.initialNotice,
this.initialDraft,
this.onNewSession,
this.onSessionRenamed,
this.onSessionClosed,
@@ -157,6 +158,9 @@ class ChatThreadView extends StatefulWidget {
/// the `/new` notice for a session it just created and opened.
final String? initialNotice;
/// A draft supplied by an external deep action; it is never sent.
final String? initialDraft;
/// `/new` moved this chat to a fresh native session; the destination swaps
/// the row in place, opens the new id with the notice and refreshes the
/// list. Without a destination the notice shows here instead.
@@ -528,6 +532,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
onAccepted: (send, queued) =>
_controller.promptAccepted(send.operationId, queued: queued),
);
if (widget.initialDraft != null) {
unawaited(composer.setDraft(widget.initialDraft!));
}
// A message a previous visit sent but never saw accepted comes back as
// "Not sent" unless the history read shows the server has it.
unawaited(