feat: add opencode usage tracking plugin#6145
Open
JJDizz1L wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new first-party Omarchy shell bar widget plugin (omarchy.opencode-model-usage) that reads OpenCode’s local SQLite DB and surfaces token/session usage in the Quickshell bar + popup UI.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Changes:
- Introduces the
opencode-model-usageplugin (manifest + icon) and a full Widget popup UI with settings. - Adds a Quickshell provider that runs a Python scanner and maps results into the widget’s expected fields.
- Adds a Python SQLite scanner that summarizes today / recent 7 days / all-time per-model token usage.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| shell/plugins/opencode-model-usage/Widget.qml | Bar chip, popup UI (today/7-day/all-time), settings UX, IPC handlers. |
| shell/plugins/opencode-model-usage/Main.qml | Wires settings + refresh timer and exposes display-provider data to the widget. |
| shell/plugins/opencode-model-usage/providers/Opencode.qml | Provider implementation that watches the DB file and runs the scanner process. |
| shell/plugins/opencode-model-usage/scripts/opencode_usage_scanner.py | Reads OpenCode SQLite session table and emits compact JSON usage summary. |
| shell/plugins/opencode-model-usage/manifest.json | Declares plugin metadata, bar-widget schema, and defaults. |
| shell/plugins/opencode-model-usage/assets/opencode.svg | OpenCode icon asset used by the chip/header. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+330
to
+333
| spacing: Style.space(8) | ||
| UsageChip { visible: !root.vertical } | ||
| EmptyUsageChip { visible: !root.vertical && !provider } | ||
| } |
Comment on lines
+339
to
+342
| spacing: Style.space(2) | ||
| UsageChip { visible: root.vertical } | ||
| EmptyUsageChip { visible: root.vertical && !provider } | ||
| } |
| spacing: 10 | ||
|
|
||
| Text { | ||
| visible: !root.settingsMode && !root.provider |
|
|
||
| component WeekCard: SectionCard { | ||
| property var provider: null | ||
| visible: !!provider && provider.recentDays && provider.recentDays.length > 0 |
| RowLayout { | ||
| Layout.fillWidth: true | ||
| spacing: 20 | ||
| StatBlock { value: provider ? String(provider.todayPrompts || 0) : "0"; label: "sessions" } |
Comment on lines
+9
to
+17
| BarWidget { | ||
| id: root | ||
| moduleName: "omarchy.opencode-model-usage" | ||
|
|
||
| property bool popupOpen: false | ||
| property bool settingsMode: false | ||
| property var draftSettings: ({}) | ||
| property string settingsStatusText: "" | ||
| property bool refreshFlash: false |
Comment on lines
+50
to
+56
| FileView { | ||
| id: dbFile | ||
| path: root.resolvePath(root.dbPath) | ||
| watchChanges: true | ||
| onFileChanged: reload() | ||
| onLoaded: root.refresh(false) | ||
| } |
Comment on lines
+99
to
+101
| } catch (e) { | ||
| console.error("model-usage/opencode", "Failed to parse scanner output:", e) | ||
| } |
| return empty_result() | ||
|
|
||
| try: | ||
| conn = sqlite3.connect(str(db_path)) |
| ORDER BY time_created DESC | ||
| """) | ||
|
|
||
| for row in cursor.fetchall(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
OpenCode Usage — Omarchy Bar Widget
Tracks OpenCode AI coding assistant usage (sessions, tokens, models) directly in the Omarchy Quickshell Bar.
Queries OpenCode's local SQLite database — no API keys, no data leaves machine.
Features
omarchy-shell shell rescanPluginsomarchy config shell bar add omarchy.opencode-model-usage left|center|right