wip(app): line selection

This commit is contained in:
Adam
2026-01-21 13:31:06 -06:00
parent cb481d9ac8
commit 1e1872aada
8 changed files with 83 additions and 65 deletions

View File

@@ -167,18 +167,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
return files.pathFromTab(tab)
})
const selectionPreview = (path: string, selection?: FileSelection, preview?: string) => {
if (preview) return preview
if (!selection) return undefined
const content = files.get(path)?.content?.content
if (!content) return undefined
const start = Math.max(1, Math.min(selection.startLine, selection.endLine))
const end = Math.max(selection.startLine, selection.endLine)
const lines = content.split("\n").slice(start - 1, end)
if (lines.length === 0) return undefined
return lines.slice(0, 2).join("\n")
}
const activeFileSelection = createMemo(() => {
const path = activeFile()
if (!path) return
@@ -186,11 +174,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
if (!range) return
return selectionFromLines(range)
})
const activeSelectionPreview = createMemo(() => {
const path = activeFile()
if (!path) return
return selectionPreview(path, activeFileSelection())
})
const info = createMemo(() => (params.id ? sync.session.get(params.id) : undefined))
const status = createMemo(
() =>
@@ -1534,13 +1517,6 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
aria-label={language.t("prompt.context.removeActiveFile")}
/>
</div>
<Show when={activeSelectionPreview()}>
{(preview) => (
<pre class="text-10-regular text-text-weak font-mono whitespace-pre-wrap leading-4">
{preview()}
</pre>
)}
</Show>
</div>
)}
</Show>

View File

@@ -2074,13 +2074,14 @@ export default function Page() {
>
<button
type="button"
class="flex items-center gap-2 px-2 py-1 rounded-md bg-surface-raised-stronger-non-alpha border border-border-base text-12-regular text-text-strong hover:bg-surface-raised-base-hover"
class="group relative flex items-center gap-2 h-6 px-2.5 rounded-md bg-surface-raised-stronger-non-alpha border border-border-weak-base text-12-medium text-text-strong shadow-xs-border whitespace-nowrap hover:bg-surface-raised-stronger-hover hover:border-border-hover focus:outline-none focus-visible:shadow-xs-border-focus"
onClick={() => {
const p = path()
if (!p) return
addSelectionToContext(p, sel())
}}
>
<span class="pointer-events-none absolute -left-1 top-1/2 size-2.5 -translate-y-1/2 rotate-45 bg-surface-raised-stronger-non-alpha border-l border-b border-border-weak-base group-hover:bg-surface-raised-stronger-hover group-hover:border-border-hover" />
<Icon name="plus-small" size="small" />
<span>
{language.t("session.context.addToContext", {