mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-10 03:37:44 +02:00
[eric] agents: rehydrate browser-agent children the trimmed session-list poll leaves message-less (feed no longer blanks)
This commit is contained in:
@@ -197,14 +197,18 @@ const BrowserAgentInlineFeed: React.FC<Props> = ({ parentSessionId, browserId })
|
||||
shallowEqual,
|
||||
);
|
||||
|
||||
// A child that arrived only through the trimmed session-list poll carries its message_count but no messages; fetch the full children so its history renders instead of showing a blank feed.
|
||||
const needsChildFetch =
|
||||
browserSessions.length === 0 ||
|
||||
browserSessions.some((s) => (s.message_count ?? 0) > 0 && s.messages.length === 0);
|
||||
useEffect(() => {
|
||||
if (browserSessions.length === 0 && fetchedForSession.current !== parentSessionId) {
|
||||
if (needsChildFetch && fetchedForSession.current !== parentSessionId) {
|
||||
fetchedForSession.current = parentSessionId;
|
||||
dispatch(fetchBrowserAgentChildren(parentSessionId))
|
||||
.unwrap()
|
||||
.catch(() => { fetchedForSession.current = null; });
|
||||
}
|
||||
}, [browserSessions.length, parentSessionId, dispatch]);
|
||||
}, [needsChildFetch, parentSessionId, dispatch]);
|
||||
|
||||
const sessionsWithHistoricalEntries = useMemo(() => {
|
||||
return browserSessions.map((session) => {
|
||||
|
||||
@@ -1416,13 +1416,17 @@ const agentsSlice = createSlice({
|
||||
})
|
||||
.addCase(fetchBrowserAgentChildren.fulfilled, (state, action) => {
|
||||
for (const session of action.payload) {
|
||||
if (!state.sessions[session.id]) {
|
||||
const existing = state.sessions[session.id];
|
||||
if (!existing) {
|
||||
state.sessions[session.id] = {
|
||||
...session,
|
||||
name: normalizeSessionName(session.name),
|
||||
tool_group_meta: session.tool_group_meta ?? {},
|
||||
pending_approvals: session.pending_approvals ?? [],
|
||||
};
|
||||
} else if (existing.messages.length === 0 && session.messages.length > 0) {
|
||||
// Hydrate a child the trimmed session-list poll left message-less; don't touch one mid-stream (already has messages).
|
||||
existing.messages = session.messages;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user