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.

fix(desktop): explain stalled memory learning (#617)

Dee30d2381b4984
diff --git a/desktop/design/review/2026-10-02-memory-learning-dark.png b/desktop/design/review/2026-10-02-memory-learning-dark.png
new file mode 100644
index 000000000..aec4e125a
Binary files /dev/null and b/desktop/design/review/2026-10-02-memory-learning-dark.png differ
diff --git a/desktop/design/review/2026-10-02-memory-learning-light.png b/desktop/design/review/2026-10-02-memory-learning-light.png
new file mode 100644
index 000000000..27890b0cf
Binary files /dev/null and b/desktop/design/review/2026-10-02-memory-learning-light.png differ
diff --git a/desktop/integration_test/coding_memory_activity_native_test.dart b/desktop/integration_test/coding_memory_activity_native_test.dart
index 734330860..ca10578ac 100644
--- a/desktop/integration_test/coding_memory_activity_native_test.dart
+++ b/desktop/integration_test/coding_memory_activity_native_test.dart
@@ -30,7 +30,7 @@ void main() {
for (final brightness in [Brightness.dark, Brightness.light]) {
testWidgets(
- 'native activity ${brightness.name} rates a selection and removes it after empty recall',
+ 'native memory ${brightness.name} rates recall and explains stalled learning',
(tester) async {
final connection = MemoryFixture()..recalls.add(syntheticRecall());
final library = CodingMemoryLibrary(connection);
@@ -114,6 +114,39 @@ void main() {
find.text('No memories were selected for the last recorded request.'),
findsOneWidget,
);
+ connection.runtime = {
+ 'state': 'ready',
+ 'learning': {'state': 'waiting_for_model'},
+ 'capture': {'state': 'unavailable', 'reason': 'memory_backlog_full'},
+ };
+ await library.refresh();
+ await tester.pumpAndSettle();
+ expect(find.text('Learning needs attention'), findsOneWidget);
+ final review = find.text('Review learning');
+ await tester.ensureVisible(review);
+ Focus.of(tester.element(review)).requestFocus();
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(find.text('Learn from coding sessions'), findsOneWidget);
+ expect(find.textContaining('queue is full'), findsOneWidget);
+ expect(
+ connection.calls.where((p) => p['action'] == 'apply'),
+ hasLength(1),
+ );
+ if (directory != null) {
+ final shot =
+ await (boundary.currentContext!.findRenderObject()
+ as RenderRepaintBoundary)
+ .toImage(pixelRatio: 1);
+ try {
+ final bytes = await shot.toByteData(format: ui.ImageByteFormat.png);
+ await File('$directory/learning-native-${brightness.name}.png')
+ .writeAsBytes(bytes!.buffer.asUint8List());
+ } finally {
+ shot.dispose();
+ }
+ }
expect(tester.takeException(), isNull);
},
);
diff --git a/desktop/lib/companions/coding_memory_view.dart b/desktop/lib/companions/coding_memory_view.dart
index ce12f4674..cff24e99d 100644
--- a/desktop/lib/companions/coding_memory_view.dart
+++ b/desktop/lib/companions/coding_memory_view.dart
@@ -47,11 +47,21 @@ class _CodingMemoryViewState extends State<CodingMemoryView> {
if (mounted && library.valid) await library.refresh();
}
+ void _selectSection(String name) {
+ setState(() => section = name);
+ unawaited(
+ library.refresh(
+ filter: name == 'Project knowledge' ? 'project' : 'personal',
+ ),
+ );
+ }
+
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: library,
builder: (context, _) {
if (library.available == false) return const SizedBox.shrink();
+ final learning = _learningStatus(library);
return DesktopChrome(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -80,16 +90,7 @@ class _CodingMemoryViewState extends State<CodingMemoryView> {
selected: section == name,
onSelected: library.busy || !library.valid
? null
- : (_) {
- setState(() => section = name);
- unawaited(
- library.refresh(
- filter: name == 'Project knowledge'
- ? 'project'
- : 'personal',
- ),
- );
- },
+ : (_) => _selectSection(name),
),
],
),
@@ -100,6 +101,31 @@ class _CodingMemoryViewState extends State<CodingMemoryView> {
padding: EdgeInsets.symmetric(vertical: 12),
child: LinearProgressIndicator(),
),
+ if (library.available == true &&
+ library.valid &&
+ section != 'Learning' &&
+ learning.needsAttention) ...[
+ Text(
+ 'Learning needs attention',
+ style: AppType.body(
+ color: AppPalette.textPrimary,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ const SizedBox(height: 4),
+ _text(learning.message),
+ if (learning.captureIssue != null) ...[
+ const SizedBox(height: 8),
+ _text(learning.captureIssue!),
+ ],
+ TextButton(
+ onPressed: library.busy
+ ? null
+ : () => _selectSection('Learning'),
+ child: const Text('Review learning'),
+ ),
+ const SizedBox(height: 16),
+ ],
if (library.available == true && library.valid)
if (section == 'Learning')
_learning()
@@ -150,8 +176,7 @@ class _CodingMemoryViewState extends State<CodingMemoryView> {
Widget _learning() {
final status = library.status!;
- final runtime = memoryMap(status['runtime']);
- final learning = memoryMap(runtime['learning']);
+ final learning = _learningStatus(library);
final queue = memoryMap(status['queue']);
final jobs = memoryMap(queue['jobs']);
final pending = [
@@ -166,31 +191,14 @@ class _CodingMemoryViewState extends State<CodingMemoryView> {
final gaps =
(memoryMap(queue['retention'])['expiredEpisodes'] as num?)?.toInt() ??
0;
- final state = runtime['state'] == 'off'
- ? 'Your companion is paused. These choices take effect when it resumes.'
- : !library.learn
- ? 'Learning is paused. Your existing memories are still here.'
- : learning['state'] == 'waiting_for_model'
- ? 'Waiting for the model selected in your companion’s terminal. Your model choice stays in control.'
- : runtime['state'] != 'ready'
- ? 'Waiting for your companion’s memory service to be ready.'
- : learning['state'] == 'foreground_busy'
- ? 'Your companion is working. Learning waits until it is free.'
- : learning['state'] == 'waiting_for_quiet'
- ? 'Giving your latest request a moment before reviewing completed work.'
- : learning['state'] == 'budget_deferred'
- ? 'Waiting for the next learning allowance before reviewing more work.'
- : learning['state'] == 'notebook_updated'
- ? 'A project notebook was updated from saved memories. Its sources and conditions are available in Project knowledge.'
- : learning['state'] == 'notebook_empty'
- ? 'The latest notebook review found no supported explanation to add. Individual memories are still available.'
- : learning['state'] == 'stale'
- ? 'The source memories or learning settings changed during review. That result was not saved.'
- : 'Learning from completed coding work. Your companion and new requests take priority.';
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- _text(state),
+ _text(learning.message),
+ if (learning.captureIssue != null) ...[
+ const SizedBox(height: 8),
+ _text(learning.captureIssue!),
+ ],
const SizedBox(height: 12),
_preference(
'Learn from coding sessions',
@@ -273,6 +281,67 @@ class _CodingMemoryViewState extends State<CodingMemoryView> {
);
}
+({String message, String? captureIssue, bool needsAttention}) _learningStatus(
+ CodingMemoryLibrary library,
+) {
+ final runtime = memoryMap(library.status?['runtime']);
+ final learning = memoryMap(runtime['learning']);
+ if (!library.learn || learning['state'] == 'learning_off') {
+ return (
+ message: 'Learning is paused. Your existing memories are still here.',
+ captureIssue: null,
+ needsAttention: false,
+ );
+ }
+ if (runtime['state'] != 'ready') {
+ return (
+ message: runtime['state'] == 'off'
+ ? 'Your companion is paused. Resume it to continue learning.'
+ : 'Waiting for your companion’s memory service to be ready.',
+ captureIssue: null,
+ needsAttention: true,
+ );
+ }
+ final capture = memoryMap(runtime['capture']);
+ final captureIssue = capture['state'] != 'unavailable'
+ ? null
+ : capture['reason'] == 'memory_backlog_full'
+ ? 'The learning queue is full. Some new work could not be added. Capture can retry as reviews free space; queued work may expire before it is reviewed.'
+ : 'Some recent work could not be read for learning. Your existing memories are still available.';
+ final state = learning['state'];
+ final message = switch (state) {
+ 'waiting_for_model' => 'Waiting for your companion’s model. Check that its terminal beside this viewer is running with a model selected, and complete any setup shown there.',
+ 'foreground_busy' =>
+ 'Your companion is working. Learning waits until it is free.',
+ 'waiting_for_quiet' =>
+ 'Giving your latest request a moment before reviewing completed work.',
+ 'budget_deferred' =>
+ 'Waiting for the next learning allowance before reviewing more work.',
+ 'failed' => 'The last memory review could not finish. Queued work can be retried while learning is on.',
+ 'source_incomplete' =>
+ 'Some work has incomplete source evidence and cannot yet be reviewed.',
+ 'idle' => 'No work is ready for review right now. Learning is on for new, included coding sessions.',
+ 'learned' => 'The latest review saved new memories. You can read their evidence in your library.',
+ 'no_useful_memory' =>
+ 'The latest review found no useful memory to save. Learning is still on.',
+ 'notebook_updated' => 'A project notebook was updated from saved memories. Its sources and conditions are available in Project knowledge.',
+ 'notebook_empty' => 'The latest notebook review found no supported explanation to add. Individual memories are still available.',
+ 'stale' => 'The source memories or learning settings changed during review. That result was not saved.',
+ _ => 'Learning is on. Completed coding work is reviewed when your companion is available.',
+ };
+ return (
+ message: message,
+ captureIssue: captureIssue,
+ needsAttention:
+ captureIssue != null ||
+ const [
+ 'waiting_for_model',
+ 'failed',
+ 'source_incomplete',
+ ].contains(state),
+ );
+}
+
Widget _text(String value, {bool small = false}) => Text(
value,
style: small
diff --git a/desktop/test/coding_memory_view_test.dart b/desktop/test/coding_memory_view_test.dart
index 29699d6d2..aebdd6235 100644
--- a/desktop/test/coding_memory_view_test.dart
+++ b/desktop/test/coding_memory_view_test.dart
@@ -1051,6 +1051,128 @@ void main() {
},
);
+ testWidgets(
+ 'stalled learning is visible from the library and review only navigates',
+ (tester) async {
+ transport.runtime = {
+ 'state': 'ready',
+ 'learning': {'state': 'waiting_for_model'},
+ 'capture': {'state': 'unavailable', 'reason': 'memory_backlog_full'},
+ };
+ await mount(tester);
+ expect(find.text('Learning needs attention'), findsOneWidget);
+ expect(find.textContaining('queue is full'), findsOneWidget);
+ expect(
+ find.textContaining('terminal beside this viewer'),
+ findsOneWidget,
+ );
+ await tap(tester, 'Review learning');
+ expect(find.text('Learn from coding sessions'), findsOneWidget);
+ expect(find.textContaining('queue is full'), findsOneWidget);
+ expect(
+ transport.calls.every(
+ (p) => p['action'] != 'preview' && p['action'] != 'apply',
+ ),
+ isTrue,
+ );
+ expect(transport.learn, isTrue);
+ expect(transport.recall, isTrue);
+
+ transport.runtime = {
+ 'state': 'ready',
+ 'learning': {'state': 'idle'},
+ 'capture': {'state': 'idle', 'sources': 0},
+ };
+ await library.refresh();
+ await tester.pumpAndSettle();
+ expect(find.textContaining('queue is full'), findsNothing);
+ expect(find.textContaining('No work is ready'), findsOneWidget);
+ await tap(tester, 'How you work');
+ expect(find.text('Learning needs attention'), findsNothing);
+ },
+ );
+
+ testWidgets('pausing learning hides stale failures and preserves recall', (
+ tester,
+ ) async {
+ transport.learn = false;
+ transport.runtime = {
+ 'state': 'off',
+ 'learning': {'state': 'failed'},
+ 'capture': {'state': 'unavailable', 'reason': 'memory_backlog_full'},
+ };
+ await mount(tester);
+ expect(find.text('Learning needs attention'), findsNothing);
+ await tap(tester, 'Learning');
+ expect(find.textContaining('Learning is paused'), findsOneWidget);
+ expect(find.textContaining('queue is full'), findsNothing);
+ expect(tester.widgetList<Switch>(find.byType(Switch)).map((s) => s.value), [
+ false,
+ true,
+ ]);
+ });
+
+ for (final state in [
+ ('off', null, 'Resume it', true),
+ ('unavailable', null, 'memory service', true),
+ ('ready', 'failed', 'could not finish', true),
+ ('ready', 'source_incomplete', 'incomplete source evidence', true),
+ ('ready', 'no_useful_memory', 'no useful memory to save', false),
+ ('ready', 'foreground_busy', 'until it is free', false),
+ ('ready', 'budget_deferred', 'next learning allowance', false),
+ ('ready', 'future_state', 'Learning is on.', false),
+ ]) {
+ testWidgets('learning distinguishes ${state.$1}/${state.$2}', (
+ tester,
+ ) async {
+ transport.runtime = {
+ 'state': state.$1,
+ 'learning': {'state': state.$2},
+ };
+ await mount(tester);
+ expect(
+ find.text('Learning needs attention'),
+ state.$4 ? findsOneWidget : findsNothing,
+ );
+ await tap(tester, 'Learning');
+ expect(find.textContaining(state.$3), findsOneWidget);
+ expect(
+ find.textContaining('Learning from completed coding work.'),
+ findsNothing,
+ );
+ });
+ }
+
+ for (final brightness in [Brightness.dark, Brightness.light]) {
+ for (final scale in [1.0, 2.0]) {
+ testWidgets(
+ 'learning backlog ${brightness.name} ${scale}x stays readable',
+ (tester) async {
+ transport.runtime = {
+ 'state': 'ready',
+ 'learning': {'state': 'waiting_for_model'},
+ 'capture': {
+ 'state': 'unavailable',
+ 'reason': 'memory_backlog_full',
+ },
+ };
+ await mount(
+ tester,
+ brightness: brightness,
+ scale: scale,
+ size: Size(scale == 1 ? 850 : 440, 900),
+ );
+ await capture(tester, 'learning-notice-${brightness.name}-${scale}x');
+ await tap(tester, 'Review learning');
+ await capture(tester, 'learning-status-${brightness.name}-${scale}x');
+ await tester.ensureVisible(find.text('Recall useful memories'));
+ await tester.pumpAndSettle();
+ expect(tester.takeException(), isNull);
+ },
+ );
+ }
+ }
+
testWidgets(
'learning and recall remain independent and do not change until settings are applied',
(tester) async {
diff --git a/desktop/test/support/coding_memory_fixture.dart b/desktop/test/support/coding_memory_fixture.dart
index 6baeceb1b..487b3e22d 100644
--- a/desktop/test/support/coding_memory_fixture.dart
+++ b/desktop/test/support/coding_memory_fixture.dart
@@ -178,6 +178,7 @@ class MemoryFixture extends CodingMemoryConnection {
final calls = <Map<String, dynamic>>[];
Future<Map<String, dynamic>> Function(Map<String, dynamic>)? handle;
Map<String, dynamic> record = syntheticMemory();
+ Map<String, dynamic> runtime = {'state': 'ready'};
bool learn = true, recall = true, present = true;
String? cursor;
String? refuseApply;
@@ -223,7 +224,7 @@ class MemoryFixture extends CodingMemoryConnection {
case 'status':
return {
'ok': true,
- 'runtime': {'state': 'ready'},
+ 'runtime': runtime,
'preferences': {'learn': learn, 'recall': recall},
'queue': {
'jobs': {'queued': 2, 'reviewing': 1, 'budget_deferred': 1},