Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/app/component-tests/composer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ story(
await input.fill("")
await input.press("ArrowUp")
await expect(input).toHaveText("Explain the latest changes")
await input.press("ControlOrMeta+u")
await component.getByRole("button", { name: "Add images and files", exact: true }).click()
await page.getByRole("menuitem", { name: /^Images and files/ }).click()
await input.press("ArrowDown")
await expect(input).toBeEmpty()
},
Expand Down
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@opencode/session-ui": "workspace:*",
"@opencode/ui": "workspace:*",
"@opencode/util": "workspace:*",
"@opentui/keymap": "catalog:",
"@pierre/highlights": "catalog:",
"@pierre/trees": "1.0.0-beta.6",
"@sentry/solid": "catalog:",
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { type Component, createRenderEffect, ErrorBoundary, type JSX, type Paren
import { Dynamic } from "solid-js/web"
import { CommandProvider } from "@/shell/commands/command"
import { DesktopCommands } from "@/shell/commands/desktop"
import { KeySequenceHint } from "@/shell/commands/key-sequence"
import { ProjectIconsProvider } from "@/shell/layout/project-icons"
import { GlobalProvider } from "@/runtime/server/runtime"
import { LanguageProvider, UiI18nBridge, type Locale } from "@/runtime/i18n/language"
Expand Down Expand Up @@ -105,6 +106,7 @@ export function AppInterface(props: {
{rootProps.children}
<VoiceOverlay />
</VoiceProvider>
<KeySequenceHint />
</CommandProvider>
</ProjectIconsProvider>
</GlobalProvider>
Expand Down
25 changes: 0 additions & 25 deletions packages/app/src/composer/editor/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,19 +474,6 @@ export function createComposerEditor(input: {

flushFocus()

if (
mode() === "normal" &&
(event.metaKey || event.ctrlKey) &&
!event.altKey &&
!event.shiftKey &&
event.key.toLowerCase() === "u"
) {
event.preventDefault()
attach()

return true
}

const ctrl = event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey
const open = isComposerPopoverOpen(readState())

Expand Down Expand Up @@ -537,18 +524,6 @@ export function createComposerEditor(input: {
return true
}

const stop =
(input.view.submit.working?.() || input.view.submit.held?.()) &&
((event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "g") ||
event.key === "Escape")

if (stop) {
event.preventDefault()
input.view.submit.onStop()

return true
}

if (
!event.altKey &&
!event.ctrlKey &&
Expand Down
20 changes: 19 additions & 1 deletion packages/app/src/composer/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImagePreview } from "@opencode/ui/image-preview"
import { useDialog } from "@opencode/ui/context/dialog"
import type { ReferenceInfo } from "@opencode/client/promise"
import type { Links, MountedSession } from "@opencode/plugin/gui"
import { createComponent, createEffect, createMemo, on, onCleanup } from "solid-js"
import { createComponent, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js"
import { Predicate } from "effect"
import type { ComposerSuggestion } from "./types"
import { createComposerEditor, type ComposerEditorModel } from "./editor/interaction"
Expand Down Expand Up @@ -33,6 +33,7 @@ import type { PromptHistoryComment } from "./history/entry"
import { createComposerHistory } from "./history/store"
import { createComposerSubmit } from "./submit"
import { composerSubmitView } from "./machine"
import { isComposerPopoverOpen } from "./suggestions/machine"
import { useAttachmentDestination } from "./attachments/destination"
import { parseClientSlashCommand } from "./client-slash-command"

Expand Down Expand Up @@ -73,6 +74,8 @@ export function createComposerModel(adapter: ComposerAdapter, options?: { queue?
),
)
let editor: HTMLDivElement | undefined
// The element `prompt.stop` binds its keys to.
const [editorElement, setEditorElement] = createSignal<HTMLDivElement>()
// A path attachment's image is read through the server, which can see both local and uploaded paths.
const pathImages = new Map<string, Promise<string | undefined>>()
const pathImageReads = new AbortController()
Expand Down Expand Up @@ -457,6 +460,7 @@ export function createComposerModel(adapter: ComposerAdapter, options?: { queue?
onEditor(element) {
// SAFETY: the editor's only `setEditor` call passes its editable root, a `<div>` (`editor/editor.tsx`).
editor = element as HTMLDivElement
setEditorElement(editor)

if (adapter.kind === "active-session") adapter.setEditor(editor)
},
Expand Down Expand Up @@ -607,6 +611,20 @@ export function createComposerModel(adapter: ComposerAdapter, options?: { queue?
disabled: mode() === "normal",
onSelect: () => void controller.dispatch({ type: "mode.normal" }),
},
{
id: "prompt.stop",
title: language.t("command.prompt.stop"),
category: language.t("command.category.session"),
keybind: "escape,ctrl+g",
editable: true,
target: editorElement,
disabled: !adapter.working() && !submitView().held,
// An open list, a queued prompt being edited and shell mode each take the key first in the editor.
skip: (event) =>
isComposerPopoverOpen(controller.state) ||
(event.key === "Escape" && (!!options?.queue?.editing() || mode() === "shell")),
onSelect: () => void submission.stop(),
},
])

// SAFETY: the `model` getter defined on the controller above completes `ComposerModel`.
Expand Down
6 changes: 6 additions & 0 deletions packages/app/src/runtime/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export const dict = {
"command.prompt.mode.shell": "Shell",
"command.prompt.mode.normal": "Prompt",
"command.prompt.mode.toggle": "Toggle shell mode",
"command.prompt.stop": "Stop session",
"command.keymap.leader": "Leader key",
"command.permissions.autoaccept.enable": "Auto-accept permissions",
"command.permissions.autoaccept.disable": "Stop auto-accepting permissions",
"command.permissions.autoaccept.project": "Auto-accept permissions for this project",
Expand Down Expand Up @@ -788,6 +790,7 @@ export const dict = {
"common.edit": "Edit",
"common.loadMore": "Load more",
"common.key.esc": "ESC",
"common.key.leader": "Leader",
"common.key.ctrl": "Ctrl",
"common.key.alt": "Alt",
"common.key.shift": "Shift",
Expand Down Expand Up @@ -1233,6 +1236,9 @@ export const dict = {
"settings.shortcuts.unassigned": "Unassigned",
"settings.shortcuts.pressKeys": "Press keys",
"settings.shortcuts.unbind": "Unbind",
"settings.shortcuts.insertLeader": "Add leader",
"settings.shortcuts.addKey": "Add a key",
"settings.shortcuts.leader.description": "Starts shortcuts that begin with Leader. Not set by default.",
"settings.shortcuts.search.placeholder": "Search shortcuts",

"settings.shortcuts.group.general": "General",
Expand Down
Loading
Loading