feat(desktop): papercut fixes (#34939)
This commit is contained in:
parent
caedf36844
commit
d46c02ba73
5 changed files with 23 additions and 6 deletions
|
|
@ -218,6 +218,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
||||||
let scrollRef!: HTMLDivElement
|
let scrollRef!: HTMLDivElement
|
||||||
let slashPopoverRef!: HTMLDivElement
|
let slashPopoverRef!: HTMLDivElement
|
||||||
let restoreEndOnFocus = true
|
let restoreEndOnFocus = true
|
||||||
|
let savedCursor: number | null = null
|
||||||
|
|
||||||
const mirror = { input: false }
|
const mirror = { input: false }
|
||||||
const inset = 56
|
const inset = 56
|
||||||
|
|
@ -590,7 +591,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
||||||
|
|
||||||
const restoreFocus = () => {
|
const restoreFocus = () => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
const cursor = prompt.cursor() ?? promptLength(prompt.current())
|
const cursor = savedCursor ?? prompt.cursor() ?? promptLength(prompt.current())
|
||||||
editorRef.focus()
|
editorRef.focus()
|
||||||
setCursorPosition(editorRef, cursor)
|
setCursorPosition(editorRef, cursor)
|
||||||
queueScroll()
|
queueScroll()
|
||||||
|
|
@ -627,6 +628,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
||||||
const isImeComposing = (event: KeyboardEvent) => event.isComposing || composing() || event.keyCode === 229
|
const isImeComposing = (event: KeyboardEvent) => event.isComposing || composing() || event.keyCode === 229
|
||||||
|
|
||||||
const handleBlur = () => {
|
const handleBlur = () => {
|
||||||
|
savedCursor = currentCursor()
|
||||||
closePopover()
|
closePopover()
|
||||||
setComposing(false)
|
setComposing(false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 440;
|
font-weight: 440;
|
||||||
line-height: 1;
|
line-height: 16px;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { createSignal, Show, type JSXElement } from "solid-js"
|
||||||
import "./titlebar-tab-popover.css"
|
import "./titlebar-tab-popover.css"
|
||||||
|
|
||||||
// Initial hover delay before the preview appears, per design.
|
// Initial hover delay before the preview appears, per design.
|
||||||
const OPEN_DELAY = 200
|
const OPEN_DELAY = 400
|
||||||
// Mouse-out delay: begin closing immediately (a brief exit animation plays).
|
// Mouse-out delay: begin closing immediately (a brief exit animation plays).
|
||||||
const CLOSE_DELAY = 0
|
const CLOSE_DELAY = 0
|
||||||
// After a preview closes, hovering a neighbouring tab within this window skips
|
// After a preview closes, hovering a neighbouring tab within this window skips
|
||||||
|
|
|
||||||
|
|
@ -1393,14 +1393,14 @@ export function MessageTimeline(props: {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
data-slot="session-title-parent"
|
data-slot="session-title-parent"
|
||||||
class="min-w-0 max-w-[40%] truncate px-2 text-[13px] font-[530] leading-4 tracking-[-0.04px] text-v2-text-text-faint transition-colors hover:text-v2-text-text-muted"
|
class="min-w-0 max-w-[40%] truncate pl-2 text-[13px] font-[530] leading-4 tracking-[-0.04px] text-v2-text-text-faint transition-colors hover:text-v2-text-text-muted"
|
||||||
onClick={navigateParent}
|
onClick={navigateParent}
|
||||||
>
|
>
|
||||||
{parentTitle()}
|
{parentTitle()}
|
||||||
</button>
|
</button>
|
||||||
<span
|
<span
|
||||||
data-slot="session-title-separator"
|
data-slot="session-title-separator"
|
||||||
class="-translate-y-[0.5px] px-1 text-[11px] font-medium text-v2-text-text-faint"
|
class="-translate-y-[0.5px] pl-2 pr-1 text-[11px] font-medium text-v2-text-text-faint"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
/
|
/
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { useLanguage } from "@/context/language"
|
||||||
import { useLocal } from "@/context/local"
|
import { useLocal } from "@/context/local"
|
||||||
import { useSettings } from "@/context/settings"
|
import { useSettings } from "@/context/settings"
|
||||||
import { useDialog } from "@opencode-ai/ui/context/dialog"
|
import { useDialog } from "@opencode-ai/ui/context/dialog"
|
||||||
|
import { getCursorPosition, setCursorPosition } from "@/components/prompt-input/editor-dom"
|
||||||
import { useSessionLayout } from "./session-layout"
|
import { useSessionLayout } from "./session-layout"
|
||||||
import { createSessionOwnership } from "./session-ownership"
|
import { createSessionOwnership } from "./session-ownership"
|
||||||
|
|
||||||
|
|
@ -26,9 +27,23 @@ export const useComposerCommands = () => {
|
||||||
|
|
||||||
const chooseModel = async () => {
|
const chooseModel = async () => {
|
||||||
const owner = sessionOwnership.capture()
|
const owner = sessionOwnership.capture()
|
||||||
|
const editor = document.querySelector<HTMLElement>('[data-component="prompt-input"]')
|
||||||
|
const selection = window.getSelection()
|
||||||
|
const cursor =
|
||||||
|
editor && selection?.rangeCount && editor.contains(selection.anchorNode) ? getCursorPosition(editor) : null
|
||||||
|
const restoreComposer = () => {
|
||||||
|
// Kobalte restores focus during its teardown effect; defer past it so the
|
||||||
|
// composer keeps focus and the caret returns to where the user left it.
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
const editor = document.querySelector<HTMLElement>('[data-component="prompt-input"]')
|
||||||
|
if (!editor) return
|
||||||
|
editor.focus()
|
||||||
|
if (cursor !== null) setCursorPosition(editor, cursor)
|
||||||
|
})
|
||||||
|
}
|
||||||
const { DialogSelectModel } = await import("@/components/dialog-select-model")
|
const { DialogSelectModel } = await import("@/components/dialog-select-model")
|
||||||
owner.run(() => {
|
owner.run(() => {
|
||||||
void dialog.show(() => <DialogSelectModel model={local.model} />)
|
void dialog.show(() => <DialogSelectModel model={local.model} />, restoreComposer)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue