macos task switch focus
This commit is contained in:
Vendored
+15
-1
@@ -280,6 +280,14 @@ export function mountChat(root, src, makeHead) {
|
||||
};
|
||||
let composerModel = "";
|
||||
let focusStart = false;
|
||||
const takeFocus = () => {
|
||||
const taskId = src.taskId();
|
||||
if (!taskId || state.composerFocus !== taskId) {
|
||||
return false;
|
||||
}
|
||||
state.composerFocus = undefined;
|
||||
return true;
|
||||
};
|
||||
const renderComposer = () => {
|
||||
const key = src.key();
|
||||
const old = composer.querySelector("textarea");
|
||||
@@ -297,11 +305,12 @@ export function mountChat(root, src, makeHead) {
|
||||
const caret = old !== null && document.activeElement === old ? [old.selectionStart, old.selectionEnd] : undefined;
|
||||
replace(composer, form);
|
||||
const text = form.querySelector("textarea");
|
||||
const asked = takeFocus();
|
||||
if (caret) {
|
||||
text.focus();
|
||||
text.setSelectionRange(caret[0], caret[1]);
|
||||
}
|
||||
else if (focusStart && !sess) {
|
||||
else if (asked || (focusStart && !sess)) {
|
||||
text.focus();
|
||||
}
|
||||
focusStart = false;
|
||||
@@ -642,6 +651,11 @@ export function mountChat(root, src, makeHead) {
|
||||
syncMergeAfterReview(transcript);
|
||||
}),
|
||||
on("jump", jump),
|
||||
on("composer", () => {
|
||||
if (takeFocus()) {
|
||||
composer.querySelector("textarea")?.focus();
|
||||
}
|
||||
}),
|
||||
];
|
||||
replace(root, h("div", { class: "transcript-view" }, head, transcript, composer));
|
||||
renderAll();
|
||||
|
||||
Reference in New Issue
Block a user