Repository navigation
fix(mobile): native chat streams replies token by token #9184
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
3 commits
Select commit
Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions
1
...eens/(authenticated)/workspace/[id]/components/ChatSessionView/utils/withRowText/index.ts
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 @@ | ||
| export { type TextRow, withRowText } from "./withRowText"; |
22 changes: 22 additions & 0 deletions
22
...nticated)/workspace/[id]/components/ChatSessionView/utils/withRowText/withRowText.test.ts
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,22 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import type { ChatRow } from "../../../../utils/chatRows"; | ||
| import { withRowText } from "./withRowText"; | ||
|
|
||
| const working: ChatRow = { kind: "working", key: "working:t1" }; | ||
| const reply: ChatRow = { kind: "working", key: "reply" }; | ||
|
|
||
| describe("withRowText", () => { | ||
| test("gives only the row whose text changed a new entry", () => { | ||
| const cache = new WeakMap(); | ||
| const texts = new Map([[reply, "Hel"]]); | ||
| const textOf = (row: ChatRow) => texts.get(row) ?? ""; | ||
|
|
||
| const first = withRowText([working, reply], textOf, cache); | ||
| texts.set(reply, "Hello"); | ||
| const second = withRowText([working, reply], textOf, cache); | ||
|
|
||
| expect(second[0]).toBe(first[0]); | ||
| expect(second[1]).not.toBe(first[1]); | ||
| expect(second[1]).toEqual({ row: reply, text: "Hello" }); | ||
| }); | ||
| }); |
26 changes: 26 additions & 0 deletions
26
...authenticated)/workspace/[id]/components/ChatSessionView/utils/withRowText/withRowText.ts
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,26 @@ | ||
| import type { ChatRow } from "../../../../utils/chatRows"; | ||
|
|
||
| export interface TextRow { | ||
| row: ChatRow; | ||
| text: string; | ||
| } | ||
|
|
||
| /** | ||
| * Pairs each row with its text. A row keeps its entry until its text changes, | ||
| * so a list that re-renders a cell only when its data changes updates just | ||
| * the streaming row. | ||
| */ | ||
| export function withRowText( | ||
| rows: readonly ChatRow[], | ||
| textOf: (row: ChatRow) => string, | ||
| previous: WeakMap<ChatRow, TextRow>, | ||
| ): TextRow[] { | ||
| return rows.map((row) => { | ||
| const text = textOf(row); | ||
| const kept = previous.get(row); | ||
| if (kept?.text === text) return kept; | ||
| const entry = { row, text }; | ||
| previous.set(row, entry); | ||
| return entry; | ||
| }); | ||
| } |
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.
Script executed:
Repository: ParadevAI/Paradev
Length of output: 19564
Web query:
React Native 0.88.1 ScrollView onScrollEndDrag onMomentumScrollBegin onMomentumScrollEnd implementation timingResult:
Web query:
@legendapp/list 3.0.3 maintainScrollAtEnd dataChange maintainScrollAtEndThreshold documentation sourceResult:
Keep end anchoring disabled during momentum.
onScrollEndDragcan fire before momentum scrolling ends. The current handler setsisDraggingtofalse, which re-enablesmaintainScrollAtEnd. A streamed data change can then re-anchor a flick released within the configured 15% threshold and interrupt the scroll. Keep anchoring disabled until momentum ends, while still re-enabling it for drags without momentum.