Runs park on usage limits; failure classes, harness error policy, run budgets

- A stage refused for a Claude usage limit no longer fails its run: the
  runner tries the chats' Claude account auto-switch (per-home setting) and
  reruns the visit, else parks the run in the new waiting_quota status
  (persisted, with reset/resume time in run summaries, details and events)
  and resumes the same visit at reset + 1 min, also after a restart.
  resume_run / `pipelines resume` resumes now; cancel works on parked runs.
  The rerun visit gets a "# Previous attempt" interruption note. Subscription
  limits no longer say "top up the provider account".
- run/retry into an account known to be limited are deferred (quota_policy
  defer/refuse/now; CLI refuses under --json/--yes unless --defer or --now).
- failure_class on runs (quota, loop_exhausted, timeout, permission_denied,
  harness_error, blocked, environment, canceled, interrupted, budget,
  check_failed, other) in RunSummary/RunDetail/events, CLI inspect/runs/wait/
  stats and the app failure line.
- Claude permission denials (permission_denials / refused tool results) fail
  a blocked visit with permission_denied naming the tool use.
- Harness failures are classified transient vs deterministic; deterministic
  ones (and a repeated empty readback) skip error self-loops; transient
  self-loops back off 15 s, 1 min, 4 min.
- Whole-run USD budget: run --budget, server default (run-budget /
  get/set_run_settings); 80% warning notification, stop with class budget.
- App: waiting_quota status/filter with resume time, Resume now and Cancel,
  failure class wording. Docs and skill references updated.

