From 82a3270cf2abb47bd55dcaabd39b256b26665161 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Fri, 17 Jul 2026 10:03:42 +0000 Subject: [PATCH] chore: generate --- .../components/prompt-input/history-store.ts | 6 +- .../v2/components/prompt-input/attachments.ts | 27 +++--- .../components/prompt-input/machine.test.ts | 6 +- .../src/v2/components/prompt-input/machine.ts | 86 ++++++++----------- .../src/v2/components/prompt-input/store.ts | 4 +- 5 files changed, 60 insertions(+), 69 deletions(-) diff --git a/packages/app/src/components/prompt-input/history-store.ts b/packages/app/src/components/prompt-input/history-store.ts index 2ee91fa863..b64636f3c0 100644 --- a/packages/app/src/components/prompt-input/history-store.ts +++ b/packages/app/src/components/prompt-input/history-store.ts @@ -1,11 +1,7 @@ import { createStore, type SetStoreFunction, type Store } from "solid-js/store" import type { Prompt } from "@/context/prompt" import { Persist, persisted } from "@/utils/persist" -import { - prependHistoryEntry, - type PromptHistoryComment, - type PromptHistoryStoredEntry, -} from "./history" +import { prependHistoryEntry, type PromptHistoryComment, type PromptHistoryStoredEntry } from "./history" export type PromptInputHistory = { entries: (mode: "normal" | "shell") => PromptHistoryStoredEntry[] diff --git a/packages/session-ui/src/v2/components/prompt-input/attachments.ts b/packages/session-ui/src/v2/components/prompt-input/attachments.ts index 24c07ca445..8c7b12e9ae 100644 --- a/packages/session-ui/src/v2/components/prompt-input/attachments.ts +++ b/packages/session-ui/src/v2/components/prompt-input/attachments.ts @@ -79,13 +79,15 @@ export type PromptInputV2AttachmentConfig = { getPathForFile?: (file: File) => string } -export function createPromptInputV2Attachments(input: PromptInputV2AttachmentConfig & { - capture: () => PromptTarget - editor: () => HTMLElement | undefined - focusEditor: () => void - addPart: (part: PromptInputV2Prompt[number]) => boolean - setDraggingType: (type: "image" | "@mention" | null) => void -}) { +export function createPromptInputV2Attachments( + input: PromptInputV2AttachmentConfig & { + capture: () => PromptTarget + editor: () => HTMLElement | undefined + focusEditor: () => void + addPart: (part: PromptInputV2Prompt[number]) => boolean + setDraggingType: (type: "image" | "@mention" | null) => void + }, +) { const capture = () => { const prompt = input.capture() const editor = input.editor() @@ -113,13 +115,10 @@ export function createPromptInputV2Attachments(input: PromptInputV2AttachmentCon return true } const addAttachments = async (files: File[], toast = true, target = capture()) => { - const found = await files.reduce( - async (result, file) => { - const previous = await result - return (await add(file, false, target)) || previous - }, - Promise.resolve(false), - ) + const found = await files.reduce(async (result, file) => { + const previous = await result + return (await add(file, false, target)) || previous + }, Promise.resolve(false)) if (!found && files.length > 0 && toast) input.warn() return found } diff --git a/packages/session-ui/src/v2/components/prompt-input/machine.test.ts b/packages/session-ui/src/v2/components/prompt-input/machine.test.ts index 672e38a622..4b75e08bcf 100644 --- a/packages/session-ui/src/v2/components/prompt-input/machine.test.ts +++ b/packages/session-ui/src/v2/components/prompt-input/machine.test.ts @@ -93,7 +93,11 @@ describe("prompt input v2 interaction machine", () => { { type: "commands.open" }, persisted("existing text"), ) - const selected = transitionPromptInputV2(open.state, { type: "popover.select", item: command }, persisted("existing text")) + const selected = transitionPromptInputV2( + open.state, + { type: "popover.select", item: command }, + persisted("existing text"), + ) expect(selected.commands).toContainEqual({ type: "draft.setText", value: "/review existing text" }) expect(selected.state.popover).toEqual({ type: "closed" }) diff --git a/packages/session-ui/src/v2/components/prompt-input/machine.ts b/packages/session-ui/src/v2/components/prompt-input/machine.ts index 49917536bf..7102b79318 100644 --- a/packages/session-ui/src/v2/components/prompt-input/machine.ts +++ b/packages/session-ui/src/v2/components/prompt-input/machine.ts @@ -91,25 +91,19 @@ function inputChanged(state: PromptInputV2InteractionState, value: string, persi const context = value.match(/(?:^|\s)@([^\s@]*)$/) if (context) { const query = context[1] ?? "" - return changed( - { ...state, popover: { type: "context", query }, focus: "editor" }, - [ - ...setText, - { type: "popover.filter", popover: "context", query }, - ], - ) + return changed({ ...state, popover: { type: "context", query }, focus: "editor" }, [ + ...setText, + { type: "popover.filter", popover: "context", query }, + ]) } const command = value.match(/^\/([^\s/]*)$/) if (command) { const query = command[1] ?? "" - return changed( - { ...state, popover: { type: "command-inline", query }, focus: "editor" }, - [ - ...setText, - { type: "popover.filter", popover: "command", query }, - ], - ) + return changed({ ...state, popover: { type: "command-inline", query }, focus: "editor" }, [ + ...setText, + { type: "popover.filter", popover: "command", query }, + ]) } return changed( @@ -123,45 +117,35 @@ function openCommands( persisted: PromptInputV2PersistedState, ): PromptInputV2Transition { if (!populated(persisted)) { - return changed( - { ...state, popover: { type: "command-inline", query: "" }, focus: "editor" }, - [ - { type: "draft.setText", value: promptText(persisted) + "/" }, - { type: "popover.filter", popover: "command", query: "" }, - { type: "focus.editor" }, - ], - ) - } - return changed( - { ...state, popover: { type: "command-menu", query: "" }, focus: "command-search" }, - [ + return changed({ ...state, popover: { type: "command-inline", query: "" }, focus: "editor" }, [ + { type: "draft.setText", value: promptText(persisted) + "/" }, { type: "popover.filter", popover: "command", query: "" }, - { type: "focus.command-search" }, - ], - ) + { type: "focus.editor" }, + ]) + } + return changed({ ...state, popover: { type: "command-menu", query: "" }, focus: "command-search" }, [ + { type: "popover.filter", popover: "command", query: "" }, + { type: "focus.command-search" }, + ]) } function openContext( state: PromptInputV2InteractionState, persisted: PromptInputV2PersistedState, ): PromptInputV2Transition { - return changed( - { ...state, popover: { type: "context", query: "" }, focus: "editor" }, - [ - { type: "draft.setText", value: promptText(persisted) + "@" }, - { type: "popover.filter", popover: "context", query: "" }, - { type: "focus.editor" }, - ], - ) + return changed({ ...state, popover: { type: "context", query: "" }, focus: "editor" }, [ + { type: "draft.setText", value: promptText(persisted) + "@" }, + { type: "popover.filter", popover: "context", query: "" }, + { type: "focus.editor" }, + ]) } function queryChanged(state: PromptInputV2InteractionState, query: string): PromptInputV2Transition { if (state.popover.type === "closed") return unchanged(state) const popover = state.popover.type === "context" ? "context" : "command" - return changed( - { ...state, popover: { ...state.popover, query, activeID: undefined } }, - [{ type: "popover.filter", popover, query }], - ) + return changed({ ...state, popover: { ...state.popover, query, activeID: undefined } }, [ + { type: "popover.filter", popover, query }, + ]) } function resultsChanged(state: PromptInputV2InteractionState, ids: string[]): PromptInputV2Transition { @@ -215,20 +199,26 @@ function keyDown( return unchanged(state) } if (event.key === "Escape") { - return changed( - { ...state, popover: { type: "closed" }, focus: "editor" }, - [{ type: "focus.editor" }], - true, - ) + return changed({ ...state, popover: { type: "closed" }, focus: "editor" }, [{ type: "focus.editor" }], true) } if (event.key === "Tab" || (event.key === "Enter" && !event.composing)) { if (!state.popover.activeID) return unchanged(state, true) return unchanged(state, true, [{ type: "suggestion.select", id: state.popover.activeID }]) } - const direction = event.key === "ArrowDown" || (event.ctrl && event.key === "n") ? 1 : event.key === "ArrowUp" || (event.ctrl && event.key === "p") ? -1 : 0 + const direction = + event.key === "ArrowDown" || (event.ctrl && event.key === "n") + ? 1 + : event.key === "ArrowUp" || (event.ctrl && event.key === "p") + ? -1 + : 0 if (!direction || event.ids.length === 0) return unchanged(state) const current = state.popover.activeID ? event.ids.indexOf(state.popover.activeID) : -1 - const index = current < 0 ? (direction === 1 ? 0 : event.ids.length - 1) : (current + direction + event.ids.length) % event.ids.length + const index = + current < 0 + ? direction === 1 + ? 0 + : event.ids.length - 1 + : (current + direction + event.ids.length) % event.ids.length return changed({ ...state, popover: { ...state.popover, activeID: event.ids[index] } }, [], true) } diff --git a/packages/session-ui/src/v2/components/prompt-input/store.ts b/packages/session-ui/src/v2/components/prompt-input/store.ts index 2819af735d..d924c554ac 100644 --- a/packages/session-ui/src/v2/components/prompt-input/store.ts +++ b/packages/session-ui/src/v2/components/prompt-input/store.ts @@ -67,7 +67,9 @@ export function createPromptInputV2Store(input: PromptInputV2StoreInput) { setStore()("context", "items", (items) => items.filter((item) => item.key !== key)) }, addMention(mention: PromptInputV2FilePart | PromptInputV2AgentPart) { - const text = store().prompt.map((part) => ("content" in part ? part.content : "")).join("") + const text = store() + .prompt.map((part) => ("content" in part ? part.content : "")) + .join("") const end = store().cursor ?? text.length const start = text.slice(0, end).lastIndexOf("@") setStore()("prompt", insertMention(store().prompt, start < 0 ? end : start, end, mention))