Merge main into chat drag
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
@@ -2,6 +2,8 @@ part of 'screen.dart';
|
||||
|
||||
/// Pane layout, focus and route publication for one Chat destination visit.
|
||||
mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
final _sessionsKey = GlobalKey<ChatSessionsScreenState>();
|
||||
|
||||
Map<String, JsonMap> get _openedSessions;
|
||||
ChatComposerFocusRequests get _composerFocus;
|
||||
ChatPaneCommands get _paneCommands;
|
||||
@@ -46,6 +48,10 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
activeSessionId: selected,
|
||||
visibleSessionIds: _visibleSidebarSessions,
|
||||
onOpen: _openSidebarSession,
|
||||
onNewChat: () {
|
||||
final state = _sessionsKey.currentState;
|
||||
if (state != null) unawaited(state.newChat());
|
||||
},
|
||||
onExpand: () => _setSidebarMode(ChatSidebarMode.expanded),
|
||||
),
|
||||
],
|
||||
@@ -297,14 +303,12 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
String? _publishedWorkspaceSession;
|
||||
String _workspaceSignature = '';
|
||||
|
||||
/// Ctrl+Tab cycles the floating chat windows while any is shown, from the
|
||||
/// tiling as well (see [ChatWindows]). With none shown it cycles the
|
||||
/// retained panes, even when the sidebar or toolbar owns focus, and over a
|
||||
/// single pane it does nothing: it never brings up a chat that is not
|
||||
/// visible in the tiling. Command+Tab stays with the operating system's
|
||||
/// application switcher. While the app's terminal is shown, Ctrl+Tab moves
|
||||
/// between its tabs instead. A floating window that is not a chat, or any
|
||||
/// other window holding the keyboard, keeps the key.
|
||||
/// Ctrl+Tab cycles a single tiled pane through the open chats in sidebar
|
||||
/// order. The pane is replaced in place so its retained view keeps the
|
||||
/// transcript and draft. With multiple panes it cycles those panes. A
|
||||
/// focused floating chat window handles the key itself (see [ChatWindows]).
|
||||
/// Command+Tab stays with the operating system's application switcher, and
|
||||
/// the terminal keeps Ctrl+Tab for its own tabs.
|
||||
bool _cycleChatKey(KeyEvent event) {
|
||||
final keyboard = HardwareKeyboard.instance;
|
||||
if (event is! KeyDownEvent ||
|
||||
@@ -317,8 +321,48 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
!_chatOwnsKeyboard()) {
|
||||
return false;
|
||||
}
|
||||
if (widget.windows?.raiseTopFromTiling() ?? false) return true;
|
||||
if (!_workspaceVisible || _workspace.paneCount < 2) return false;
|
||||
if (!_workspaceVisible || _workspace.paneCount == 0) return false;
|
||||
if (_workspace.paneCount == 1) {
|
||||
final pane = _workspace.activePane;
|
||||
if (pane == null) return false;
|
||||
final floating = widget.windows?.floatingSessionIds.toSet() ?? const {};
|
||||
final sessions = chatSessionsShown(
|
||||
_sessionsForSidebar.sessions
|
||||
.where(
|
||||
(row) =>
|
||||
row['closed_at'] == null &&
|
||||
row['closed'] != true &&
|
||||
!floating.contains('${row['id'] ?? ''}'),
|
||||
)
|
||||
.toList(),
|
||||
query: '',
|
||||
// Cycling is independent of a collapsed section: the sidebar's
|
||||
// ordering is still used, but every open-chat row remains reachable.
|
||||
isOpen: (_) => true,
|
||||
);
|
||||
final active = sessions.indexWhere(
|
||||
(row) => '${row['id'] ?? ''}' == pane.sessionId,
|
||||
);
|
||||
if (sessions.length < 2 || active < 0) return false;
|
||||
final direction = keyboard.isShiftPressed ? -1 : 1;
|
||||
final target = sessions[(active + direction) % sessions.length];
|
||||
final targetId = '${target['id'] ?? ''}';
|
||||
if (targetId.isEmpty) return false;
|
||||
_workspace.replacePaneSession(pane.id, targetId);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted ||
|
||||
!_workspaceVisible ||
|
||||
_workspace.activePane?.sessionId != targetId) {
|
||||
return;
|
||||
}
|
||||
final destination = ShellBarScope.maybeOf(context)?.registry.focus;
|
||||
if (destination == null || destination == AppDestination.chat) {
|
||||
_composerFocus.request(targetId);
|
||||
}
|
||||
});
|
||||
WidgetsBinding.instance.ensureVisualUpdate();
|
||||
return true;
|
||||
}
|
||||
final panes = _workspace.panes;
|
||||
final active = panes.indexWhere(
|
||||
(pane) => pane.id == _workspace.activePaneId,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -485,6 +485,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
// The session list pads its first row by the bar's height itself, so it
|
||||
// scrolls behind the shell's floating bar like the other lists.
|
||||
final sessions = ChatSessionsScreen(
|
||||
key: _sessionsKey,
|
||||
gateway: widget.gateway,
|
||||
embedded: true,
|
||||
syncToken: widget.syncToken,
|
||||
|
||||
@@ -23,6 +23,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
required this.activeSessionId,
|
||||
this.visibleSessionIds = const {},
|
||||
required this.onOpen,
|
||||
required this.onNewChat,
|
||||
required this.onExpand,
|
||||
this.navigation,
|
||||
});
|
||||
@@ -31,6 +32,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
final String? activeSessionId;
|
||||
final Set<String> visibleSessionIds;
|
||||
final ValueChanged<JsonMap> onOpen;
|
||||
final VoidCallback onNewChat;
|
||||
final VoidCallback onExpand;
|
||||
final Widget? navigation;
|
||||
static const width = 72.0;
|
||||
@@ -156,6 +158,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
width: width,
|
||||
child: Column(
|
||||
children: [
|
||||
_button(context, 'New chat', const Icon(Icons.add), onNewChat),
|
||||
_button(
|
||||
context,
|
||||
'Expand chat list',
|
||||
|
||||
@@ -100,10 +100,10 @@ class ChatSessionsScreen extends StatefulWidget {
|
||||
final ChatSectionFolds? folds;
|
||||
|
||||
@override
|
||||
State<ChatSessionsScreen> createState() => _ChatSessionsScreenState();
|
||||
ChatSessionsScreenState createState() => ChatSessionsScreenState();
|
||||
}
|
||||
|
||||
class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
class ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
late final ChatSessionsController _controller =
|
||||
(widget.controller ??
|
||||
ChatSessionsController(
|
||||
@@ -235,6 +235,9 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
if (session != null && mounted) widget.onOpen(session);
|
||||
}
|
||||
|
||||
/// Starts the same machine picker and create dialog used by the list action.
|
||||
Future<void> newChat() => _newChat();
|
||||
|
||||
void _markOpened(JsonMap session) =>
|
||||
unawaited(_controller.markOpened(session));
|
||||
|
||||
|
||||
@@ -288,6 +288,23 @@ class ChatWorkspaceController extends ChangeNotifier {
|
||||
_changed();
|
||||
}
|
||||
|
||||
/// Replaces a pane after its caller has already validated [newId]. Unlike
|
||||
/// [replaceSession], this does not ask the window host to show a floating
|
||||
/// chat; keyboard cycling filters those chats before calling this method.
|
||||
void replacePaneSession(String paneId, String newId) {
|
||||
if (newId.isEmpty) return;
|
||||
final pane = panes.where((p) => p.id == paneId).firstOrNull;
|
||||
if (pane == null) return;
|
||||
final existing = panes.where((p) => p.sessionId == newId).firstOrNull;
|
||||
if (existing != null) {
|
||||
close(pane.id);
|
||||
activate(existing.id);
|
||||
return;
|
||||
}
|
||||
_root = _replace(_root!, pane.id, ChatWorkspacePane(pane.id, newId));
|
||||
_changed();
|
||||
}
|
||||
|
||||
ChatWorkspaceNode _replace(
|
||||
ChatWorkspaceNode node,
|
||||
String id,
|
||||
|
||||
@@ -224,6 +224,7 @@ class PipelineRun {
|
||||
required this.createdAt,
|
||||
required this.finishedAt,
|
||||
required this.executing,
|
||||
this.workspace = '',
|
||||
});
|
||||
|
||||
factory PipelineRun.fromJson(PipelineJson json) => PipelineRun(
|
||||
@@ -233,6 +234,7 @@ class PipelineRun {
|
||||
createdAt: _string(json['created_at']),
|
||||
finishedAt: _string(json['finished_at']),
|
||||
executing: json['executing'] == true,
|
||||
workspace: '${json['workspace'] ?? ''}',
|
||||
);
|
||||
|
||||
final int id;
|
||||
@@ -241,6 +243,7 @@ class PipelineRun {
|
||||
final String createdAt;
|
||||
final String finishedAt;
|
||||
final bool executing;
|
||||
final String workspace;
|
||||
}
|
||||
|
||||
/// Timestamps decide recency; a higher run id breaks an exact tie or two bad
|
||||
|
||||
@@ -41,6 +41,8 @@ class PipelinesScreen extends StatefulWidget {
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
this.initialStageKey,
|
||||
this.onOpenInChat,
|
||||
this.onOpenPipelineInChat,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -87,6 +89,10 @@ class PipelinesScreen extends StatefulWidget {
|
||||
/// pane; a key the pinned version does not declare opens the Graph tab with
|
||||
/// nothing selected. Null keeps the ordinary default tab.
|
||||
final String? initialStageKey;
|
||||
final Future<void> Function(BuildContext, PipelineDetail, PipelineRun?)?
|
||||
onOpenInChat;
|
||||
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
|
||||
onOpenPipelineInChat;
|
||||
|
||||
@override
|
||||
State<PipelinesScreen> createState() => _PipelinesScreenState();
|
||||
@@ -235,6 +241,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
showBack: false,
|
||||
onRunStarted: widget.onRunStarted,
|
||||
onViewPipelineRuns: widget.onViewPipelineRuns,
|
||||
onOpenInChat: widget.onOpenInChat,
|
||||
stageKey: stageKey,
|
||||
stagePipelineId: widget.initialPipelineId,
|
||||
stageVersion: widget.initialVersion,
|
||||
@@ -252,12 +259,18 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
);
|
||||
if (!wide) {
|
||||
return ContentWidth(
|
||||
child: PipelineListPanel(controller: _controller),
|
||||
child: PipelineListPanel(
|
||||
controller: _controller,
|
||||
onOpenInChat: widget.onOpenPipelineInChat,
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListDetailPanes(
|
||||
list: ContentWidth(
|
||||
child: PipelineListPanel(controller: _controller),
|
||||
child: PipelineListPanel(
|
||||
controller: _controller,
|
||||
onOpenInChat: widget.onOpenPipelineInChat,
|
||||
),
|
||||
),
|
||||
detailIdentity: _controller.selectedId,
|
||||
detail: _controller.hasSelection
|
||||
|
||||
@@ -18,17 +18,29 @@ String archiveConfirmation(String name) =>
|
||||
Widget pipelineActionsMenu(
|
||||
BuildContext context,
|
||||
PipelinesController controller,
|
||||
PipelineDetail detail,
|
||||
) {
|
||||
PipelineDetail detail, {
|
||||
Future<void> Function(BuildContext, PipelineDetail, PipelineRun?)?
|
||||
onOpenInChat,
|
||||
}) {
|
||||
final archived = detail.archived;
|
||||
final label = archived ? 'Unarchive' : 'Archive…';
|
||||
void run(BuildContext context) =>
|
||||
archiveOrUnarchive(context, controller, detail);
|
||||
return SegmentedOverflowAction(
|
||||
overflowEntry: SegmentedOverflowEntry(
|
||||
label: archived ? 'Unarchive pipeline' : 'Archive pipeline…',
|
||||
label: 'Pipeline actions',
|
||||
icon: Icons.archive_outlined,
|
||||
onPressed: () => run(context),
|
||||
choices: [
|
||||
SegmentedMenuChoice(
|
||||
label: archived ? 'Unarchive pipeline' : 'Archive pipeline…',
|
||||
onSelected: () => run(context),
|
||||
),
|
||||
if (onOpenInChat != null)
|
||||
SegmentedMenuChoice(
|
||||
label: 'Open in chat',
|
||||
onSelected: () => onOpenInChat(context, detail, null),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: AppOverflowMenu<bool>(
|
||||
key: const Key('pipeline-actions-menu'),
|
||||
@@ -40,8 +52,15 @@ Widget pipelineActionsMenu(
|
||||
value: true,
|
||||
label: label,
|
||||
),
|
||||
if (onOpenInChat != null)
|
||||
const AppMenuAction<bool>(
|
||||
value: false,
|
||||
label: 'Open in chat',
|
||||
icon: Icons.chat_bubble_outline,
|
||||
),
|
||||
],
|
||||
onSelected: (context, _) => run(context),
|
||||
onSelected: (context, value) =>
|
||||
value ? run(context) : onOpenInChat!(context, detail, null),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class PipelineDetailPanel extends StatefulWidget {
|
||||
this.stagePipelineId,
|
||||
this.stageVersion = 0,
|
||||
this.stageRequest = 0,
|
||||
this.onOpenInChat,
|
||||
}) : assert(
|
||||
stageKey == null || stagePipelineId != null,
|
||||
'a routed stage names the pipeline it belongs to',
|
||||
@@ -77,6 +78,8 @@ class PipelineDetailPanel extends StatefulWidget {
|
||||
/// definition pane even though the pinned detail may be re-read in place. A
|
||||
/// later version switch from this screen is not a new route request.
|
||||
final int stageRequest;
|
||||
final Future<void> Function(BuildContext, PipelineDetail, PipelineRun?)?
|
||||
onOpenInChat;
|
||||
|
||||
@override
|
||||
State<PipelineDetailPanel> createState() => _PipelineDetailPanelState();
|
||||
@@ -420,7 +423,18 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
onRunStarted: widget.onRunStarted,
|
||||
inBar: true,
|
||||
),
|
||||
pipelineActionsMenu(context, _controller, detail),
|
||||
pipelineActionsMenu(
|
||||
context,
|
||||
_controller,
|
||||
detail,
|
||||
onOpenInChat: widget.onOpenInChat == null
|
||||
? null
|
||||
: (context, detail, _) => widget.onOpenInChat!(
|
||||
context,
|
||||
detail,
|
||||
_controller.latestRuns[detail.id],
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
Widget _source(BuildContext context, PipelineDetail detail) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import '../pipelines_controller.dart';
|
||||
import 'pipeline_controls.dart';
|
||||
import 'pipeline_filter_page.dart';
|
||||
import 'pipeline_scope_control.dart';
|
||||
import '../../../ui/layout/app_overflow_menu.dart';
|
||||
|
||||
/// The list's horizontal rhythm, matching the web's toolbar and row inset
|
||||
/// (`var(--space-s)`: 12px). The detail pane keeps its own content padding.
|
||||
@@ -21,9 +22,15 @@ const double kPipelineListInset = 12;
|
||||
|
||||
/// The left/top pane: filter and sort controls, then the truthful list states.
|
||||
class PipelineListPanel extends StatelessWidget {
|
||||
const PipelineListPanel({super.key, required this.controller});
|
||||
const PipelineListPanel({
|
||||
super.key,
|
||||
required this.controller,
|
||||
this.onOpenInChat,
|
||||
});
|
||||
|
||||
final PipelinesController controller;
|
||||
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
|
||||
onOpenInChat;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -264,6 +271,22 @@ class PipelineListPanel extends StatelessWidget {
|
||||
: Text(
|
||||
ServerContext.metadata(context, runStateLabel(badge.state)),
|
||||
),
|
||||
menu: onOpenInChat == null
|
||||
? null
|
||||
: AppOverflowMenu<bool>(
|
||||
key: Key('pipeline-row-more-menu-${pipeline.id}'),
|
||||
label: 'Pipeline actions',
|
||||
sheetTitle: pipeline.displayName,
|
||||
actions: const [
|
||||
AppMenuAction<bool>(
|
||||
value: true,
|
||||
label: 'Open in chat',
|
||||
icon: Icons.chat_bubble_outline,
|
||||
),
|
||||
],
|
||||
onSelected: (context, _) =>
|
||||
onOpenInChat!(context, pipeline, run),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -53,6 +53,7 @@ class RunsScreen extends StatefulWidget {
|
||||
this.attention,
|
||||
this.sortStore = const SharedPreferencesRunsSortStore(),
|
||||
this.pendingRunStore = const SharedPreferencesPendingRunStore(''),
|
||||
this.onOpenInChat,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -103,6 +104,7 @@ class RunsScreen extends StatefulWidget {
|
||||
/// Where a New run's pending launch intent persists, under the same endpoint
|
||||
/// scope the Pipelines tab uses. Tests inject a memory store.
|
||||
final PendingRunStore pendingRunStore;
|
||||
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
|
||||
|
||||
@override
|
||||
State<RunsScreen> createState() => _RunsScreenState();
|
||||
@@ -300,6 +302,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
onBack: onBack,
|
||||
onRunOpened: _select,
|
||||
onOpenPipeline: widget.onOpenPipeline,
|
||||
onOpenInChat: widget.onOpenInChat,
|
||||
initialStageKey: widget.initialStageKey,
|
||||
initialVisit: widget.initialVisit,
|
||||
);
|
||||
@@ -354,6 +357,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
attentionNow: widget.attentionNow,
|
||||
notifications: widget.notifications,
|
||||
attention: widget.attention,
|
||||
onOpenInChat: widget.onOpenInChat,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -24,6 +24,7 @@ class RunDetailView extends StatefulWidget {
|
||||
this.onOpenPipeline,
|
||||
this.initialStageKey,
|
||||
this.initialVisit,
|
||||
this.onOpenInChat,
|
||||
});
|
||||
|
||||
final RunsController controller;
|
||||
@@ -44,6 +45,7 @@ class RunDetailView extends StatefulWidget {
|
||||
/// plain detail.
|
||||
final String? initialStageKey;
|
||||
final int? initialVisit;
|
||||
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
|
||||
|
||||
@override
|
||||
State<RunDetailView> createState() => _RunDetailViewState();
|
||||
@@ -114,6 +116,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
onRunOpened: widget.onRunOpened,
|
||||
onDeleted: widget.controller.applyDeletion,
|
||||
onOpenInChat: widget.onOpenInChat,
|
||||
);
|
||||
if (inShellBar) {
|
||||
return ShellBar(
|
||||
|
||||
@@ -35,6 +35,7 @@ class RunListRow extends StatelessWidget {
|
||||
this.checked = false,
|
||||
this.onToggle,
|
||||
this.onLongPress,
|
||||
this.onOpenInChat,
|
||||
});
|
||||
|
||||
final JsonMap run;
|
||||
@@ -56,6 +57,7 @@ class RunListRow extends StatelessWidget {
|
||||
|
||||
/// Enters select mode from a touch long-press.
|
||||
final VoidCallback? onLongPress;
|
||||
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -140,13 +142,18 @@ class RunListRow extends StatelessWidget {
|
||||
!selecting &&
|
||||
gateway != null &&
|
||||
onRunChanged != null &&
|
||||
showRunMoreMenu(run, deletable: onDeleted != null)
|
||||
showRunMoreMenu(
|
||||
run,
|
||||
deletable: onDeleted != null,
|
||||
canOpenInChat: onOpenInChat != null,
|
||||
)
|
||||
? RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway!,
|
||||
onRunChanged: onRunChanged!,
|
||||
onRunOpened: onRunOpened,
|
||||
onDeleted: onDeleted,
|
||||
onOpenInChat: onOpenInChat,
|
||||
menuKey: ValueKey('run-list-more-menu-$id'),
|
||||
)
|
||||
: null,
|
||||
|
||||
@@ -16,14 +16,21 @@ import '../domain/run_models.dart' show runIdentity;
|
||||
const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
||||
const deleteRunActionKey = ValueKey<String>('run-delete-action');
|
||||
const deleteRunActionLabel = 'Delete run';
|
||||
const openRunInChatActionKey = ValueKey<String>('run-open-in-chat-action');
|
||||
const openRunInChatActionLabel = 'Open in chat';
|
||||
|
||||
/// Whether the run has anything for its more menu. [deletable] says the host
|
||||
/// can apply a deletion, so a finished run offers Delete run.
|
||||
bool showRunMoreMenu(JsonMap run, {bool deletable = false}) =>
|
||||
bool showRunMoreMenu(
|
||||
JsonMap run, {
|
||||
bool deletable = false,
|
||||
bool canOpenInChat = false,
|
||||
}) =>
|
||||
runTitleId(run) != null ||
|
||||
canScheduleRun(run) ||
|
||||
_canRetry(run) ||
|
||||
(deletable && runIsDeletable(run));
|
||||
(deletable && runIsDeletable(run)) ||
|
||||
canOpenInChat;
|
||||
|
||||
/// The run's own name for its action sheet: its title or pipeline, else
|
||||
/// `Run <id>`, as its list row shows it.
|
||||
@@ -34,7 +41,7 @@ String runMoreMenuTitle(JsonMap run) {
|
||||
|
||||
bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run);
|
||||
|
||||
enum _RunMoreItem { retry, rename, schedule, delete }
|
||||
enum _RunMoreItem { retry, rename, schedule, delete, openInChat }
|
||||
|
||||
/// Each item keeps the key its standalone button had.
|
||||
Key _keyOf(_RunMoreItem item) => switch (item) {
|
||||
@@ -42,6 +49,7 @@ Key _keyOf(_RunMoreItem item) => switch (item) {
|
||||
_RunMoreItem.rename => runTitleActionKey,
|
||||
_RunMoreItem.schedule => scheduleRunActionKey,
|
||||
_RunMoreItem.delete => deleteRunActionKey,
|
||||
_RunMoreItem.openInChat => openRunInChatActionKey,
|
||||
};
|
||||
|
||||
/// The run detail's more menu: Retry (failed runs only), Rename and Schedule
|
||||
@@ -56,6 +64,7 @@ class RunMoreMenu extends StatefulWidget {
|
||||
required this.onRunChanged,
|
||||
this.onRunOpened,
|
||||
this.onDeleted,
|
||||
this.onOpenInChat,
|
||||
this.menuKey = runMoreMenuKey,
|
||||
});
|
||||
|
||||
@@ -68,6 +77,7 @@ class RunMoreMenu extends StatefulWidget {
|
||||
|
||||
/// Applies an answered deletion; without it the menu offers no Delete run.
|
||||
final ValueChanged<RunsDeletion>? onDeleted;
|
||||
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
|
||||
|
||||
/// Detail menus retain the shared key; list rows supply a per-run key.
|
||||
final Key menuKey;
|
||||
@@ -86,6 +96,8 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
|
||||
if (canScheduleRun(run)) (_RunMoreItem.schedule, scheduleRunActionLabel),
|
||||
if (widget.onDeleted != null && runIsDeletable(run))
|
||||
(_RunMoreItem.delete, deleteRunActionLabel),
|
||||
if (widget.onOpenInChat != null)
|
||||
(_RunMoreItem.openInChat, openRunInChatActionLabel),
|
||||
];
|
||||
|
||||
void _pick(BuildContext context, _RunMoreItem item) {
|
||||
@@ -117,6 +129,8 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
|
||||
gateway: widget.gateway,
|
||||
onDeleted: widget.onDeleted!,
|
||||
);
|
||||
case _RunMoreItem.openInChat:
|
||||
widget.onOpenInChat!(context, run);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +145,13 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
|
||||
key: _keyOf(item),
|
||||
value: item,
|
||||
label: label,
|
||||
icon: switch (item) {
|
||||
_RunMoreItem.retry => Icons.replay,
|
||||
_RunMoreItem.rename => Icons.edit_outlined,
|
||||
_RunMoreItem.schedule => Icons.schedule,
|
||||
_RunMoreItem.delete => Icons.delete_outline,
|
||||
_RunMoreItem.openInChat => Icons.chat_bubble_outline,
|
||||
},
|
||||
destructive: item == _RunMoreItem.delete,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -32,10 +32,12 @@ class RunsList extends StatelessWidget {
|
||||
this.notifications,
|
||||
this.attention,
|
||||
this.active = true,
|
||||
this.onOpenInChat,
|
||||
});
|
||||
|
||||
/// False while a run detail covers the list; the bar is then the run's.
|
||||
final bool active;
|
||||
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
|
||||
|
||||
final RunsController controller;
|
||||
final ValueChanged<num> onSelected;
|
||||
@@ -166,7 +168,8 @@ class RunsList extends StatelessWidget {
|
||||
// A server with no runs at all is not a filter problem: say what the list
|
||||
// is for and where its first run comes from. A free-text query counts as
|
||||
// a filter too, so a search on an empty server reads as "nothing found".
|
||||
final noRunsAtAll = controller.runs.isEmpty &&
|
||||
final noRunsAtAll =
|
||||
controller.runs.isEmpty &&
|
||||
controller.activeFilterCount == 0 &&
|
||||
controller.query.trim().isEmpty;
|
||||
return BelowTopBar(
|
||||
@@ -340,6 +343,7 @@ class RunsList extends StatelessWidget {
|
||||
gateway: controller.repository.gateway,
|
||||
onRunChanged: controller.acceptRunDetail,
|
||||
onRunOpened: onSelected,
|
||||
onOpenInChat: onOpenInChat,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,10 +156,10 @@ class KeyboardShortcutRegistry {
|
||||
if (!web)
|
||||
const KeyboardShortcutEntry(
|
||||
group: KeyboardShortcutGroup.chat,
|
||||
action: 'Cycle chat panes and floating chats',
|
||||
action: 'Cycle chats and floating chat panes',
|
||||
keys: 'Ctrl+Tab, Ctrl+Shift+Tab',
|
||||
caveat:
|
||||
'While the terminal is shown, Ctrl+Tab moves between its tabs instead.',
|
||||
'With one tiled pane, cycles open sidebar chats (excluding closed, hidden and floating chats); with multiple panes, cycles panes. While the terminal is shown, Ctrl+Tab moves between its tabs instead.',
|
||||
),
|
||||
const KeyboardShortcutEntry(
|
||||
group: KeyboardShortcutGroup.chat,
|
||||
|
||||
Reference in New Issue
Block a user