fix: keep task selection order stable
This commit is contained in:
parent
caa40a910b
commit
fdc96f5246
@ -210,7 +210,6 @@ extension AppControllerDesktopThreadActions on AppController {
|
||||
nextSessionKey,
|
||||
executionTarget: nextTarget,
|
||||
messageViewMode: nextViewMode,
|
||||
updatedAtMs: DateTime.now().millisecondsSinceEpoch.toDouble(),
|
||||
);
|
||||
await ensureDesktopTaskThreadBindingInternal(
|
||||
nextSessionKey,
|
||||
|
||||
@ -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 <String, String>{},
|
||||
);
|
||||
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),
|
||||
<String>[newerTask, olderTask],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'returns unspecified when a saved provider is no longer in the current catalog',
|
||||
() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user