macos task switch focus
This commit is contained in:
Vendored
+5
@@ -16,6 +16,7 @@ export const state = {
|
||||
leadSessions: [],
|
||||
leadTranscript: [],
|
||||
jump: undefined,
|
||||
composerFocus: undefined,
|
||||
summaryReads: {},
|
||||
};
|
||||
const listeners = new Map();
|
||||
@@ -359,6 +360,10 @@ export function openSummary(task) {
|
||||
focusTask(task.id, "transcript");
|
||||
notify("jump");
|
||||
}
|
||||
export function focusComposer(taskId) {
|
||||
state.composerFocus = taskId;
|
||||
notify("composer");
|
||||
}
|
||||
export function selectTask(taskId) {
|
||||
markVisited(state.selectedTaskId);
|
||||
markVisited(taskId);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+3
-1
@@ -2,7 +2,7 @@ import { get, post } from "./api.js";
|
||||
import { errorText, h, replace, showAlert } from "./dom.js";
|
||||
import { focusLead } from "./panes.js";
|
||||
import { summaryMark } from "./project.js";
|
||||
import { activeTasks, findTask, focusedProject, focusProject, focusTab, focusTask, lastVisits, onEach, openSummary, state, taskState, unreadSummary } from "./state.js";
|
||||
import { activeTasks, findTask, focusComposer, focusedProject, focusProject, focusTab, focusTask, lastVisits, onEach, openSummary, state, taskState, unreadSummary } from "./state.js";
|
||||
import { confirmMerge, models } from "./task.js";
|
||||
import { taskStyle } from "./taskcolor.js";
|
||||
export function bindShortcuts() {
|
||||
@@ -122,9 +122,11 @@ export function openSwitcher() {
|
||||
focusTask(taskId, "inbox");
|
||||
}
|
||||
else if (task && unreadSummary(task)) {
|
||||
focusComposer(taskId);
|
||||
openSummary(task);
|
||||
}
|
||||
else {
|
||||
focusComposer(taskId);
|
||||
focusTask(taskId, "transcript");
|
||||
}
|
||||
};
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
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();
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user