Preserve center stage width with file explorer

Report each pane's active explorer width to the center-stage layout so the reading column stays at its preferred width while constrained workspaces still make room for side strips. Restore the allocation when switching panes or closing the explorer.
This commit is contained in:
2026-11-11 18:25:44 +00:00
parent 2307d45417
commit d17d356814
6 changed files with 177 additions and 18 deletions
@@ -38,6 +38,7 @@ class ChatCenterStageLayout {
Size size,
List<String> order,
String? activeId,
Map<String, double>? paneExtraWidths,
) {
if (order.length < 2 || activeId == null || !order.contains(activeId)) {
return null;
@@ -45,7 +46,7 @@ class ChatCenterStageLayout {
final others = order.length - 1;
final available = size.width - chatCenterStageGap * others;
final stage = math.min(
chatCenterStageWidth,
chatCenterStageWidth + (paneExtraWidths?[activeId] ?? 0),
available - others * chatCenterStageStripMinimumWidth,
);
if (stage < chatPaneMinimumWidth) return null;
@@ -84,6 +84,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
ChatWorkspaceGeometry? _geometry;
String? _lastActiveId;
Set<String> _visibleSessionIds = const {};
final Map<String, double> _paneExtraWidths = {};
late final ChatPaneBackdrop _backdrop;
void _backdropChanged() {
if (mounted) setState(() {});
@@ -109,6 +110,16 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
});
}
void _reportPaneExtraWidth(String paneId, double width) {
if ((_paneExtraWidths[paneId] ?? 0) == width) return;
if (width == 0) {
_paneExtraWidths.remove(paneId);
} else {
_paneExtraWidths[paneId] = width;
}
if (mounted) setState(() {});
}
void _motionSettled(AnimationStatus status) {
if (status != AnimationStatus.completed) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -272,9 +283,12 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
engaged: engaged,
split: geometry.panes,
stage: engaged && widget.centerStage?.value == true
? ChatCenterStageLayout.of(constraints.biggest, [
for (final pane in panes) pane.id,
], activeId)
? ChatCenterStageLayout.of(
constraints.biggest,
[for (final pane in panes) pane.id],
activeId,
_paneExtraWidths,
)
: null,
animate: !MediaQuery.disableAnimationsOf(context),
);
@@ -461,6 +475,8 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
moveTargets: moveTargets ?? const {},
onActionBarPointerDown: () => actionBarPointerDown = true,
onActionBarPointerUp: () => actionBarPointerDown = false,
onPreferredWidthChanged: (width) =>
_reportPaneExtraWidth(pane.id, width),
child: Builder(
builder: (paneContext) =>
widget.paneBuilder(paneContext, pane, active),
@@ -16,6 +16,7 @@ class ChatWorkspacePaneScope extends InheritedWidget {
this.moveTargets = const {},
this.onActionBarPointerDown,
this.onActionBarPointerUp,
this.onPreferredWidthChanged,
required super.child,
});
@@ -35,6 +36,9 @@ class ChatWorkspacePaneScope extends InheritedWidget {
final VoidCallback? onActionBarPointerDown;
final VoidCallback? onActionBarPointerUp;
/// Reports width needed by content that sits beside its reading column.
final ValueChanged<double>? onPreferredWidthChanged;
static ChatWorkspacePaneScope? maybeOf(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<ChatWorkspacePaneScope>();
@@ -47,7 +51,8 @@ class ChatWorkspacePaneScope extends InheritedWidget {
movable != oldWidget.movable ||
!mapEquals(moveTargets, oldWidget.moveTargets) ||
onActionBarPointerDown != oldWidget.onActionBarPointerDown ||
onActionBarPointerUp != oldWidget.onActionBarPointerUp;
onActionBarPointerUp != oldWidget.onActionBarPointerUp ||
onPreferredWidthChanged != oldWidget.onPreferredWidthChanged;
}
/// Marks a pane header/toolbar. Its controls remain interactive, but focusing