mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 04:26:05 +00:00
fix(app): avoid stale virtual timeline rows
This commit is contained in:
parent
bf6ff7dfd7
commit
aedbe006a0
2 changed files with 30 additions and 8 deletions
|
|
@ -427,8 +427,7 @@ export function MessageTimeline(props: {
|
|||
if (rows.length === 0) return rows
|
||||
return reuseTimelineRows(previous, [...rows, new TimelineRow.BottomSpacer()])
|
||||
})
|
||||
const timelineRowByKey = createMemo(() => new Map(timelineRows().map((row) => [TimelineRow.key(row), row] as const)))
|
||||
const timelineRowKeys = createMemo(() => [...timelineRowByKey().keys()], [] as string[], { equals: sameKeys })
|
||||
const timelineRowKeys = createMemo(() => timelineRows().map(TimelineRow.key), [] as string[], { equals: sameKeys })
|
||||
const virtualCache = createMemo(() => readTimelineCache(sessionKey(), timelineRowKeys()))
|
||||
const messageRowIndex = createMemo(() => {
|
||||
const result = new Map<string, number>()
|
||||
|
|
@ -1227,10 +1226,8 @@ export function MessageTimeline(props: {
|
|||
}
|
||||
}
|
||||
|
||||
function TimelineRowView(props: { rowKey: string }) {
|
||||
const row = () => timelineRowByKey().get(props.rowKey)!
|
||||
|
||||
return renderTimelineRow(row)
|
||||
function TimelineRowView(props: { row: TimelineRow.TimelineRow }) {
|
||||
return renderTimelineRow(() => props.row)
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -1565,7 +1562,7 @@ export function MessageTimeline(props: {
|
|||
<Show when={scrollRoot()}>
|
||||
{(root) => (
|
||||
<Virtualizer
|
||||
data={timelineRowKeys()}
|
||||
data={timelineRows()}
|
||||
cache={virtualCache()}
|
||||
itemSize={virtualCache() ? undefined : timelineFallbackItemSize}
|
||||
scrollRef={root()}
|
||||
|
|
@ -1585,7 +1582,7 @@ export function MessageTimeline(props: {
|
|||
scheduleContentRoot(root())
|
||||
}}
|
||||
>
|
||||
{(key) => <TimelineRowView rowKey={key} />}
|
||||
{(row) => <TimelineRowView row={row} />}
|
||||
</Virtualizer>
|
||||
)}
|
||||
</Show>
|
||||
|
|
|
|||
|
|
@ -46,6 +46,31 @@ index 029201a2c8..e3c4c0ca3a 100644
|
|||
scrollToIndex: scroller.$scrollToIndex,
|
||||
scrollTo: scroller.$scrollTo,
|
||||
scrollBy: scroller.$scrollBy,
|
||||
@@ -1423,5 +1440,7 @@ const Virtualizer = (props) => {
|
||||
}
|
||||
sort([...mounted]).forEach((index) => {
|
||||
+ if (index < 0 || index >= count)
|
||||
+ return;
|
||||
items.push(props.data[index]);
|
||||
indexes.push(index);
|
||||
});
|
||||
@@ -1430,5 +1449,7 @@ const Virtualizer = (props) => {
|
||||
else {
|
||||
for (let [i, j] = range(); i <= j; i++) {
|
||||
+ if (i < 0 || i >= count)
|
||||
+ continue;
|
||||
items.push(props.data[i]);
|
||||
indexes.push(i);
|
||||
}
|
||||
@@ -1579,6 +1600,8 @@ const VList = (props) => {
|
||||
});
|
||||
const items = [];
|
||||
for (let [i, j] = range(); i <= j; i++) {
|
||||
+ if (i < 0 || i >= count)
|
||||
+ continue;
|
||||
items.push(props.data[i]);
|
||||
}
|
||||
return items;
|
||||
diff --git a/lib/solid/Virtualizer.d.ts b/lib/solid/Virtualizer.d.ts
|
||||
index 144dd7fba8..819aab92c5 100644
|
||||
--- a/lib/solid/Virtualizer.d.ts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue