Skip to content

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

fix(open-human): restore external store provider

Steven Enamakelaec6b646efc8
diff --git a/app/src/providers/useOpenHumanExternalStore.ts b/app/src/providers/useOpenHumanExternalStore.ts
index 683104c501..56ba0d1ce2 100644
--- a/app/src/providers/useOpenHumanExternalStore.ts
+++ b/app/src/providers/useOpenHumanExternalStore.ts
@@ -29,6 +29,7 @@ const EMPTY_SUGGESTIONS: readonly ThreadSuggestion[] = [];
const EMPTY_TIMELINE: never[] = [];
const EMPTY_TRANSCRIPT: never[] = [];
const EMPTY_TURN_MAP = {};
+const EMPTY_SETTLED = {};
/** Items per derived-transcript RPC page; the core caps a page at this size. */
const DERIVED_TRANSCRIPT_PAGE_LIMIT = 500;
/**
@@ -91,6 +92,34 @@ const EMPTY_CORE_TRANSCRIPT: CoreTranscriptProjection = {
transcripts: EMPTY_TURN_MAP,
};
+/**
+ * Keep the previous array for every turn whose re-projection is unchanged.
+ *
+ * The projection refetches whenever the thread's last message or lifecycle
+ * moves — several times per turn — and each fetch minted fresh arrays for
+ * EVERY turn. The settled-message conversion cache is keyed on those array
+ * identities, so each refetch re-converted the whole thread and handed
+ * assistant-ui new part objects for turns nothing had happened to.
+ */
+function reuseUnchangedTurns<T>(
+ previous: Record<string, T[]>,
+ next: Record<string, T[]>
+): Record<string, T[]> {
+ const nextKeys = Object.keys(next);
+ let allReused = nextKeys.length === Object.keys(previous).length;
+ const merged: Record<string, T[]> = {};
+ for (const key of nextKeys) {
+ const before = previous[key];
+ if (before !== undefined && JSON.stringify(before) === JSON.stringify(next[key])) {
+ merged[key] = before;
+ } else {
+ merged[key] = next[key];
+ allReused = false;
+ }
+ }
+ return allReused ? previous : merged;
+}
+
/**
* Read settled process history straight from the core's transcript projection.
* The Rust side owns a bounded, mtime-keyed LRU, so this hook deliberately does
@@ -118,7 +147,17 @@ export function useCoreTranscriptProjection(
const skipRequestIds = liveRequestId ? new Set([liveRequestId]) : undefined;
const project = (items: DerivedDisplayItem[]) => {
const mapped = mapDisplayItems(items, { skipRequestIds });
- setProjection({ threadId, timelines: mapped.timelines, transcripts: mapped.transcripts });
+ setProjection(previous => {
+ if (previous.threadId !== threadId) {
+ return { threadId, timelines: mapped.timelines, transcripts: mapped.transcripts };
+ }
+ const timelines = reuseUnchangedTurns(previous.timelines, mapped.timelines);
+ const transcripts = reuseUnchangedTurns(previous.transcripts, mapped.transcripts);
+ if (timelines === previous.timelines && transcripts === previous.transcripts) {
+ return previous;
+ }
+ return { threadId, timelines, transcripts };
+ });
};
void (async () => {
try {