Skip to content

Commit e5d4260

Browse files
committed
Add Gemini provider support and release 0.5.0
1 parent d4d9ef5 commit e5d4260

53 files changed

Lines changed: 5268 additions & 114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "yapcap"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
edition = "2024"
55
license = "MPL-2.0"
66
description = "COSMIC panel applet for Codex, Claude Code, and Cursor usage"

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# YapCap
44

5-
**A native COSMIC panel applet that tracks AI coding quota for Codex, Claude Code, and Cursor.**
5+
**A native COSMIC panel applet that tracks AI coding quota for Codex, Claude Code, Cursor, and Gemini.**
66

77
<img src="resources/screenshots/screenshot-hero.png" alt="YapCap panel applet" width="780" />
88

@@ -23,10 +23,11 @@ YapCap lives in your COSMIC panel and shows how much of your AI coding quota you
2323

2424
## Highlights
2525

26-
- **Three providers**
26+
- **Four providers**
2727
- **Codex** — 5h/weekly windows + credits
2828
- **Claude Code** — session/weekly/extra usage
2929
- **Cursor** — plan usage + billing cycle end
30+
- **Gemini** — Pro / Flash / Lite quota bars (OAuth accounts only)
3031
- **Multi-account view** — add, switch, and remove accounts per provider. Turn on **Show all accounts** to lay out each selected account side by side in the popup and show one usage-bar group per account in the panel.
3132
- **Active badge** — YapCap reads your local Codex and Claude Code session state to mark which account is currently active in the host CLI.
3233
- **In-app login** — guided login flows for Codex, Claude, and Cursor without leaving YapCap or opening a terminal
@@ -201,7 +202,15 @@ Logs (native): `~/.local/state/yapcap/logs/yapcap.log`. Logs (Flatpak): `~/.var/
201202

202203
- COSMIC only. No GNOME, KDE, or tray fallback.
203204
- No historical charts, notifications, or cost analytics.
204-
- Three providers only for now.
205+
- Four providers only for now.
206+
- **Gemini OAuth only.** YapCap meters Gemini accounts authenticated via Google OAuth.
207+
API-key (`selectedAuthType: gemini-api-key`) and Vertex AI (`selectedAuthType:
208+
vertex-ai`) gemini-cli configurations are not supported — switch the account to
209+
OAuth with `gemini auth login` to use YapCap.
210+
- **One Gemini project per account.** YapCap displays the single
211+
`cloudaicompanionProject` returned by Google's `loadCodeAssist` for each
212+
account. Users with multiple paid GCP projects see whichever project Google
213+
selects, not all of them.
205214

206215
## License
207216

docs/qa.md

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# YapCap QA Plan
22

3-
Manual test plan for v0.4.0. Run against both Native (`just install`) and Flatpak (`just flatpak-install`) builds unless noted.
3+
Manual test plan for v0.5.0. Run against both Native (`just install`) and Flatpak (`just flatpak-install`) builds unless noted.
44

55
Paths used below:
66

@@ -188,7 +188,70 @@ In Settings → General, cycle through all four panel icon styles and verify the
188188

189189
---
190190

191-
## 9. Multi-account
191+
## 9. Gemini
192+
193+
### 9.1 Fresh install / Login required
194+
195+
- With no Gemini accounts configured, the Gemini provider tab is visible and shows the **Login required** empty state pointing to Settings → Gemini → Add account.
196+
- Pre-existing host `~/.gemini/oauth_creds.json` is **not** imported. YapCap does not read host tokens.
197+
198+
### 9.2 Add account (Native and Flatpak)
199+
200+
- Settings → Gemini → Add account opens the system browser (Native: directly; Flatpak: via `org.freedesktop.portal.OpenURI`) at Google's sign-in page.
201+
- The browser redirects back to a loopback `127.0.0.1:<port>/?code=…&state=…` callback served by YapCap; the success page reads "Signed in to Gemini — you can close this tab and return to YapCap."
202+
- Cancel during login aborts cleanly with no partial account stored.
203+
- Successful login stores the account under native `~/.local/state/yapcap/gemini-accounts/<id>/` or Flatpak `~/.var/app/io.github.TopiCsarno.YapCap/data/yapcap/gemini-accounts/<id>/`.
204+
- Stored directory contains `metadata.json` (email, sub, optional `hd`, last tier id, last `cloudaicompanionProject`) and `tokens.json` (`access_token`, `refresh_token`, `expires_at`, `scope`).
205+
- New account is selected immediately in single-account mode.
206+
207+
### 9.3 Multi-account dedupe
208+
209+
- Add a second Gemini account with a different Google identity — both accounts appear in Settings and the popup.
210+
- Re-running Add account with an already-stored Google account updates the existing managed directory by normalized email; no second entry is created.
211+
212+
### 9.4 Usage display
213+
214+
- Free-tier account: popup shows two bars (**Flash**, **Lite**); the Pro bar is hidden.
215+
- Standard-tier (AI Pro) account: popup shows three bars (**Pro**, **Flash**, **Lite**); panel bars show Pro + Flash.
216+
- Workspace account (id_token `hd` present, `currentTier.id = standard-tier`): plan badge reads **Workspace**.
217+
- Each bucket reset follows the YapCap-wide `reset_time_format` preference.
218+
219+
### 9.5 Tier transitions
220+
221+
- Upgrade a free-tier account to AI Pro (or downgrade). On the next refresh cycle the Pro bar appears or disappears and the plan badge updates from **Free** to **Pro**/**Workspace** (or back), without restarting YapCap.
222+
223+
### 9.6 Active account hint
224+
225+
- With YapCap running, `gemini auth login` to a Gemini account YapCap is tracking — the **Active** badge follows the new active email written to `~/.gemini/google_accounts.json`.
226+
- Switching to a Google account that YapCap does not track removes the Active badge from all tracked accounts.
227+
- Deleting `~/.gemini/google_accounts.json` clears the Active badge; recreating it (e.g. via another `gemini auth login`) restores it without a YapCap restart.
228+
- Flatpak: same behaviour through the read-only home mount; click **Refresh now** as a fallback if file watching misses an atomic replace.
229+
230+
### 9.7 Token refresh and re-auth
231+
232+
- Set `expires_at` to one minute in the past with a valid `refresh_token`. Verify silent refresh on the next cycle and updated `expires_at` in `tokens.json`.
233+
- Replace `refresh_token` with junk. Verify `ActionRequired` badge ("Login") on the account, plus a per-account re-auth icon in Settings.
234+
- Per-account re-auth: click re-auth icon → complete OAuth in the browser with the same Google account → usage refreshes immediately.
235+
- Per-account re-auth with a different Google account (different `id_token.email`) → rejected with error, existing account left unchanged.
236+
237+
### 9.8 Remove account
238+
239+
- Remove from Settings — only the YapCap-owned account directory is deleted. Host `~/.gemini/` files (`oauth_creds.json`, `google_accounts.json`, `settings.json`) are not touched.
240+
- If it was the last Gemini account, the provider returns to the Login required empty state.
241+
242+
### 9.9 Host CLI configurations that don't interfere
243+
244+
- Pre-existing `~/.gemini/settings.json` with `selectedAuthType: gemini-api-key` or `vertex-ai`: YapCap still runs OAuth login and stores its own tokens; the absence of an Active badge for these accounts is **expected**, not a bug.
245+
- A `GEMINI_API_KEY` environment variable on the host shell has no effect on YapCap.
246+
247+
### 9.10 `cloudresourcemanager` fallback
248+
249+
- For accounts where `loadCodeAssist` returns no `cloudaicompanionProject` (common when the user has a paid GCP project but no auto-assigned Code Assist project), YapCap calls `cloudresourcemanager.googleapis.com/v1/projects` and picks the first `ACTIVE` project whose id begins with `gen-lang-client-`. Verify the discovered project id is persisted to `metadata.json` (`gemini_last_cloudaicompanion_project`) and the next refresh re-uses it directly.
250+
- For accounts where neither path yields a project, the provider surfaces the actionable `NoCloudaicompanionProject` error in the popup.
251+
252+
---
253+
254+
## 10. Multi-account
192255

193256
- Add a second account for any provider.
194257
- `Show all accounts` toggle appears only when the provider has more than one account.
@@ -200,7 +263,7 @@ In Settings → General, cycle through all four panel icon styles and verify the
200263

201264
---
202265

203-
## 10. Stale / error states
266+
## 11. Stale / error states
204267

205268
- Kill network (`nmcli networking off`). Trigger a refresh. Verify "No internet connection. Showing cached data; information is not up to date." message. Cached usage data still visible. Re-enable network, verify Live badge returns.
206269
- Wait 11 minutes without refreshing (or set refresh interval to max and advance clock). Verify account badge switches from Live to Stale. Status line appends "(stale)".
@@ -209,7 +272,7 @@ In Settings → General, cycle through all four panel icon styles and verify the
209272

210273
---
211274

212-
## 11. Provider enable/disable
275+
## 12. Provider enable/disable
213276

214277
- Disable a provider via its settings toggle — provider tab disappears from popup nav.
215278
- All provider-specific settings below the toggle are dimmed and non-interactive when disabled.
@@ -218,7 +281,7 @@ In Settings → General, cycle through all four panel icon styles and verify the
218281

219282
---
220283

221-
## 12. Popup sizing
284+
## 13. Popup sizing
222285

223286
- Single-account provider: popup is 420 px wide.
224287
- Two-account provider: popup is 840 px wide.
@@ -229,13 +292,13 @@ In Settings → General, cycle through all four panel icon styles and verify the
229292

230293
---
231294

232-
## 13. Accounts removed from filesystem
295+
## 14. Accounts removed from filesystem
233296

234297
- Manually delete a provider account directory from the YapCap data tree (`~/.local/state/yapcap/<provider>-accounts/` native, or `~/.var/app/io.github.TopiCsarno.YapCap/data/yapcap/<provider>-accounts/` Flatpak). Trigger a refresh. Verify the provider surfaces "Login required" or empty state rather than showing a stale snapshot indefinitely.
235298

236299
---
237300

238-
## 14. Config state file manipulation
301+
## 15. Config state file manipulation
239302

240303
- Delete cached snapshots (native `~/.cache/yapcap/snapshots.json`, Flatpak `~/.var/app/io.github.TopiCsarno.YapCap/cache/yapcap/snapshots.json`). Restart. Verify app starts with Loading state and fetches fresh data.
241304
- Delete the COSMIC config dir (`just clear-config`). Restart. Verify defaults apply: all providers enabled, refresh interval 300s, relative reset time, used amount format.
@@ -245,19 +308,19 @@ In Settings → General, cycle through all four panel icon styles and verify the
245308

246309
---
247310

248-
## 15. Logging
311+
## 16. Logging
249312

250313
- Native: verify `~/.local/state/yapcap/logs/yapcap.log`. Flatpak: verify `~/.var/app/io.github.TopiCsarno.YapCap/data/yapcap/logs/yapcap.log`. Each is written during a normal session for that build.
251314
- Verify no bearer tokens, access tokens, cookie values, or refresh tokens appear in the log.
252315
- `RUST_LOG=debug just run` — debug output in terminal, still no credentials in log file.
253316

254317
---
255318

256-
## 16. Flatpak-specific
319+
## 17. Flatpak-specific
257320

258321
- Install via `just flatpak-install`. YapCap appears in COSMIC applet list.
259322
- Install from the COSMIC Store. YapCap appears in the COSMIC panel applet picker after installation, uses the `io.github.TopiCsarno.YapCap` Flatpak id, appears under the applet category/filter, and shows "Place on desktop" rather than "Open".
260-
- COSMIC Store details page shows developer `Tamás Csarnó`, version `0.4.0`, description paragraphs without manual line-break wrapping, and screenshots in this order: detail popup, Codex zoom, Claude Code zoom, Cursor zoom, Settings.
323+
- COSMIC Store details page shows developer `Tamás Csarnó`, version `0.5.0`, description paragraphs without manual line-break wrapping, and screenshots in this order: detail popup, Codex zoom, Claude Code zoom, Cursor zoom, Settings.
261324
- About section shows "Flatpak" dist label.
262325
- OAuth flows (Codex, Claude) open the system browser correctly from inside the sandbox.
263326
- COSMIC dark/light theme and accent colour updates are observed immediately through the settings config watcher.

0 commit comments

Comments
 (0)