Route agent/model shortcuts through sidebar events
This commit is contained in:
@@ -9,6 +9,7 @@ import { abortSession, getSessions, isSessionBusy } from "../../stores/sessions"
|
|||||||
import { showCommandPalette, hideCommandPalette } from "../../stores/command-palette"
|
import { showCommandPalette, hideCommandPalette } from "../../stores/command-palette"
|
||||||
import type { Instance } from "../../types/instance"
|
import type { Instance } from "../../types/instance"
|
||||||
import { getLogger } from "../logger"
|
import { getLogger } from "../logger"
|
||||||
|
import { emitSessionSidebarRequest } from "../session-sidebar-events"
|
||||||
|
|
||||||
const log = getLogger("actions")
|
const log = getLogger("actions")
|
||||||
|
|
||||||
@@ -55,38 +56,14 @@ export function useAppLifecycle(options: UseAppLifecycleOptions) {
|
|||||||
|
|
||||||
registerAgentShortcuts(
|
registerAgentShortcuts(
|
||||||
() => {
|
() => {
|
||||||
const modelInput = document.querySelector("[data-model-selector]") as HTMLInputElement
|
const instance = options.getActiveInstance()
|
||||||
if (modelInput) {
|
if (!instance) return
|
||||||
modelInput.focus()
|
emitSessionSidebarRequest({ instanceId: instance.id, action: "focus-model-selector" })
|
||||||
setTimeout(() => {
|
|
||||||
const event = new KeyboardEvent("keydown", {
|
|
||||||
key: "ArrowDown",
|
|
||||||
code: "ArrowDown",
|
|
||||||
keyCode: 40,
|
|
||||||
which: 40,
|
|
||||||
bubbles: true,
|
|
||||||
cancelable: true,
|
|
||||||
})
|
|
||||||
modelInput.dispatchEvent(event)
|
|
||||||
}, 10)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const agentTrigger = document.querySelector("[data-agent-selector]") as HTMLElement
|
const instance = options.getActiveInstance()
|
||||||
if (agentTrigger) {
|
if (!instance) return
|
||||||
agentTrigger.focus()
|
emitSessionSidebarRequest({ instanceId: instance.id, action: "focus-agent-selector" })
|
||||||
setTimeout(() => {
|
|
||||||
const event = new KeyboardEvent("keydown", {
|
|
||||||
key: "Enter",
|
|
||||||
code: "Enter",
|
|
||||||
keyCode: 13,
|
|
||||||
which: 13,
|
|
||||||
bubbles: true,
|
|
||||||
cancelable: true,
|
|
||||||
})
|
|
||||||
agentTrigger.dispatchEvent(event)
|
|
||||||
}, 50)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user