Repository navigation
fix(desktop): stop per-event nested commits that crashed the Live Session View #444
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
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
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,54 @@ | ||
| import { render } from "@testing-library/react"; | ||
| import { describe, expect, it, vi } from "vitest"; | ||
| import { Heading, Text } from "@astryxdesign/core/Text"; | ||
|
|
||
| /** | ||
| * Guard for the @astryxdesign/core patch: Text/Heading merge their forwarded | ||
| * ref, useTruncation's callback ref, and an internal object ref into one | ||
| * callback built fresh on every render. A new callback identity makes React | ||
| * detach+reattach the ref on every commit — and useTruncation's attach calls | ||
| * setState inside the commit, which is what let nested updates accumulate | ||
| * into React #185 under dense Session events. | ||
| */ | ||
| describe("Astryx ref stability", () => { | ||
| it("Text keeps the forwarded callback ref attached across re-renders", () => { | ||
| const spy = vi.fn(); | ||
| function Parent({ label }: { label: string }) { | ||
| return <Text ref={spy}>{label}</Text>; | ||
| } | ||
|
|
||
| const { rerender } = render(<Parent label="a" />); | ||
| expect(spy).toHaveBeenCalledTimes(1); | ||
| expect(spy).toHaveBeenLastCalledWith(expect.any(HTMLElement)); | ||
|
|
||
| rerender(<Parent label="b" />); | ||
| rerender(<Parent label="c" />); | ||
| rerender(<Parent label="d" />); | ||
|
|
||
| // No detach (spy(null)) and no re-attach: identity must be stable. | ||
| expect(spy).toHaveBeenCalledTimes(1); | ||
| expect(spy).not.toHaveBeenCalledWith(null); | ||
| }); | ||
|
|
||
| it("Heading keeps the forwarded callback ref attached across re-renders", () => { | ||
| const spy = vi.fn(); | ||
| function Parent({ label }: { label: string }) { | ||
| return ( | ||
| <Heading level={2} ref={spy}> | ||
| {label} | ||
| </Heading> | ||
| ); | ||
| } | ||
|
|
||
| const { rerender } = render(<Parent label="a" />); | ||
| expect(spy).toHaveBeenCalledTimes(1); | ||
| expect(spy).toHaveBeenLastCalledWith(expect.any(HTMLElement)); | ||
|
|
||
| rerender(<Parent label="b" />); | ||
| rerender(<Parent label="c" />); | ||
| rerender(<Parent label="d" />); | ||
|
|
||
| expect(spy).toHaveBeenCalledTimes(1); | ||
| expect(spy).not.toHaveBeenCalledWith(null); | ||
| }); | ||
| }); |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Late session arrival stays unread
If
view()starts before an unread Session is inserted, it cannot mark that Session read. insert bypassesseen, so its unread badge remains while the Session is on screen.Learn more
A view can start while its Session is absent from the store.
view()records the id but only clears unread on the projection available at that moment. A later insert commits its projection unchanged. useViewedSession depends on the id and store, not on the projection, so no second view call clears the badge. The previous read effect depended onliveProjection?.unreadResult, so it handled a projection that appeared after the view mounted.Example: A view starts for Session
sbefore its projection exists. An unread projection forsis then inserted. Its unread indicator remains visible even though the Session is open.Recommended fix: Apply
seen()to projections entering throughinsert()while their id is viewed. Also check replacement paths such asrehydrate()for projections that can enter the store unread after a view starts.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid, thanks. Fixed in 8358f65:
commit()is now the single place that applies the read marker, soinsert()andrehydrate()are covered too. Added red-first tests for a Session inserted after its view started and one rehydrated unread.