Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed app/src/providers/__tests__/useOpenHumanExternalStore.reload.test.tsx,app/src/p

Steven Enamakel71c66d45817e
diff --git a/app/src/providers/__tests__/useOpenHumanExternalStore.reload.test.tsx b/app/src/providers/__tests__/useOpenHumanExternalStore.reload.test.tsx
index 11b0ac1c13..838f2dc578 100644
--- a/app/src/providers/__tests__/useOpenHumanExternalStore.reload.test.tsx
+++ b/app/src/providers/__tests__/useOpenHumanExternalStore.reload.test.tsx
@@ -168,6 +168,22 @@ describe('onReload — regenerating an assistant reply', () => {
expect(cachedIds(store)).toEqual(messages.slice(0, 7).map(m => m.id));
});
+ it('resolves the reply after parentId when sourceId is absent', async () => {
+ const store = buildStore();
+ const { result } = mountAdapter(store);
+ const onReload = result.current.onReload as (
+ parentId: string | null,
+ config?: { sourceId?: string | null }
+ ) => Promise<void>;
+
+ await onReload('msg_u2', {});
+
+ expect(hoisted.regenerate).toHaveBeenCalledWith({
+ threadId: THREAD_ID,
+ messageId: 'agent:req-2',
+ });
+ });
+
it('refuses an unresolvable earlier reply without calling the RPC', async () => {
const store = buildStore();
const { result } = mountAdapter(store);
diff --git a/app/src/providers/useOpenHumanExternalStore.ts b/app/src/providers/useOpenHumanExternalStore.ts
index 5f46be371a..b8655b7205 100644
--- a/app/src/providers/useOpenHumanExternalStore.ts
+++ b/app/src/providers/useOpenHumanExternalStore.ts
@@ -631,7 +631,15 @@ export function useOpenHumanExternalStore(
log('reload skipped: no thread selected');
return;
}
- const sourceId = config?.sourceId ?? null;
+ // assistant-ui always sends the reply as `sourceId`; if only the user
+ // prompt (`parentId`) arrives, the reply is the first agent row after it.
+ let sourceId = config?.sourceId ?? null;
+ if (!sourceId && parentId) {
+ const parentIndex = messages.findIndex(m => m.id === parentId);
+ if (parentIndex >= 0) {
+ sourceId = messages.slice(parentIndex + 1).find(m => m.sender === 'agent')?.id ?? null;
+ }
+ }
const target = resolveRegenerateTarget(runtimeMessages, sourceId);
if (!target) {
log('reload refused: reply has no regenerable id thread=%s', threadId);