perf(app): reduce streaming rerenders and scroll churn (#67)
Amp-Thread-ID: https://ampcode.com/threads/T-019c793a-d087-762a-882a-8cc11e6101db Co-authored-by: Ubuntu <ubuntu@dev-yk.tail388b2e.ts.net>
This commit is contained in:
@@ -183,6 +183,9 @@ function SessionProviderInternal({
|
||||
const setAgentStreamHead = useSessionStore(
|
||||
(state) => state.setAgentStreamHead
|
||||
);
|
||||
const setAgentStreamState = useSessionStore(
|
||||
(state) => state.setAgentStreamState
|
||||
);
|
||||
const clearAgentStreamHead = useSessionStore(
|
||||
(state) => state.clearAgentStreamHead
|
||||
);
|
||||
@@ -784,23 +787,10 @@ function SessionProviderInternal({
|
||||
timestamp: parsedTimestamp,
|
||||
});
|
||||
|
||||
if (changedTail) {
|
||||
setAgentStreamTail(serverId, (prev) => {
|
||||
const next = new Map(prev);
|
||||
next.set(agentId, tail);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
if (changedHead) {
|
||||
setAgentStreamHead(serverId, (prev) => {
|
||||
const next = new Map(prev);
|
||||
if (head.length > 0) {
|
||||
next.set(agentId, head);
|
||||
} else {
|
||||
next.delete(agentId);
|
||||
}
|
||||
return next;
|
||||
if (changedTail || changedHead) {
|
||||
setAgentStreamState(serverId, agentId, {
|
||||
...(changedTail ? { tail } : {}),
|
||||
...(changedHead ? { head } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1261,6 +1251,7 @@ function SessionProviderInternal({
|
||||
setCurrentAssistantMessage,
|
||||
setAgentStreamTail,
|
||||
setAgentStreamHead,
|
||||
setAgentStreamState,
|
||||
clearAgentStreamHead,
|
||||
setAgentTimelineCursor,
|
||||
setInitializingAgents,
|
||||
|
||||
Reference in New Issue
Block a user