Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai f0601a1da5 fix(agents): clear the selection highlight on off-screen conversation rows
Selecting new text in an agent conversation no longer leaves the previous selection highlighted on messages that were scrolled out of view. WebKit doesn't clear the highlight of rows that skip rendering off screen (content-visibility: auto), so every row now renders while the conversation holds a selection, until the frame after it is cleared.
2026-11-22 19:39:21 +08:00
2 змінених файлів з 37 додано та 0 видалено

No files matched your search

+4
Переглянути файл
@@ -228,6 +228,10 @@
.conversationRow[data-measured] {
content-visibility: auto;
}
/* WebKit leaves a stale selection highlight on rows that skipped rendering (`useOffscreenRows`). */
.stream[data-selection] > .conversationRow[data-measured] {
content-visibility: visible;
}
/* Keep turns distinct and the work within a turn close to its author. Not `* + *`: a
universal adjacent-sibling rule makes Chromium restyle whole sibling subtrees on every
DOM insertion anywhere in the window, which costs every editor scroll frame. */
+33
Переглянути файл
@@ -144,6 +144,39 @@ function useOffscreenRows(
resize.disconnect();
};
}, [ref, visible, enabled, fitWindowWidth, fontZoom]);
// WebKit never clears the selection highlight of a row that skips rendering: once the
// selection moves, rows it covered off screen still show it when scrolled back. While the
// stream holds a selection every row renders (`data-selection`), and keeps rendering until
// the frame after it goes, when WebKit applies the change.
useEffect(() => {
const el = ref.current;
if (!el || !enabled || !visible) return;
let frame = 0;
const selected = () => {
const sel = window.getSelection();
return !!sel && !sel.isCollapsed && sel.rangeCount > 0 && sel.getRangeAt(0).intersectsNode(el);
};
const update = () => {
cancelAnimationFrame(frame);
if (selected()) {
el.setAttribute("data-selection", "");
return;
}
if (!el.hasAttribute("data-selection")) return;
frame = requestAnimationFrame(() => {
frame = requestAnimationFrame(() => {
if (!selected()) el.removeAttribute("data-selection");
});
});
};
update();
document.addEventListener("selectionchange", update);
return () => {
cancelAnimationFrame(frame);
document.removeEventListener("selectionchange", update);
el.removeAttribute("data-selection");
};
}, [ref, visible, enabled]);
}
interface StreamProps {