fix: use role-specific cursor keys in review_ready and arbiter_requested paths

The review_ready and arbiter_requested paths in processGroupMessages
were advancing the default (owner) cursor instead of the role-specific
cursor. This caused the reviewer to miss the owner's messages because
the owner cursor had already moved past them.

Now review_ready advances chatJid:reviewer cursor only, and
arbiter_requested advances chatJid:arbiter cursor only.
This commit is contained in:
Eyejoker
2026-03-30 22:50:26 +09:00
parent 4ccd45e549
commit 46926f32f3
2 changed files with 6 additions and 2 deletions

View File

@@ -631,7 +631,7 @@ describe('createMessageRuntime', () => {
expect(result).toBe(true); expect(result).toBe(true);
expect(agentRunner.runAgentProcess).toHaveBeenCalledTimes(1); expect(agentRunner.runAgentProcess).toHaveBeenCalledTimes(1);
expect(lastAgentTimestamps[chatJid]).toBe('41'); expect(lastAgentTimestamps[`${chatJid}:reviewer`]).toBe('41');
expect(saveState).toHaveBeenCalled(); expect(saveState).toHaveBeenCalled();
expect(channel.sendMessage).toHaveBeenCalledWith(chatJid, '리뷰 확인 완료'); expect(channel.sendMessage).toHaveBeenCalledWith(chatJid, '리뷰 확인 완료');
}); });

View File

@@ -624,7 +624,8 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): {
? `${parts.join('\n\n')}\n\nReview the latest owner changes in the workspace.` ? `${parts.join('\n\n')}\n\nReview the latest owner changes in the workspace.`
: 'Review the latest owner changes in the workspace.'; : 'Review the latest owner changes in the workspace.';
// Advance cursor past filtered bot messages so they aren't re-processed // Advance reviewer cursor (not owner cursor) so the reviewer
// still sees the owner's messages on subsequent turns.
const lastRaw = rawMissedMessages[rawMissedMessages.length - 1]; const lastRaw = rawMissedMessages[rawMissedMessages.length - 1];
const cursor = lastRaw?.seq ?? lastRaw?.timestamp; const cursor = lastRaw?.seq ?? lastRaw?.timestamp;
if (cursor != null) { if (cursor != null) {
@@ -633,6 +634,7 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): {
deps.saveState, deps.saveState,
chatJid, chatJid,
cursor, cursor,
`${chatJid}:reviewer`,
); );
} }
@@ -654,6 +656,7 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): {
(pendingReviewTask.status === 'arbiter_requested' || (pendingReviewTask.status === 'arbiter_requested' ||
pendingReviewTask.status === 'in_arbitration') pendingReviewTask.status === 'in_arbitration')
) { ) {
// Advance only the arbiter cursor — do NOT touch the owner cursor
const lastRaw = rawMissedMessages[rawMissedMessages.length - 1]; const lastRaw = rawMissedMessages[rawMissedMessages.length - 1];
const cursor = lastRaw?.seq ?? lastRaw?.timestamp; const cursor = lastRaw?.seq ?? lastRaw?.timestamp;
if (cursor != null) { if (cursor != null) {
@@ -662,6 +665,7 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): {
deps.saveState, deps.saveState,
chatJid, chatJid,
cursor, cursor,
`${chatJid}:arbiter`,
); );
} }