mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Prefer fresh agent typing over retained outcomes
Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -123,7 +123,7 @@ final composerActivityStateProvider = Provider.autoDispose
|
||||
humans.add(entry);
|
||||
continue;
|
||||
}
|
||||
if (signals.containsKey(pubkey)) continue;
|
||||
if (signals[pubkey]?.isWorking == true) continue;
|
||||
final turn = activeByAgent[pubkey];
|
||||
final liveTurn = turn?.isWorking == true ? turn : null;
|
||||
signals[pubkey] = WorkingAgentSignal(
|
||||
|
||||
@@ -114,55 +114,68 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test('thread typing does not inherit a retained terminal turn', () {
|
||||
final failedTurn = _turn('agent-a', phase: AgentTurnPhase.error);
|
||||
final container = ProviderContainer(
|
||||
overrides: [
|
||||
currentPubkeyProvider.overrideWith((ref) => 'owner'),
|
||||
channelMembersProvider(
|
||||
_channelId,
|
||||
).overrideWith((ref) async => const <ChannelMember>[]),
|
||||
channelTypingProvider(_channelId).overrideWith(
|
||||
() => _FakeTypingNotifier(const [
|
||||
TypingEntry(
|
||||
pubkey: 'agent-a',
|
||||
threadHeadId: 'thread-1',
|
||||
expiresAtMs: 9999999999999,
|
||||
for (final retainedThreadHeadId in <String?>[null, 'thread-1']) {
|
||||
test(
|
||||
'thread typing replaces a retained terminal turn '
|
||||
'${retainedThreadHeadId == null ? 'from another scope' : 'in the same scope'}',
|
||||
() {
|
||||
final failedTurn = _turn(
|
||||
'agent-a',
|
||||
phase: AgentTurnPhase.error,
|
||||
threadHeadId: retainedThreadHeadId,
|
||||
);
|
||||
final container = ProviderContainer(
|
||||
overrides: [
|
||||
currentPubkeyProvider.overrideWith((ref) => 'owner'),
|
||||
channelMembersProvider(
|
||||
_channelId,
|
||||
).overrideWith((ref) async => const <ChannelMember>[]),
|
||||
channelTypingProvider(_channelId).overrideWith(
|
||||
() => _FakeTypingNotifier(const [
|
||||
TypingEntry(
|
||||
pubkey: 'agent-a',
|
||||
threadHeadId: 'thread-1',
|
||||
expiresAtMs: 9999999999999,
|
||||
),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
),
|
||||
agentMentionPubkeysProvider(
|
||||
_channelId,
|
||||
).overrideWith((ref) => const {'agent-a'}),
|
||||
agentOwnersProvider.overrideWithValue(
|
||||
const AsyncData({'agent-a': 'owner'}),
|
||||
),
|
||||
userCacheProvider.overrideWith(_FakeUserCacheNotifier.new),
|
||||
observerRelayProvider.overrideWith(
|
||||
() => _FakeObserverRelayNotifier({
|
||||
'agent-a': [_observerFrame('agent-a')],
|
||||
}),
|
||||
),
|
||||
composerAgentTurnStatesProvider.overrideWithValue([failedTurn]),
|
||||
],
|
||||
agentMentionPubkeysProvider(
|
||||
_channelId,
|
||||
).overrideWith((ref) => const {'agent-a'}),
|
||||
agentOwnersProvider.overrideWithValue(
|
||||
const AsyncData({'agent-a': 'owner'}),
|
||||
),
|
||||
userCacheProvider.overrideWith(_FakeUserCacheNotifier.new),
|
||||
observerRelayProvider.overrideWith(
|
||||
() => _FakeObserverRelayNotifier({
|
||||
'agent-a': [_observerFrame('agent-a')],
|
||||
}),
|
||||
),
|
||||
composerAgentTurnStatesProvider.overrideWithValue([failedTurn]),
|
||||
],
|
||||
);
|
||||
addTearDown(container.dispose);
|
||||
|
||||
final signal = container
|
||||
.read(
|
||||
composerActivityStateProvider((
|
||||
channelId: _channelId,
|
||||
threadHeadId: 'thread-1',
|
||||
)),
|
||||
)
|
||||
.agents
|
||||
.single;
|
||||
|
||||
expect(signal.source, AgentWorkingSource.typing);
|
||||
expect(signal.isWorking, isTrue);
|
||||
expect(signal.turnId, isNull);
|
||||
expect(signal.startedAt, isNull);
|
||||
expect(container.read(workingBotPubkeysProvider(_channelId)), {
|
||||
'agent-a',
|
||||
});
|
||||
},
|
||||
);
|
||||
addTearDown(container.dispose);
|
||||
|
||||
final signal = container
|
||||
.read(
|
||||
composerActivityStateProvider((
|
||||
channelId: _channelId,
|
||||
threadHeadId: 'thread-1',
|
||||
)),
|
||||
)
|
||||
.agents
|
||||
.single;
|
||||
|
||||
expect(signal.source, AgentWorkingSource.typing);
|
||||
expect(signal.isWorking, isTrue);
|
||||
expect(signal.turnId, isNull);
|
||||
expect(signal.startedAt, isNull);
|
||||
});
|
||||
}
|
||||
|
||||
test(
|
||||
'keeps a scoped terminal outcome reachable after thread typing stops',
|
||||
|
||||
Reference in New Issue
Block a user