diff --git a/lib/app/app_controller_desktop_thread_actions.dart b/lib/app/app_controller_desktop_thread_actions.dart index d2b051b6..f92e7a06 100644 --- a/lib/app/app_controller_desktop_thread_actions.dart +++ b/lib/app/app_controller_desktop_thread_actions.dart @@ -210,7 +210,6 @@ extension AppControllerDesktopThreadActions on AppController { nextSessionKey, executionTarget: nextTarget, messageViewMode: nextViewMode, - updatedAtMs: DateTime.now().millisecondsSinceEpoch.toDouble(), ); await ensureDesktopTaskThreadBindingInternal( nextSessionKey, diff --git a/test/runtime/assistant_execution_target_test.dart b/test/runtime/assistant_execution_target_test.dart index 929b1062..929a7fee 100644 --- a/test/runtime/assistant_execution_target_test.dart +++ b/test/runtime/assistant_execution_target_test.dart @@ -348,6 +348,54 @@ void main() { expect(keys, isNot(contains('session-1'))); }); + test( + 'switching sessions does not refresh task ordering timestamp', + () async { + final localHome = await Directory.systemTemp.createTemp( + 'xworkmate-stable-task-selection-home-', + ); + addTearDown(() async { + if (await localHome.exists()) { + await localHome.delete(recursive: true); + } + }); + final controller = AppController( + environmentOverride: const {}, + ); + addTearDown(controller.dispose); + controller.resolvedUserHomeDirectoryInternal = localHome.path; + + const newerTask = 'draft:newer-task'; + const olderTask = 'draft:older-task'; + const newerUpdatedAtMs = 2000.0; + const olderUpdatedAtMs = 1000.0; + controller.upsertTaskThreadInternal( + newerTask, + executionTarget: AssistantExecutionTarget.gateway, + messageViewMode: AssistantMessageViewMode.rendered, + updatedAtMs: newerUpdatedAtMs, + ); + controller.upsertTaskThreadInternal( + olderTask, + executionTarget: AssistantExecutionTarget.gateway, + messageViewMode: AssistantMessageViewMode.rendered, + updatedAtMs: olderUpdatedAtMs, + ); + + await controller.switchSession(olderTask); + + expect(controller.currentSessionKey, olderTask); + expect( + controller.requireTaskThreadForSessionInternal(olderTask).updatedAtMs, + olderUpdatedAtMs, + ); + expect( + controller.assistantSessions.map((item) => item.key).take(2), + [newerTask, olderTask], + ); + }, + ); + test( 'returns unspecified when a saved provider is no longer in the current catalog', () {