Skip to content

feat(tui): migrate quota sidebar and commands to TUI V2 - #196

Open
dmmop wants to merge 6 commits into
slkiser:mainfrom
dmmop:main
Open

feat(tui): migrate quota sidebar and commands to TUI V2#196
dmmop wants to merge 6 commits into
slkiser:mainfrom
dmmop:main

Conversation

@dmmop

@dmmop dmmop commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • Migrate the TUI integration to the OpenCode V2 plugin API.
  • Add a quota sidebar with collapsible provider details and active-provider count.
  • Register local /quota and token-usage slash commands.
  • BREAKING CHANGE: OpenCode's SQLite credential database replaced auth.json as credential source.

Testing

  • pnpm run typecheck
  • pnpm exec vitest run tests/tui-v2-commands.test.ts
  • git diff --check 87e6540...HEAD
  • manually verified /quota in the OpenCode V2 TUI

David Martinez added 6 commits August 2, 2026 09:49
- Extend `src/lib/opencode-auth.ts` with a credential database reader
  - Add `CredentialDatabase` and `CredentialDatabaseConstructor` types
  - Add `runtimeRequire` to conditionally load `better-sqlite3`
  - Implement `getCredentialDbPaths`, `readCredentialDatabase`, `openCredentialDatabase`, and `parseCredentialValue`
- Modify `readAuthFile` and add `readAuthFiles` + `readCredentialDatabases` to merge credentials from auth.json and OpenCode's database
- Preserve precedence: entries in auth.json override database credentials; database serves as a fallback for OAuth credentials
- Add tests covering database fallback and auth.json precedence in `tests/lib.opencode-auth.test.ts`
@slkiser

slkiser commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@dmmop Thanks for the PR, code looks good.

I believe OpenCode v2 is still in beta, so I'd hold off on releasing this on main for now.

If there is support for v2 or when v2 is out of beta I'll definitely return to the PR.

@dmmop

dmmop commented Aug 2, 2026

Copy link
Copy Markdown
Author

@slkiser Thanks you for this plugin!

Yes, v2 is still in beta, thats why "opencode-next.db" is hardcoded in the code.

I adapted the plugin to suit my needs in v2, i'll keep this PR update if they introduce any breaking change.

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.

2 participants