Skip to content

Commit efd8141

Browse files
fix(web): keep $ skill picker usable inside question answers
1 parent d3c24a1 commit efd8141

3 files changed

Lines changed: 297 additions & 97 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6142,10 +6142,22 @@ function ChatViewContent(props: ChatViewProps) {
61426142
},
61436143
}));
61446144
const snapshot = composerRef.current?.readSnapshot();
6145+
// Avoid ping-pong when skill picker inserts plain text while editor is still
6146+
// showing old value: the controlled effect (activePendingProgress.customAnswer
6147+
// -> composer) will rewrite editor to new value and place cursor. Calling
6148+
// focusAt now would move selection in old content (clamped) and fire
6149+
// handleEditorChange with old value, overwriting the just-inserted skill.
6150+
const isPlainInsert =
6151+
snapshot !== undefined &&
6152+
typeof snapshot.value === "string" &&
6153+
value.length > snapshot.value.length &&
6154+
value.startsWith(snapshot.value);
6155+
61456156
if (
6146-
snapshot?.value !== value ||
6147-
snapshot.cursor !== nextCursor ||
6148-
snapshot.expandedCursor !== expandedCursor
6157+
!isPlainInsert &&
6158+
(snapshot?.value !== value ||
6159+
snapshot.cursor !== nextCursor ||
6160+
snapshot.expandedCursor !== expandedCursor)
61496161
) {
61506162
composerRef.current?.focusAt(nextCursor);
61516163
}

0 commit comments

Comments
 (0)