From 0ce0cacb282c47943348a2af21ea00e721bcb9d9 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Wed, 21 Jan 2026 05:27:52 -0600 Subject: wip(app): line selection --- packages/app/src/components/prompt-input.tsx | 137 +++++++++++++++++---------- 1 file changed, 89 insertions(+), 48 deletions(-) (limited to 'packages/app/src/components') diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx index 0d6a7641a..5e936737a 100644 --- a/packages/app/src/components/prompt-input.tsx +++ b/packages/app/src/components/prompt-input.tsx @@ -164,6 +164,18 @@ export const PromptInput: Component = (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 @@ -171,6 +183,11 @@ export const PromptInput: Component = (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( () => @@ -1485,40 +1502,49 @@ export const PromptInput: Component = (props) => { 0 || !!activeFile()}> -
+
{(path) => ( -
- -
- {getDirectory(path())} - {getFilename(path())} - - {(sel) => ( - - {sel().startLine === sel().endLine - ? `:${sel().startLine}` - : `:${sel().startLine}-${sel().endLine}`} - - )} - - {language.t("prompt.context.active")} +
+
+ +
+ {getDirectory(path())} + {getFilename(path())} + + {(sel) => ( + + {sel().startLine === sel().endLine + ? `:${sel().startLine}` + : `:${sel().startLine}-${sel().endLine}`} + + )} + + {language.t("prompt.context.active")} +
+ prompt.context.removeActive()} + aria-label={language.t("prompt.context.removeActiveFile")} + />
- prompt.context.removeActive()} - aria-label={language.t("prompt.context.removeActiveFile")} - /> + + {(preview) => ( +
+                        {preview()}
+                      
+ )} +
)} - {(item) => ( -
- -
- {getDirectory(item.path)} - {getFilename(item.path)} - - {(sel) => ( - - {sel().startLine === sel().endLine - ? `:${sel().startLine}` - : `:${sel().startLine}-${sel().endLine}`} - + {(item) => { + const preview = createMemo(() => selectionPreview(item.path, item.selection, item.preview)) + return ( +
+
+ +
+ {getDirectory(item.path)} + {getFilename(item.path)} + + {(sel) => ( + + {sel().startLine === sel().endLine + ? `:${sel().startLine}` + : `:${sel().startLine}-${sel().endLine}`} + + )} + +
+ prompt.context.remove(item.key)} + aria-label={language.t("prompt.context.removeFile")} + /> +
+ + {(comment) =>
{comment()}
} +
+ + {(content) => ( +
+                          {content()}
+                        
)}
- prompt.context.remove(item.key)} - aria-label={language.t("prompt.context.removeFile")} - /> -
- )} + ) + }}
-- cgit v1.2.3