forked from pingdotgg/t3code
-
-
Notifications
You must be signed in to change notification settings - Fork 8
perf(web): cut re-render storms and continuous repaints in bot chats #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1074edd
perf(web): cut re-render storms and continuous repaints in bot chats
leoisadev1 f0607de
fix(web): drop unused botEnvironment import
leoisadev1 b2b43e8
fix(web): keep reply playback baseline, fresh avatar eye cache, and c…
leoisadev1 862c35e
fix(web): order cross-tab draft writes by edit time
leoisadev1 e56287c
fix(web): order cross-tab draft writes by stored version, not clock
leoisadev1 0f96b9b
fix(web): save each bot draft under its own key as it is typed
leoisadev1 ec8cd60
fix(web): restore synchronous draft store and keep long chats' speech…
leoisadev1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@t3tools/web": patch | ||
| --- | ||
|
|
||
| Smoother web chats: long conversations stop re-rendering on every update, and working-bot animations use far less GPU. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { EnvironmentId, MessageId, ThreadId, type OrchestrationMessage } from "@t3tools/contracts"; | ||
| import { describe, expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| import { assistantRowPropsEqual } from "./BotChatMessageRows"; | ||
|
|
||
| type RowProps = Parameters<typeof assistantRowPropsEqual>[0]; | ||
|
|
||
| const message: OrchestrationMessage = { | ||
| id: MessageId.make("reply-1"), | ||
| role: "assistant", | ||
| text: "Done.", | ||
| turnId: null, | ||
| streaming: false, | ||
| createdAt: "2026-09-26T00:00:00.000Z", | ||
| updatedAt: "2026-09-26T00:00:00.000Z", | ||
| }; | ||
| const engine = { provider: "codex", model: "gpt" } as const; | ||
| const result = { kind: "plugin-search-results" } as unknown as NonNullable< | ||
| RowProps["pluginResults"] | ||
| >[number]["result"]; | ||
|
|
||
| function props(overrides: Partial<RowProps> = {}): RowProps { | ||
| return { | ||
| message, | ||
| author: { name: "Akeru", avatar: { kind: "dither", seed: "a" } }, | ||
| testId: "row", | ||
| cwd: "/work", | ||
| threadRef: { environmentId: EnvironmentId.make("env"), threadId: ThreadId.make("thread") }, | ||
| stepMeter: { engine, tokens: 10, costUsd: null, hardStopReached: false }, | ||
| pluginResults: [{ id: "entry-1", result }], | ||
| currentPersonId: "person", | ||
| playback: null, | ||
| playbackKey: "env/thread", | ||
| channelApproval: null, | ||
| onReply: vi.fn(), | ||
| onReactionChange: vi.fn(), | ||
| ...overrides, | ||
| } as RowProps; | ||
| } | ||
|
|
||
| describe("assistant row memoization", () => { | ||
| it("skips re-rendering when per-turn data is rebuilt with the same content", () => { | ||
| const previous = props(); | ||
| const next = { | ||
| ...previous, | ||
| stepMeter: { ...previous.stepMeter!, engine: { ...engine } }, | ||
| pluginResults: previous.pluginResults!.map((entry) => ({ ...entry })), | ||
| }; | ||
| expect(assistantRowPropsEqual(previous, next)).toBe(true); | ||
| }); | ||
|
|
||
| it("re-renders when the message, meter, playback context, or handlers change", () => { | ||
| const previous = props(); | ||
| expect(assistantRowPropsEqual(previous, { ...previous, message: { ...message } })).toBe(false); | ||
| expect( | ||
| assistantRowPropsEqual(previous, { | ||
| ...previous, | ||
| stepMeter: { ...previous.stepMeter!, tokens: 11 }, | ||
| }), | ||
| ).toBe(false); | ||
| expect(assistantRowPropsEqual(previous, { ...previous, playbackKey: null })).toBe(false); | ||
| expect(assistantRowPropsEqual(previous, { ...previous, onReply: vi.fn() })).toBe(false); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.