macos task switch focus

This commit is contained in:
Ian Gulliver
2026-10-17 09:04:32 -07:00
parent ebf1561c4a
commit c42a513e2c
14 changed files with 68 additions and 12 deletions
+15 -1
View File
@@ -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();