Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Thread pane: keep a width the person chose, 280 included (#2430)

0xken1575ab3a0285bf
diff --git a/desktop/lib/super_tabs/pane_layout.dart b/desktop/lib/super_tabs/pane_layout.dart
index 321196cdb..f802ede41 100644
--- a/desktop/lib/super_tabs/pane_layout.dart
+++ b/desktop/lib/super_tabs/pane_layout.dart
@@ -88,11 +88,13 @@ class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
: fallback;
setState(() {
_left = width('left', _left);
- // Builds before 10-31 saved the right pane's default with any
- // divider move: 280 is that default (and the minimum), so it reads as
- // no choice and a thread still opens at its own width.
+ // A width the person chose is saved with that mark and kept
+ // exactly, 280 included. Builds before the mark saved the right
+ // pane's default (280, also the minimum) with any divider move: an
+ // unmarked 280 reads as no choice, so a thread opens at its own width.
final right = width('right', -1);
- if (right > 0 && right != SuperTabPaneLayout.rightWidth) {
+ final chosen = value is Map && value['rightChosen'] == true;
+ if (right > 0 && (chosen || right != SuperTabPaneLayout.rightWidth)) {
_right = right;
}
});
@@ -104,7 +106,11 @@ class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
void _save() {
final store = widget.storage;
if (store == null) return;
- final value = jsonEncode({'left': _left, 'right': ?_right});
+ final right = _right;
+ final value = jsonEncode({
+ 'left': _left,
+ if (right != null) ...{'right': right, 'rightChosen': true},
+ });
_writing = _writing
.then((_) => store.write(SuperTabPaneLayout.storageKey, value))
.catchError((Object _) {});
diff --git a/desktop/test/super_tab_pane_layout_test.dart b/desktop/test/super_tab_pane_layout_test.dart
index 4f21fede4..bfb425156 100644
--- a/desktop/test/super_tab_pane_layout_test.dart
+++ b/desktop/test/super_tab_pane_layout_test.dart
@@ -255,4 +255,59 @@ void main() {
await mount(tester, chosen, rightDefault: SuperTabPaneLayout.threadWidth);
expect(tester.getSize(right).width, 310);
});
+
+ testWidgets('a thread dragged to its 280px minimum keeps 280 after a '
+ 'restart, and the roster keeps its own', (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final store = MemoryStore();
+ const thread = SuperTabPaneLayout.threadWidth;
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, 340);
+ await tester.drag(rightHandle, const Offset(1000, 0));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(right).width, closeTo(280, 1));
+ final saved = jsonDecode(store.values[SuperTabPaneLayout.storageKey]!);
+ expect(saved['right'], closeTo(280, 1));
+ expect(saved['rightChosen'], isTrue);
+
+ // A restart: the layout is built afresh from what was saved.
+ await tester.pumpWidget(const SizedBox());
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, closeTo(280, 1));
+ await tester.pumpWidget(const SizedBox());
+ await mount(tester, store);
+ expect(tester.getSize(right).width, closeTo(280, 1));
+
+ // Moving the left divider afterwards keeps the choice.
+ await tester.drag(leftHandle, const Offset(40, 0));
+ await tester.pumpAndSettle();
+ final again = jsonDecode(store.values[SuperTabPaneLayout.storageKey]!);
+ expect(again['rightChosen'], isTrue);
+ await tester.pumpWidget(const SizedBox());
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, closeTo(280, 1));
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a saved width marked as chosen is kept exactly; an old one '
+ 'without the mark keeps today\'s reading', (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ const thread = SuperTabPaneLayout.threadWidth;
+ for (final (saved, expected) in [
+ ('{"left":400,"right":280,"rightChosen":true}', 280.0),
+ ('{"left":400,"right":310,"rightChosen":true}', 310.0),
+ ('{"left":400,"right":280}', 340.0),
+ ('{"left":400,"right":310}', 310.0),
+ ('{"left":400,"right":280,"rightChosen":"yes"}', 340.0),
+ ]) {
+ final store = MemoryStore()
+ ..values[SuperTabPaneLayout.storageKey] = saved;
+ await tester.pumpWidget(const SizedBox());
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, expected, reason: saved);
+ expect(tester.getSize(left).width, 400, reason: saved);
+ }
+ });
}