Merges main (check stage, delivery gate, Claude stage restart survival,
schedule changes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 14:34:53 +00:00
193 changed files with 11295 additions and 505 deletions
+32 -7
View File
@@ -25,6 +25,8 @@ mixin _ChatScreenFloat on State<ChatScreen>, _ChatScreenWorkspace {
final pane = _workspace.activePane;
if (pane != null) _floatPane(pane.id);
},
release: _releaseSession,
activeSession: () => _workspace.activePane?.sessionId,
);
}
@@ -66,6 +68,19 @@ mixin _ChatScreenFloat on State<ChatScreen>, _ChatScreenWorkspace {
}
}
/// [sessionId] went to a window of its own: its panes leave the tiling,
/// as a floated pane does, and the list shows when none is left.
void _releaseSession(String sessionId) {
if (!mounted) return;
final panes = _workspace.panes.where((p) => p.sessionId == sessionId);
if (panes.isEmpty) return;
for (final pane in panes.toList()) {
_workspace.detach(pane.id);
}
_syncOpenWorkspace();
if (_workspace.paneCount == 0) _back();
}
void _dockSession(String sessionId) {
if (!mounted) return;
_workspaceVisible = true;
@@ -75,15 +90,25 @@ mixin _ChatScreenFloat on State<ChatScreen>, _ChatScreenWorkspace {
_composerFocus.request(sessionId);
}
/// The pane menu's Float choice, on a tiled pane that can.
/// The pane menu's Float choice, on a tiled pane that can, and Open in
/// new window where the platform has windows.
List<Widget> _floatControls(ChatWorkspacePane pane) {
if (!_floatsHere || !_workspace.canFloat(pane.id)) return const [];
final windows = widget.windows;
if (windows == null || !_workspace.canFloat(pane.id)) return const [];
return [
ChatBarAction(
label: 'Float (${chatFloatShortcutLabel()})',
onPressed: () => _floatPane(pane.id),
materialIcon: Icons.picture_in_picture_alt_outlined,
),
if (_floatsHere)
ChatBarAction(
label: 'Float (${chatFloatShortcutLabel()})',
onPressed: () => _floatPane(pane.id),
materialIcon: Icons.picture_in_picture_alt_outlined,
),
if (windows.detached != null)
ChatBarAction(
label: detachedChatWindowLabel(),
identifier: 'chat-open-new-window',
onPressed: () => windows.detach(pane.sessionId),
materialIcon: Icons.open_in_browser,
),
];
}
}
@@ -43,6 +43,12 @@ mixin _ChatScreenPaneMenu on State<ChatScreen>, _ChatScreenWorkspace
final moves = pane == null ? null : _paneMoveTargets[pane.id];
final directory = '${session['directory'] ?? ''}'.trim();
return [
if (widget.windows?.detached != null)
(
action: SessionPaneAction.newWindow,
label: detachedChatWindowLabel(),
enabled: true,
),
(
action: SessionPaneAction.addPane,
label: 'Add chat pane',
@@ -97,6 +103,8 @@ mixin _ChatScreenPaneMenu on State<ChatScreen>, _ChatScreenWorkspace
final id = '${session['id'] ?? ''}';
if (id.isEmpty) return;
switch (action) {
case SessionPaneAction.newWindow:
widget.windows?.detach(id);
case SessionPaneAction.addPane:
_openBySelection(session);
_addPane(context);
@@ -7,7 +7,9 @@ import 'package:flutter/widgets.dart';
import 'chat_attachment_picker.dart';
import 'chat_clipboard_paste.dart';
/// The macOS Runner's pasteboard reader (macos/Runner/MainFlutterWindow.swift).
/// The desktop Runners' clipboard reader: macOS's
/// (macos/Runner/MainFlutterWindow.swift) and Linux's
/// (linux/runner/clipboard_files.cc).
const MethodChannel chatClipboardFilesChannel = MethodChannel(
'pipelines/clipboard_files',
);
@@ -17,7 +19,7 @@ const MethodChannel chatClipboardFilesChannel = MethodChannel(
///
/// Flutter's own [Clipboard] carries text only, so a native host reads the
/// pasteboard through the Runner. Each subscription watches for the platform
/// paste shortcut (Cmd+V). When its composer may take the paste it consumes
/// paste shortcut (Cmd+V on macOS, Ctrl+V on Linux). When its composer may take the paste it consumes
/// the key, asks the Runner for the pasteboard's files (Finder file URLs, else
/// a copied or screenshot image) and hands them over; a pasteboard without
/// files pastes its text into the composer instead, so the consumed key never
@@ -46,13 +48,14 @@ ChatClipboardPaste nativeChatClipboardPaste({
);
/// Whether the held modifiers make V the host's paste shortcut: Cmd alone on
/// macOS.
bool chatIsNativePasteShortcut() {
/// macOS; Ctrl on Linux, also with Super held (Omarchy's universal Super+V
/// sends Ctrl+V while Super is down).
bool chatIsNativePasteShortcut([TargetPlatform? platform]) {
final keys = HardwareKeyboard.instance;
return keys.isMetaPressed &&
!keys.isControlPressed &&
!keys.isAltPressed &&
!keys.isShiftPressed;
if (keys.isAltPressed || keys.isShiftPressed) return false;
return (platform ?? defaultTargetPlatform) == TargetPlatform.linux
? keys.isControlPressed
: keys.isMetaPressed && !keys.isControlPressed;
}
Future<void> _readPasteboard(
@@ -121,4 +124,5 @@ String chatNothingToPasteMessage(List<String> types) => types.isEmpty
/// Whether [platform] has a Runner that answers [chatClipboardFilesChannel].
bool chatHostReadsClipboardFiles(TargetPlatform platform) =>
!kIsWeb && platform == TargetPlatform.macOS;
!kIsWeb &&
(platform == TargetPlatform.macOS || platform == TargetPlatform.linux);
@@ -5,7 +5,7 @@ import 'chat_clipboard_paste_native.dart';
/// Native clipboard-file paste.
///
/// macOS reads the pasteboard through its Runner
/// macOS and Linux read the clipboard through their Runners
/// ([nativeChatClipboardPaste]). Other native hosts have no pasteboard reader
/// yet: they report that missing capability rather than pretending no paste
/// happened, and the composer keeps the host field's own text paste.
@@ -1,6 +1,7 @@
import '../../../core/api_gateway.dart';
import '../../pipelines/pipeline_format.dart' show formatDuration;
import '../../runs/domain/run_events.dart' show isTerminalRunStatus;
import '../../runs/domain/run_quota.dart';
/// A `show_run` item's run, as the server records it
/// (`internal/protocol/chat_shown.go` ChatShownRunBody). The server pushes the
@@ -49,6 +50,7 @@ class ChatShownRun {
/// The status in words: the outcome of a finished run when it says more.
String get statusLabel {
if (isWaitingQuotaStatus(status)) return runWaitingQuotaLabel;
final word = status.isEmpty ? 'unknown' : status;
final label = '${word[0].toUpperCase()}${word.substring(1)}';
return finished && outcome.isNotEmpty && outcome != status
+1
View File
@@ -22,6 +22,7 @@ import 'package:flutter/services.dart';
import '../../core/api_gateway.dart';
import '../../core/servers/server_context.dart';
import '../../core/servers/server_scope.dart';
import '../../shell/detached/detached_window_scope.dart';
import '../../shell/windows/window_scope.dart';
import 'shell/chat_shell_dismiss.dart';
import '../terminal/terminal_open_action.dart';
@@ -105,6 +105,7 @@ class SessionActionsButton extends StatelessWidget {
}
IconData _paneIcon(SessionPaneAction action) => switch (action) {
SessionPaneAction.newWindow => Icons.open_in_browser,
SessionPaneAction.addPane => Icons.add_box_outlined,
SessionPaneAction.openChats => Icons.view_quilt_outlined,
SessionPaneAction.centerStage => Icons.center_focus_strong_outlined,
@@ -4,6 +4,7 @@ import '../../../../core/api_gateway.dart';
/// The pane More menu's choices that a chat row's menu also offers.
enum SessionPaneAction {
newWindow,
addPane,
openChats,
centerStage,
@@ -14,6 +14,7 @@ IconData chatShownRunIcon(String status) => switch (status) {
'canceled' => Icons.cancel_outlined,
'interrupted' => Icons.pause_circle_outline,
'waiting' => Icons.front_hand_outlined,
'waiting_quota' => Icons.hourglass_bottom,
'queued' => Icons.schedule,
_ => Icons.play_circle_outline,
};
@@ -21,7 +22,7 @@ IconData chatShownRunIcon(String status) => switch (status) {
Color _statusColor(ColorScheme colors, String status) => switch (status) {
'succeeded' => colors.primary,
'failed' || 'interrupted' => colors.error,
'waiting' => colors.tertiary,
'waiting' || 'waiting_quota' => colors.tertiary,
_ => colors.onSurfaceVariant,
};
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import '../../../shell/detached/detached_window_scope.dart';
import '../../../shell/list_detail_policy.dart';
import '../../../shell/windows/window_entry.dart';
import '../../../shell/windows/window_kind.dart';
@@ -25,6 +26,8 @@ class ChatTiling {
required this.dock,
required this.canFloatActive,
required this.floatActive,
this.release,
this.activeSession,
});
/// Whether the tiling shows [sessionId].
@@ -36,6 +39,13 @@ class ChatTiling {
/// Whether the chord can float the active pane now.
final bool Function() canFloatActive;
final VoidCallback floatActive;
/// Takes [sessionId]'s panes out of the tiling (it went to a window of
/// its own).
final void Function(String sessionId)? release;
/// The active pane's chat.
final String? Function()? activeSession;
}
/// The floating chat windows, for the app's lifetime: the `chat` window kind
@@ -66,6 +76,10 @@ class ChatWindows {
/// The mounted Chat destination's tiling, if it is built.
ChatTiling? tiling;
/// Opens a chat in a window of its own (a browser window or app process);
/// null where the platform has none.
DetachedWindowOpener? detached;
late final ChatWindowKind kind = ChatWindowKind(this);
bool _started = false;
@@ -86,7 +100,8 @@ class ChatWindows {
manager.kinds.register(kind);
FocusManager.instance
..addEarlyKeyEventHandler(_key)
..addEarlyKeyEventHandler(_tabKey);
..addEarlyKeyEventHandler(_tabKey)
..addEarlyKeyEventHandler(_detachKey);
runtime.addSessionReplacedListener(_replacedElsewhere);
runtime.sessions.addListener(_rowsChanged);
manager.addListener(_rowsChanged);
@@ -98,7 +113,8 @@ class ChatWindows {
_started = false;
FocusManager.instance
..removeEarlyKeyEventHandler(_key)
..removeEarlyKeyEventHandler(_tabKey);
..removeEarlyKeyEventHandler(_tabKey)
..removeEarlyKeyEventHandler(_detachKey);
runtime.removeSessionReplacedListener(_replacedElsewhere);
runtime.sessions.removeListener(_rowsChanged);
manager.removeListener(_rowsChanged);
@@ -154,6 +170,35 @@ class ChatWindows {
}
}
/// Opens [sessionId] in a window of its own. Once that window is open the
/// chat leaves this one: its floating window closes and its tiled panes
/// close, as Float takes a pane out of the tiling.
void detach(String sessionId) {
final opener = detached;
if (opener == null || sessionId.isEmpty) return;
opener.openChat(
sessionId,
title: runtime.titleFor(sessionId),
onOpened: () {
final entry = manager.find(chatWindowKind, sessionId);
if (entry != null) manager.close(entry.id);
tiling?.release?.call(sessionId);
},
);
}
/// A detached window gave [sessionId] back: it goes into the tiling, or
/// opens in the Chat destination when that is not built.
void bringBack(String sessionId) {
if (sessionId.isEmpty) return;
final tiling = this.tiling;
if (tiling != null) {
tiling.dock(sessionId);
} else {
openInChat(sessionId);
}
}
/// `/new` in a window's chat: the window follows the new session, unless
/// that session is already open elsewhere.
void startedNewSession(
@@ -242,6 +287,29 @@ class ChatWindows {
return KeyEventResult.handled;
}
/// Alt+Shift+Y sends the chat with the keyboard (a floating window's, else
/// the active tiled pane's) to a new window. Left alone when there is no
/// such chat or no platform window.
KeyEventResult _detachKey(KeyEvent event) {
if (detached == null ||
!detachedWindowShortcut(event, HardwareKeyboard.instance)) {
return KeyEventResult.ignored;
}
final scope = keyboardWindow();
String? id;
if (scope != null) {
if (scope.entry.kind == chatWindowKind) id = scope.entry.contentId;
} else {
final tiling = this.tiling;
if (tiling != null && tiling.canFloatActive()) {
id = tiling.activeSession?.call();
}
}
if (id == null || id.isEmpty) return KeyEventResult.ignored;
if (event is KeyDownEvent) detach(id);
return KeyEventResult.handled;
}
/// Ctrl+Tab and Ctrl+Shift+Tab while a floating chat window holds the
/// keyboard: the next (previous) shown chat window, in open order and
/// wrapping, comes to the top. The window host then gives it the keyboard,
@@ -350,6 +418,12 @@ class ChatWindowKind extends WindowKind {
icon: Icons.vertical_split_outlined,
onPressed: () => windows.dock(entry),
),
if (windows.detached != null)
WindowAction(
label: detachedChatWindowLabel(),
icon: Icons.open_in_browser,
onPressed: () => windows.detach(entry.contentId),
),
];
@override