Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions apps/desktop/src/main/__tests__/workhub-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,7 @@ test('conversation acknowledges a durable assignment before projecting target ex
sessions,
coordination: {
open: async (handler) => {
handler([assignment], [{
actionId: assignment.assignment!.actionId,
targetSessionId: assignment.assignment!.targetSessionId,
sequence: 0,
}]);
handler([assignment]);
return { close: async () => undefined };
},
record: async (input) => ({ turnId: input.turnId }),
Expand Down Expand Up @@ -294,11 +290,7 @@ test('conversation feedback never lets an older refresh overwrite newer target s
coordination: {
open: async (handler) => {
const assignment = coordinationAssignmentTurn();
handler([assignment], [{
actionId: assignment.assignment!.actionId,
targetSessionId: assignment.assignment!.targetSessionId,
sequence: 0,
}]);
handler([assignment]);
return { close: async () => undefined };
},
record: async (input) => ({ turnId: input.turnId }),
Expand Down Expand Up @@ -340,11 +332,7 @@ test('direct stop bypasses routing candidates and preserves a not_owned delegati
sessions,
coordination: {
open: async (handler) => {
handler([coordinationAssignmentTurn()], [{
actionId: 'action-1',
targetSessionId: 'payments',
sequence: 0,
}]);
handler([coordinationAssignmentTurn()]);
return { close: async () => undefined };
},
record: async (input) => ({ turnId: input.turnId }),
Expand Down Expand Up @@ -400,7 +388,7 @@ test('an anaphoric stop asks for a fresh named imperative without offering a rou
sessions,
coordination: {
open: async (handler) => {
handler([], [{ actionId: 'action-1', targetSessionId: 'payments', sequence: 0 }]);
handler([]);
return { close: async () => undefined };
},
record: async (input) => ({ turnId: input.turnId }),
Expand Down Expand Up @@ -430,7 +418,7 @@ test('a named stop reports the Gate refusal instead of judging the target itself
sessions,
coordination: {
open: async (handler) => {
handler([], []);
handler([]);
return { close: async () => undefined };
},
record: async (input) => ({ turnId: input.turnId }),
Expand Down Expand Up @@ -464,7 +452,7 @@ test('a stop that fails for any other reason is a fault, not a clarification', a
sessions,
coordination: {
open: async (handler) => {
handler([], []);
handler([]);
return { close: async () => undefined };
},
record: async (input) => ({ turnId: input.turnId }),
Expand Down Expand Up @@ -494,7 +482,7 @@ test('stop-shaped ordinary work routes normally instead of looping on clarificat
sessions,
coordination: {
open: async (handler) => {
handler([], [{ actionId: 'action-1', targetSessionId: 'payments', sequence: 0 }]);
handler([]);
return { close: async () => undefined };
},
record: async (input) => ({ turnId: input.turnId }),
Expand Down Expand Up @@ -1785,6 +1773,7 @@ test('production natural-language corrections retain the prior delegation link',
}),
]);
const candidateSetId = `sha256:${'e'.repeat(64)}`;
const latestActionIdBySessionId = new Map<string, string>();
const candidates = [
{
candidateRef: 'candidate-login',
Expand Down Expand Up @@ -1814,7 +1803,15 @@ test('production natural-language corrections retain the prior delegation link',
coordination: {
open: async () => ({ close: async () => undefined }),
record: async (input) => ({ turnId: input.turnId }),
candidates: async () => ({ candidateSetId, candidates }),
candidates: async () => ({
candidateSetId,
candidates: candidates.map((candidate) => {
const latestDelegationActionId = latestActionIdBySessionId.get(candidate.sessionId);
return latestDelegationActionId
? { ...candidate, latestDelegationActionId }
: candidate;
}),
}),
act: async (input) => {
actions.push(input);
if (input.proposal.disposition === 'replace') {
Expand All @@ -1826,6 +1823,10 @@ test('production natural-language corrections retain the prior delegation link',
targetTurnId: `turn-${input.actionId}`,
};
}
latestActionIdBySessionId.set(
input.proposal.target.candidateRef === 'candidate-login' ? 'login' : 'payment',
input.actionId,
);
return {
disposition: 'replace',
replacementDisposition: 'delegate_existing',
Expand All @@ -1838,6 +1839,10 @@ test('production natural-language corrections retain the prior delegation link',
if (input.proposal.disposition !== 'delegate_existing') {
throw new Error('unexpected test disposition');
}
latestActionIdBySessionId.set(
input.proposal.candidateRef === 'candidate-login' ? 'login' : 'payment',
input.actionId,
);
return {
disposition: 'delegate_existing',
targetSessionId: input.proposal.candidateRef === 'candidate-login'
Expand Down
Loading