Keep background pane updates from stealing destination navigation

This commit is contained in:
2026-11-06 18:24:58 +00:00
parent 4bae206afd
commit 417a696785
4 changed files with 80 additions and 8 deletions
@@ -28,15 +28,8 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
_workspaceSignature = signature;
void update() {
if (!mounted) return;
final id = _workspace.activePane?.sessionId;
setState(() {});
if (!_workspaceVisible ||
id == null ||
id == _publishedWorkspaceSession) {
return;
}
_publishedWorkspaceSession = id;
widget.onSessionSelected?.call(id);
_publishWorkspaceRoute();
}
if (SchedulerBinding.instance.schedulerPhase ==
@@ -47,6 +40,20 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
}
}
void _publishWorkspaceRoute() {
if (!mounted) return;
final id = _workspace.activePane?.sessionId;
final destination = ShellBarScope.maybeOf(context)?.registry.focus;
if (!_workspaceVisible ||
id == null ||
id == _publishedWorkspaceSession ||
(destination != null && destination != AppDestination.chat)) {
return;
}
_publishedWorkspaceSession = id;
widget.onSessionSelected?.call(id);
}
void _split(JsonMap session, ChatSplitAxis axis) {
final id = '${session['id'] ?? ''}';
if (id.isEmpty) return;
+5
View File
@@ -435,6 +435,11 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
@override
Widget build(BuildContext context) {
final selected = _selected;
if (_workspaceVisible && selected != _publishedWorkspaceSession) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => _publishWorkspaceRoute(),
);
}
_offeredNext = selected != null && _nextAfter(selected) != null;
// A phone opens a chat as a real Navigator page with stock Back. A wide
// window keeps the destination rail and the chat list beside the open