The open source coding agent.
TypeScript
chore: cleanup
Adamdf2713a6c263
diff --git a/packages/desktop/src/components/prompt-input.tsx b/packages/desktop/src/components/prompt-input.tsxindex 87f91104c27..9be09507a74 100644--- a/packages/desktop/src/components/prompt-input.tsx+++ b/packages/desktop/src/components/prompt-input.tsx@@ -77,7 +77,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {const command = useCommand()let editorRef!: HTMLDivElement- // Session-derived stateconst sessionKey = createMemo(() => `${params.dir}${params.id ? "/" + params.id : ""}`)const tabs = createMemo(() => layout.tabs(sessionKey()))const info = createMemo(() => (params.id ? sync.session.get(params.id) : undefined))@@ -183,10 +182,10 @@ export const PromptInput: Component<PromptInputProps> = (props) => {}onMount(() => {- editorRef?.addEventListener("paste", handlePaste)+ editorRef.addEventListener("paste", handlePaste)})onCleanup(() => {- editorRef?.removeEventListener("paste", handlePaste)+ editorRef.removeEventListener("paste", handlePaste)})createEffect(() => {@@ -208,7 +207,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {onSelect: handleFileSelect,})- // Get slash commands from registered commands (only those with explicit slash trigger)const slashCommands = createMemo<SlashCommand[]>(() => {const builtin = command.options.filter((opt) => !opt.disabled && !opt.id.startsWith("suggested.") && opt.slash)@@ -237,12 +235,10 @@ export const PromptInput: Component<PromptInputProps> = (props) => {setStore("popover", null)if (cmd.type === "custom") {- // For custom commands, insert the command text so user can add argumentsconst text = `/${cmd.trigger} `editorRef.innerHTML = ""editorRef.textContent = textprompt.set([{ type: "text", content: text, start: 0, end: text.length }], text.length)- // Set cursor at endrequestAnimationFrame(() => {editorRef.focus()const range = document.createRange()@@ -255,7 +251,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {return}- // For built-in commands, clear input and execute immediatelyeditorRef.innerHTML = ""prompt.set([{ type: "text", content: "", start: 0, end: 0 }], 0)command.trigger(cmd.id, "slash")@@ -287,7 +282,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {}editorRef.innerHTML = ""- currentParts.forEach((part: ContentPart) => {+ currentParts.forEach((part) => {if (part.type === "text") {editorRef.appendChild(document.createTextNode(part.content))} else if (part.type === "file") {@@ -374,7 +369,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {const cursorPosition = getCursorPosition(editorRef)const currentPrompt = prompt.current()- const rawText = currentPrompt.map((p: ContentPart) => p.content).join("")+ const rawText = currentPrompt.map((p) => p.content).join("")const textBeforeCursor = rawText.substring(0, cursorPosition)const atMatch = textBeforeCursor.match(/@(\S*)$/)@@ -498,7 +493,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {}const handleKeyDown = (event: KeyboardEvent) => {- // Handle popover navigationif (store.popover && (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Enter")) {if (store.popover === "file") {onKeyDown(event)@@ -510,7 +504,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {}if (event.key === "ArrowUp" || event.key === "ArrowDown") {- // Skip history navigation when modifier keys are pressed (used for other commands)if (event.altKey || event.ctrlKey || event.metaKey) returnconst { collapsed, onFirstLine, onLastLine } = getCaretLineState()if (!collapsed) return@@ -554,7 +547,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {const handleSubmit = async (event: Event) => {event.preventDefault()const currentPrompt = prompt.current()- const text = currentPrompt.map((part: ContentPart) => part.content).join("")+ const text = currentPrompt.map((part) => part.content).join("")if (text.trim().length === 0) {if (working()) abort()return@@ -574,7 +567,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {const toAbsolutePath = (path: string) => (path.startsWith("/") ? path : sync.absolute(path))const attachments = currentPrompt.filter(- (part: ContentPart) => part.type === "file",+ (part) => part.type === "file",) as import("@/context/prompt").FileAttachmentPart[]const attachmentParts = attachments.map((attachment) => {@@ -603,7 +596,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {editorRef.innerHTML = ""prompt.set([{ type: "text", content: "", start: 0, end: 0 }], 0)- // Check if this is a custom commandif (text.startsWith("/")) {const [cmdName, ...args] = text.split(" ")const commandName = cmdName.slice(1) // Remove leading "/"@@ -639,7 +631,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {return (<div class="relative size-full _max-h-[320px] flex flex-col gap-3">- {/* Popover for file mentions and slash commands */}<Show when={store.popover}><divclass="absolute inset-x-0 -top-3 -translate-y-full origin-bottom-left max-h-80 min-h-10diff --git a/packages/desktop/src/context/command.tsx b/packages/desktop/src/context/command.tsxindex dcc4b60073d..d4ef8e16607 100644--- a/packages/desktop/src/context/command.tsx+++ b/packages/desktop/src/context/command.tsx@@ -6,12 +6,6 @@ import { List } from "@opencode-ai/ui/list"const IS_MAC = typeof navigator === "object" && /(Mac|iPod|iPhone|iPad)/.test(navigator.platform)-/**- * Keybind configuration type.- * Format: "mod+key" where mod can be ctrl, alt, shift, meta (or cmd on mac)- * Multiple keybinds can be separated by comma: "mod+p,ctrl+shift+p"- * Use "mod" for platform-appropriate modifier (cmd on mac, ctrl elsewhere)- */export type KeybindConfig = stringexport interface Keybind {@@ -23,23 +17,14 @@ export interface Keybind {}export interface CommandOption {- /** Unique identifier for the command */id: string- /** Display title in the command palette */title: string- /** Optional description */description?: string- /** Category for grouping in the palette */category?: string- /** Keybind string (e.g., "mod+p", "ctrl+shift+t") */keybind?: KeybindConfig- /** Slash command trigger (e.g., "models" for /models) */slash?: string- /** Whether to show in the "Suggested" section */suggested?: boolean- /** Whether the command is disabled */disabled?: boolean- /** Handler when command is selected */onSelect?: (source?: "palette" | "keybind" | "slash") => void}@@ -197,7 +182,6 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContexconst handleKeyDown = (event: KeyboardEvent) => {if (suspended()) return- // Check for command palette keybind (mod+shift+p)const paletteKeybinds = parseKeybind("mod+shift+p")if (matchKeybind(paletteKeybinds, event)) {event.preventDefault()@@ -205,7 +189,6 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContexreturn}- // Check registered command keybindsfor (const option of options()) {if (option.disabled) continueif (!option.keybind) continuediff --git a/packages/desktop/src/pages/session.tsx b/packages/desktop/src/pages/session.tsxindex d497795873c..9e743e48f43 100644--- a/packages/desktop/src/pages/session.tsx+++ b/packages/desktop/src/pages/session.tsx@@ -49,7 +49,6 @@ export default function Page() {const params = useParams()const navigate = useNavigate()- // Session-specific derived stateconst sessionKey = createMemo(() => `${params.dir}${params.id ? "/" + params.id : ""}`)const tabs = createMemo(() => layout.tabs(sessionKey()))@@ -132,7 +131,6 @@ export default function Page() {}})- // Register commands for this pagecommand.register(() => [{id: "session.new",@@ -230,28 +228,17 @@ export default function Page() {},])- // Handle keyboard events that aren't commandsconst handleKeyDown = (event: KeyboardEvent) => {- // Don't interfere with terminal// @ts-expect-error- if (document.activeElement?.dataset?.component === "terminal") {- return- }-- // Don't interfere with dialogs- if (dialog.stack.length > 0) {- return- }+ if (document.activeElement?.dataset?.component === "terminal") return+ if (dialog.stack.length > 0) returnconst focused = document.activeElement === inputRefif (focused) {- if (event.key === "Escape") {- inputRef?.blur()- }+ if (event.key === "Escape") inputRef?.blur()return}- // Focus input when typing charactersif (event.key.length === 1 && event.key !== "Unidentified" && !(event.ctrlKey || event.metaKey)) {inputRef?.focus()}diff --git a/packages/ui/src/components/session-turn.tsx b/packages/ui/src/components/session-turn.tsxindex 807092d03fd..f905abbd1b8 100644--- a/packages/ui/src/components/session-turn.tsx+++ b/packages/ui/src/components/session-turn.tsx@@ -228,7 +228,6 @@ export function SessionTurn(duration: duration(),})- // Sync with controlled propcreateEffect(() => {if (props.stepsExpanded !== undefined) {setStore("stepsExpanded", props.stepsExpanded)