Skip to content

fix(vscode,intellij): handle missing status and fix StringIndexOutOfBoundsException in completion renderer#4482

Open
octo-patch wants to merge 1 commit into
TabbyML:mainfrom
octo-patch:fix/vscode-spinner-no-completion-model
Open

fix(vscode,intellij): handle missing status and fix StringIndexOutOfBoundsException in completion renderer#4482
octo-patch wants to merge 1 commit into
TabbyML:mainfrom
octo-patch:fix/vscode-spinner-no-completion-model

Conversation

@octo-patch

Copy link
Copy Markdown

Summary

This PR fixes two bugs in the client extensions:

1. VSCode: Constant spinner when no completion model is running (fixes #4418)

Problem: When the Tabby server is connected but no completion model is configured, the status bar shows a persistent spinning animation. This happens because StatusBarItem.ts does not handle the codeCompletionNotAvailable status emitted by tabby-agent, so the icon stays as the loading spinner from the previous Starting state.

Solution: Add a codeCompletionNotAvailable case to the switch statement in StatusBarItem.ts that displays the warning icon with the appropriate tooltip — consistent with other warning states like rateLimitExceeded.

2. IntelliJ: StringIndexOutOfBoundsException in InlineCompletionRenderer (fixes #4404)

Problem: InlineCompletionRenderer.kt throws java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 at line 95 (currentLineSuffix[0]) when suffixReplaceLength == 1 but currentLineSuffix is empty. This can happen when the completion item's replaceRange.end extends past the end of the actual document line (e.g., cursor at end of line or document state mismatch).

Solution: Guard the suffixReplaceLength == 1 branch with currentLineSuffix.isNotEmpty(). When the suffix is empty, the code falls through to the existing else block which handles the case gracefully without accessing out-of-bounds indices.

Test plan

  • VSCode: Connect to a Tabby server with no completion model configured; verify the status bar shows a warning icon (⚠) instead of a spinning spinner
  • IntelliJ: Verify no StringIndexOutOfBoundsException when inline completion is triggered at the end of a line

When the Tabby server is connected but no completion model is running,
the status bar shows a persistent spinning spinner because the
`codeCompletionNotAvailable` status was not handled in StatusBarItem.ts.

Add a case for `codeCompletionNotAvailable` that displays the warning
icon with appropriate tooltip, matching the behavior of similar warning
states like `rateLimitExceeded`.

Also guard `currentLineSuffix[0]` access in InlineCompletionRenderer.kt
with an `isNotEmpty()` check to fix a `StringIndexOutOfBoundsException`
that occurs when the cursor is at the end of a line but the completion
item reports a non-zero `suffixReplaceLength` (fixes TabbyML#4404).

Fixes TabbyML#4418
Fixes TabbyML#4404
@wsxiaoys wsxiaoys requested a review from icycodes April 18, 2026 05:38
@ronda-labs

Copy link
Copy Markdown

Both bugs are the kind of defensive coding gap that's hard to write tests for upfront — a constant spinner when no completion model is configured is a bad first-run experience, and a StringIndexOutOfBoundsException in the renderer would make the IDE plugin look broken. The null check on status and the bounds guard on the completion text look correct. Does the VSCode fix also address the spinner state when the model endpoint changes at runtime, not just on initial connect?

@octo-patch

Copy link
Copy Markdown
Author

Yes — StatusBarItem.update() is wired to this.client.status.on("didChange", () => this.update()) (StatusBarItem.ts:33), so whenever tabby-agent emits a status change at runtime (including when the model endpoint changes and codeCompletionNotAvailable is re-emitted), the new case fires and the icon transitions to the warning state. It's not gated on initial connect.

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.

[VSCode extension] Constant spinner animation when no completion model running StringIndexOutOfBoundsException during editing of a source file.

2 participants