Repository navigation
perf(web): changing file counts no longer re-render the chat view #28571
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
Open
Yuruzuu
wants to merge
6
commits into
pingdotgg:main
Choose a base branch
from
Yuruzuu:perf/chat-view-git-status-fields
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−6
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b0e9cab
perf(web): changing file counts no longer re-render the chat view
Yuruzuu b73677c
test(web): cover the other chat git status fields
Yuruzuu 99e17a2
chore: merge main into chat git status optimization
maria-rcks dec373a
test(web): file count scenario waits for the last status update
Yuruzuu 9bc292d
chore: merge main into chat git status optimization
maria-rcks 15e4620
Merge remote-tracking branch 'upstream/main' into pr-28571-sync
Yuruzuu 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
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,68 @@ | ||
| import type { VcsStatusResult } from "@t3tools/contracts"; | ||
| import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity"; | ||
| import { describe, expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| import { chatGitStatusAtom } from "./vcs"; | ||
|
|
||
| vi.mock("../connection/runtime", () => ({ connectionAtomRuntime: {} })); | ||
| vi.mock("@t3tools/client-runtime/state/vcs", () => ({ | ||
| createVcsActionManager: () => ({}), | ||
| createVcsEnvironmentAtoms: () => ({}), | ||
| createVcsStatusRevalidationAtomFamily: () => () => null, | ||
| })); | ||
|
|
||
| const status = (changes: Partial<VcsStatusResult> = {}) => | ||
| AsyncResult.success({ | ||
| isRepo: true, | ||
| hasPrimaryRemote: true, | ||
| isDefaultRef: true, | ||
| refName: "main", | ||
| hasWorkingTreeChanges: true, | ||
| workingTree: { files: [], insertions: 1, deletions: 0 }, | ||
| hasUpstream: true, | ||
| aheadCount: 0, | ||
| behindCount: 0, | ||
| pr: null, | ||
| ...changes, | ||
| } satisfies VcsStatusResult); | ||
|
|
||
| describe("chatGitStatusAtom", () => { | ||
| it("notifies only when a field the chat view reads changes", () => { | ||
| const registry = AtomRegistry.make(); | ||
| const source = Atom.make<AsyncResult.AsyncResult<VcsStatusResult, never>>(status()); | ||
| const selected = chatGitStatusAtom(source as never); | ||
| const notified: unknown[] = []; | ||
| const unsubscribe = registry.subscribe(selected, (value) => notified.push(value)); | ||
| registry.get(selected); | ||
| notified.length = 0; | ||
|
|
||
| registry.set( | ||
| source, | ||
| status({ workingTree: { files: [], insertions: 2, deletions: 0 }, aheadCount: 1 }), | ||
| ); | ||
| expect(notified).toEqual([]); | ||
|
|
||
| registry.set(source, status({ refName: "feature" })); | ||
| expect(notified).toHaveLength(1); | ||
|
|
||
| registry.set(source, status({ refName: "feature", hasWorkingTreeChanges: false })); | ||
| expect(notified).toHaveLength(2); | ||
|
|
||
| const pr = () => ({ | ||
| number: 42, | ||
| title: "Feature PR", | ||
| url: "https://github.com/pingdotgg/t3code/pull/42", | ||
| baseRef: "main", | ||
| headRef: "feature", | ||
| state: "open" as const, | ||
| }); | ||
| const linked = { refName: "feature", hasWorkingTreeChanges: false }; | ||
| registry.set(source, status({ ...linked, pr: pr() })); | ||
| expect(notified).toHaveLength(3); | ||
|
|
||
| // A new object with the same data, as each remote status refresh sends. | ||
| registry.set(source, status({ ...linked, pr: pr() })); | ||
| expect(notified).toHaveLength(3); | ||
| unsubscribe(); | ||
| }); | ||
| }); |
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
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.