|
@@ -112,9 +112,10 @@ export function Prompt(props: PromptProps) {
|
|
|
const animationsEnabled = createMemo(() => kv.get("animations_enabled", true))
|
|
const animationsEnabled = createMemo(() => kv.get("animations_enabled", true))
|
|
|
const list = createMemo(() => props.placeholders?.normal ?? [])
|
|
const list = createMemo(() => props.placeholders?.normal ?? [])
|
|
|
const shell = createMemo(() => props.placeholders?.shell ?? [])
|
|
const shell = createMemo(() => props.placeholders?.shell ?? [])
|
|
|
- const editorPath = createMemo(() => editor.selection()?.filePath)
|
|
|
|
|
|
|
+ const fileContextEnabled = createMemo(() => kv.get("file_context_enabled", true))
|
|
|
|
|
+ const editorPath = createMemo(() => (fileContextEnabled() ? editor.selection()?.filePath : undefined))
|
|
|
const editorSelectionLabel = createMemo(() => {
|
|
const editorSelectionLabel = createMemo(() => {
|
|
|
- const selection = editor.selection()?.selection
|
|
|
|
|
|
|
+ const selection = fileContextEnabled() ? editor.selection()?.selection : undefined
|
|
|
if (!selection) return
|
|
if (!selection) return
|
|
|
if (selection.start.line === selection.end.line && selection.start.character === selection.end.character) return
|
|
if (selection.start.line === selection.end.line && selection.start.character === selection.end.character) return
|
|
|
if (selection.start.line === selection.end.line) return `#${selection.start.line}`
|
|
if (selection.start.line === selection.end.line) return `#${selection.start.line}`
|
|
@@ -746,7 +747,7 @@ export function Prompt(props: PromptProps) {
|
|
|
// Capture mode before it gets reset
|
|
// Capture mode before it gets reset
|
|
|
const currentMode = store.mode
|
|
const currentMode = store.mode
|
|
|
const variant = local.model.variant.current()
|
|
const variant = local.model.variant.current()
|
|
|
- const editorSelection = editor.selection()
|
|
|
|
|
|
|
+ const editorSelection = fileContextEnabled() ? editor.selection() : undefined
|
|
|
const editorParts = editorSelection
|
|
const editorParts = editorSelection
|
|
|
? [
|
|
? [
|
|
|
{
|
|
{
|
|
@@ -755,13 +756,17 @@ export function Prompt(props: PromptProps) {
|
|
|
text: (() => {
|
|
text: (() => {
|
|
|
const start = editorSelection.selection.start
|
|
const start = editorSelection.selection.start
|
|
|
const end = editorSelection.selection.end
|
|
const end = editorSelection.selection.end
|
|
|
|
|
+
|
|
|
|
|
+ let text = ""
|
|
|
if (start.line === end.line && start.character === end.character) {
|
|
if (start.line === end.line && start.character === end.character) {
|
|
|
- return `Note: The user opened the file "${editorSelection.filePath}".`
|
|
|
|
|
- }
|
|
|
|
|
- if (start.line === end.line) {
|
|
|
|
|
- return `Note: The user selected line ${start.line} from "${editorSelection.filePath}": ${editorSelection.text}`
|
|
|
|
|
|
|
+ text = `Note: The user opened the file "${editorSelection.filePath}".`
|
|
|
|
|
+ } else if (start.line === end.line) {
|
|
|
|
|
+ text = `Note: The user selected line ${start.line + 1} from "${editorSelection.filePath}". \`\`\`${editorSelection.text}\`\`\`\n\n`
|
|
|
|
|
+ } else {
|
|
|
|
|
+ text = `Note: The user selected lines ${start.line + 1} to ${end.line + 1} from "${editorSelection.filePath}". \`\`\`${editorSelection.text}\`\`\`\n\n`
|
|
|
}
|
|
}
|
|
|
- return `Note: The user selected lines ${start.line} to ${end.line} from "${editorSelection.filePath}": ${editorSelection.text}`
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return `<system-reminder>${text} This may or may not be relevant to the current task.</system-reminder>\n`
|
|
|
})(),
|
|
})(),
|
|
|
synthetic: true,
|
|
synthetic: true,
|
|
|
metadata: {
|
|
metadata: {
|
|
@@ -835,6 +840,7 @@ export function Prompt(props: PromptProps) {
|
|
|
],
|
|
],
|
|
|
})
|
|
})
|
|
|
.catch(() => {})
|
|
.catch(() => {})
|
|
|
|
|
+ editor.clearSelection()
|
|
|
}
|
|
}
|
|
|
history.append({
|
|
history.append({
|
|
|
...store.prompt,
|
|
...store.prompt,
|