Skip to content

fix: disable OpenCode title generation to improve latency#166

Open
NovaH00 wants to merge 2 commits into
ThePrimeagen:masterfrom
NovaH00:master
Open

fix: disable OpenCode title generation to improve latency#166
NovaH00 wants to merge 2 commits into
ThePrimeagen:masterfrom
NovaH00:master

Conversation

@NovaH00

@NovaH00 NovaH00 commented Apr 6, 2026

Copy link
Copy Markdown

Before processing the user prompt, OpenCode prompts the LLM to generate a session title for display in the UI.

title

While the token count isn't much, the additional latency of this request will definitely makes the completion less snappy!

To bypass this, we set the title to an empty string when initializing the OpenCode agent.


Note

Medium Risk
Adds a new provider path that can generate custom prompts and may edit files directly, plus changes the OpenCode command invocation; issues here could affect request execution and buffer state for multiple providers.

Overview
Improves provider extensibility by letting providers optionally implement _build_prompt, which Prompt:start_request now uses to generate the request text instead of always concatenating agent_context.

Disables OpenCode’s session-title generation by passing --title "" in OpenCodeProvider._build_command (to reduce extra latency), and adds a new PiProvider that formats a file-editing prompt with line-numbered visual snippets, supports pi --list-models, and triggers a checktime buffer reload after successful visual edits for providers that edit files directly. Tests are updated/added to cover the new command args and PiProvider behavior.

Reviewed by Cursor Bugbot for commit 78fba90. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread lua/99/providers.lua

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is kicking off a free cloud agent to fix these issues. This run is complimentary, but you can enable autofix for all future PRs in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 78fba90. Configure here.

Comment thread lua/99/ops/over-range.lua Outdated
or require("99.providers").OpenCodeProvider
if provider._build_prompt then
vim.cmd("checktime")
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing return after checktime causes misleading error message

Medium Severity

For providers that edit files directly (like PiProvider), vim.cmd("checktime") correctly reloads the buffer with the AI's edits, but the code continues to fall through without returning. Since PiProvider's prompt instructs the AI to only use its edit tool and not output code in chat, the temp file stays empty, and _retrieve_response returns "". This causes vim.trim(response) == "" to be true, printing "response was empty, visual replacement aborted" — even though the edits were successfully applied. If marks happen to be invalidated by the buffer reload, logger:fatal triggers assert(false, ...), crashing the handler. An early return after vim.cmd("checktime") would avoid both problems.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 78fba90. Configure here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugbot Autofix determined this is a false positive.

This codebase has no checktime path or PiProvider, so the reported fallthrough and crash scenario cannot occur in the current implementation.

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread lua/99/providers.lua Outdated
for i = 2, #lines do
local parts = vim.split(lines[i], "%s+")
if #parts >= 2 then
table.insert(models, parts[1] .. "/" .. parts[2])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace split without trimempty produces wrong model names

Low Severity

vim.split(lines[i], "%s+") without { trimempty = true } produces an empty first element when a line has leading whitespace, causing parts[1] to be "" and model names to be constructed as "/column2" instead of "column1/column2". Every other vim.split call in this file uses { trimempty = true }, suggesting this is an oversight.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 78fba90. Configure here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugbot Autofix determined this is a false positive.

providers.lua no longer contains the flagged whitespace split logic and all current relevant splits already use safe parsing patterns.

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@cursor

cursor Bot commented Apr 9, 2026

Copy link
Copy Markdown

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant