-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(web): keep $ skill picker usable inside question answers #8359
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6142,10 +6142,22 @@ function ChatViewContent(props: ChatViewProps) { | |
| }, | ||
| })); | ||
| const snapshot = composerRef.current?.readSnapshot(); | ||
| // Avoid ping-pong when skill picker inserts plain text while editor is still | ||
| // showing old value: the controlled effect (activePendingProgress.customAnswer | ||
| // -> composer) will rewrite editor to new value and place cursor. Calling | ||
| // focusAt now would move selection in old content (clamped) and fire | ||
| // handleEditorChange with old value, overwriting the just-inserted skill. | ||
| const isPlainInsert = | ||
| snapshot !== undefined && | ||
| typeof snapshot.value === "string" && | ||
| value.length > snapshot.value.length && | ||
| value.startsWith(snapshot.value); | ||
|
Comment on lines
+6150
to
+6154
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggest keying off an explicit signal that the change came from a programmatic replacement (e.g. a flag threaded from Posted via Macroscope β UI Consistency |
||
|
|
||
| if ( | ||
| snapshot?.value !== value || | ||
| snapshot.cursor !== nextCursor || | ||
| snapshot.expandedCursor !== expandedCursor | ||
| !isPlainInsert && | ||
| (snapshot?.value !== value || | ||
| snapshot.cursor !== nextCursor || | ||
| snapshot.expandedCursor !== expandedCursor) | ||
| ) { | ||
| composerRef.current?.focusAt(nextCursor); | ||
| } | ||
|
|
||
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.
π‘ Medium
components/ChatView.tsx:6149The
isPlainInsertguard only recognises appended text (value.startsWith(snapshot.value)). When a skill picker replaces the typed query (e.g.$brβ$Browser),isPlainInsertisfalse, sofocusAt(nextCursor)fires against the editor's stale$brsnapshot. That synchronously re-emitsonChangewith the old value, overwriting the pending-answer state update that was just queued β the selected skill never appears.The comment above the guard already states the real invariant: skip
focusAtwhenever the editor shows a different value than the one being written, because the controlled effect will rewrite the editor. Broaden the check tosnapshot.value !== valueinstead of the append-only heuristic.π€ Copy this AI Prompt to have your agent fix this: