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
+8
-1
@@ -21,7 +21,8 @@ export type Topic =
|
||||
| "ready"
|
||||
| "lead.ready"
|
||||
| "summaries"
|
||||
| "jump";
|
||||
| "jump"
|
||||
| "composer";
|
||||
|
||||
export const tabs: TaskTab[] = ["transcript", "changes", "files", "terminal", "inbox", "reviews", "workflow", "project"];
|
||||
|
||||
@@ -40,6 +41,7 @@ export const state = {
|
||||
leadSessions: [] as AgentSession[],
|
||||
leadTranscript: [] as ByreEvent[],
|
||||
jump: undefined as { taskId: string; seq: number } | undefined,
|
||||
composerFocus: undefined as string | undefined,
|
||||
summaryReads: {} as Record<string, number>,
|
||||
};
|
||||
|
||||
@@ -433,6 +435,11 @@ export function openSummary(task: Task): void {
|
||||
notify("jump");
|
||||
}
|
||||
|
||||
export function focusComposer(taskId: string): void {
|
||||
state.composerFocus = taskId;
|
||||
notify("composer");
|
||||
}
|
||||
|
||||
export function selectTask(taskId: string | undefined): void {
|
||||
markVisited(state.selectedTaskId);
|
||||
markVisited(taskId);
|
||||
|
||||
+3
-1
@@ -2,7 +2,7 @@ import { get, post, type Project, type WorkflowSummary } 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";
|
||||
|
||||
@@ -131,8 +131,10 @@ export function openSwitcher(): void {
|
||||
if (state.inbox.some((item) => item.task_id === taskId)) {
|
||||
focusTask(taskId, "inbox");
|
||||
} else if (task && unreadSummary(task)) {
|
||||
focusComposer(taskId);
|
||||
openSummary(task);
|
||||
} else {
|
||||
focusComposer(taskId);
|
||||
focusTask(taskId, "transcript");
|
||||
}
|
||||
};
|
||||
|
||||
+15
-1
@@ -360,6 +360,14 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
|
||||
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");
|
||||
@@ -377,10 +385,11 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
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;
|
||||
@@ -740,6 +749,11 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
syncMergeAfterReview(transcript);
|
||||
}),
|
||||
on("jump", jump),
|
||||
on("composer", () => {
|
||||
if (takeFocus()) {
|
||||
composer.querySelector("textarea")?.focus();
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
replace(root, h("div", { class: "transcript-view" }, head, transcript, composer));
|
||||
|
||||
Reference in New Issue
Block a user