GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): file context improvements and option to disable by jlongster · Pull Request #24661 · anomalyco/opencode

feat(core): file context improvements and option to disable #24661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
jlongster merged 2 commits into dev from tui-file-context
Apr 27, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(core): file context improvements and option to disable #24661

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
340dd42
wip
jlongster Apr 27, 2026
9b2b79e
fix(tui): rename context toggle to file context
jlongster Apr 27, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Next Next commit
wip
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@jlongster
jlongster committed Apr 27, 2026
commit 340dd42d5dec1b549b1868ea3d51f00a4d76c2ba

There are no files selected for viewing

9 changes: 9 additions & 0 deletions 9 packages/opencode/src/cli/cmd/tui/app.tsx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,15 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
dialog.clear()
},
},
{
title: kv.get("project_context_enabled", true) ? "Disable project context" : "Enable project context",
value: "app.toggle.project_context",
category: "System",
onSelect: (dialog) => {
kv.set("project_context_enabled", !kv.get("project_context_enabled", true))
dialog.clear()
},
},
{
title: kv.get("diff_wrap_mode", "word") === "word" ? "Disable diff wrapping" : "Enable diff wrapping",
value: "app.toggle.diffwrap",
Expand Down
22 changes: 14 additions & 8 deletions 22 packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ export function Prompt(props: PromptProps) {
const animationsEnabled = createMemo(() => kv.get("animations_enabled", true))
const list = createMemo(() => props.placeholders?.normal ?? [])
const shell = createMemo(() => props.placeholders?.shell ?? [])
const editorPath = createMemo(() => editor.selection()?.filePath)
const projectContextEnabled = createMemo(() => kv.get("project_context_enabled", true))
const editorPath = createMemo(() => (projectContextEnabled() ? editor.selection()?.filePath : undefined))
const editorSelectionLabel = createMemo(() => {
const selection = editor.selection()?.selection
const selection = projectContextEnabled() ? editor.selection()?.selection : undefined
if (!selection) 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}`
Expand Down Expand Up @@ -746,7 +747,7 @@ export function Prompt(props: PromptProps) {
// Capture mode before it gets reset
const currentMode = store.mode
const variant = local.model.variant.current()
const editorSelection = editor.selection()
const editorSelection = projectContextEnabled() ? editor.selection() : undefined
const editorParts = editorSelection
? [
{
Expand All @@ -755,13 +756,17 @@ export function Prompt(props: PromptProps) {
text: (() => {
const start = editorSelection.selection.start
const end = editorSelection.selection.end

let text = ""
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,
metadata: {
Expand Down Expand Up @@ -835,6 +840,7 @@ export function Prompt(props: PromptProps) {
],
})
.catch(() => {})
editor.clearSelection()
}
history.append({
...store.prompt,
Expand Down
17 changes: 10 additions & 7 deletions 17 packages/opencode/src/cli/cmd/tui/context/editor.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
send({ id: requestID, method, params })
}

const scheduleReconnect = (delay: number) => {
const scheduleReconnect = () => {
if (closed) return
if (reconnect) clearTimeout(reconnect)
attempt += 1
const delay = Math.min(1000 * 2 ** (attempt - 1), 10_000)
reconnect = setTimeout(connect, delay)
}

Expand All @@ -122,7 +124,7 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
const dbPath = resolveZedDbPath()
if (!dbPath) {
setStore("status", "disabled")
scheduleReconnect(1000)
scheduleReconnect()
return
}
zedSelection ??= resolveZedSelection(dbPath)
Expand All @@ -143,7 +145,7 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
.finally(() => {
zedSelection = undefined
})
scheduleReconnect(1000)
scheduleReconnect()
return
}

Expand Down Expand Up @@ -207,13 +209,11 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
if (closed) return

setStore("status", "connecting")
attempt += 1
const delay = Math.min(1000 * 2 ** (attempt - 1), 30000)
scheduleReconnect(delay)
scheduleReconnect()
})
}

scheduleReconnect(0)
connect()

onCleanup(() => {
closed = true
Expand All @@ -232,6 +232,9 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
selection() {
return store.selection
},
clearSelection() {
setStore("selection", undefined)
},
onMention(listener: (mention: EditorMention) => void) {
mentionListeners.add(listener)
return () => mentionListeners.delete(listener)
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.