Skip to content

Claude plan usage in the notch (5 h and weekly), for the Tauri build - #171

Draft
AinzDerErste wants to merge 12 commits into
Louis-CFM:mainfrom
AinzDerErste:plan-usage
Draft

AinzDerErste wants to merge 12 commits into
Louis-CFM:mainfrom
AinzDerErste:plan-usage

Conversation

@AinzDerErste

Copy link
Copy Markdown

Part 1 of 3 of bringing the macOS 0.1.3 defaults to the Tauri build on Linux (and Windows). Draft until #158 is merged: this branch sits on top of #158, so until then the diff also shows its 11 commits. Only the last commit, "Claude plan usage in the notch", is new here.

This is the design of #159 for the Tauri build, in place of the small usage card that #158 used to carry (that card is gone from #158 now):

  • A pill in the header ("Claude 73%": green below 50 %, orange up to 80 %, red above, grey without data). Clicking it opens the plan card (5 hours and week, reset times, age of the numbers) in place of the left card, and Mochi takes the plan's colour. Off by default.
  • The numbers come from Claude Code's status line (rate_limits) through the relay, with the same checks as ClaudePlanGauge: 100-200 % shown full, above 200 or below 0 dropped, a reset more than 400 days away dropped, a passed reset counts as 0 %.
  • The relay runs as the status line (coucou-hook --statusline) and runs the user's previous status line with the same input, printing its output untouched (10 s limit). The previous one is kept in statusline-previous.json beside the relay.
  • Settings → Plan usage: "Show in the notch" starts the install when the relay is not in yet; "Install relay…" / "Uninstall relay…" show the diff of the statusLine key only, back settings.json up and write after a click (and only for the diff that was shown). Only command is swapped, so padding and the like stay; uninstalling puts the previous status line back, or removes the key if there was none.

Pill and plan card

The numbers in the picture are real, from my own Claude Code sessions.

Checked: tsc, vite build, cargo test (the installer's status line merge/restore rules, the relay's chaining), no new warnings. A throwaway test of the validation, dominant percentage and colour rules. The relay run by hand with and without a previous status line, with bad input and in the old StatusLine form. Real numbers arriving from real sessions on KDE/Wayland.
Not checked: Windows, macOS, GNOME.

Differences from the Mac: no githubOnly split (there is no App Store build of this app), and no Xcode tools check (the relay is a binary that ships with the app).

Justin Minkmar added 12 commits October 3, 2026 13:26
With NVIDIA's proprietary driver, WebKitGTK's DMABUF renderer commits frames to a
Wayland surface after announcing explicit sync without an acquire point. The
compositor then closes the connection with a protocol error and the app dies on its
first frame.

Switch the DMABUF renderer off when the NVIDIA driver is loaded, unless the user set
WEBKIT_DISABLE_DMABUF_RENDERER themselves. Split prepare_environment into one
function per concern.
Wayland has no main display, and the layer surface was never assigned an output,
so the compositor picked one.

- Pin the layer surface to the chosen monitor (gtk_layer_set_monitor).
- Settings -> Island lives on lists every display by name and size.
- "Main display" now asks XWayland's RandR for the primary output, which KWin and
  Mutter set from the user's choice, and falls back to the first display.
- Report the compositor's pointer leave (GTK leave-notify) to the page. WebKitGTK
  sends no mouseleave when the pointer leaves the surface, so the island never
  learned the mouse was gone and never auto-closed.
- Restart the collapse timer when an alert reaches an island that is already open.
  forceHome cancelled it and only a state change started it again.
- Start the drop sequence after the island has opened. Waking a closed island passes
  through its default view, which stopped the sequence and left "uploading" stuck.
- Let clicks through #content and the hidden DOM view to the drop canvas' buttons;
  Cancel and Ask were covered by invisible elements.
- Give the ticker's dim text top:0. Without it WebKit places the absolute box one
  line below the text it should overlap.
- Let notes dismiss themselves after five seconds.
…there is no editor

- The relay passes Konsole's D-Bus names. The app switches to the tab over D-Bus
  and raises its window with a short KWin script, found by Konsole's process id and
  the tab's title.
- Look for code, code-insiders, code-oss, codium, vscodium and cursor in that order.
- When no editor is installed the island says so instead of silently opening the
  file manager.
- open_in_vscode returns an enum instead of a bool.
Settings -> Language (system, English, Deutsch, Français). An explicit choice tells
the chat to always answer in that language, whatever the question or the search
results are in. The step labels ("Runs", "Führt aus", "Exécute") follow it, where
they were fixed to French.
Without an API key the chat runs `claude -p` on the user's own login instead of
failing with "API key missing". Read, WebSearch and WebFetch are pre-approved, the
user's hooks are left out (--setting-sources project, run from a temp directory) so
the helper does not show up as a session, and follow-up questions resume the same
session.
Embed the handful of Font Awesome Free 7 (solid) paths in use, with the CC BY 4.0
notice, and drop the hand-drawn header icons. The tabs get a little more room.
Clicking the overview's left card opens an editor view while the session has
edited a file or run a command: Mochi and the Read / Edit / Bash / Done phases on
the left, on the right the changed lines in red and green with a few lines of
context, and under them the last command and what it printed. Nothing opens by
itself.

- snippet.rs reads the lines around an edit, only from a regular file inside the
  session's folder, up to 2 MB.
- The relay forwards the last three lines a Bash command printed, without colour
  codes; the rest of tool_response stays out.
CSS cannot transition between two gradients, so the halo's colour flipped in one
step. Ease colour and opacity per frame, like Mochi's position.
GTK's leave-notify reaches the page over IPC and can overtake the last mouse-move
WebKit was still handing it. That move put the mouse "inside" again after the leave,
and since nothing follows a pointer that is gone, the island never started its
auto-close timer; it stayed open until OK was pressed.

Ignore page mouse-moves for 400 ms after a leave. A real re-entry is picked up by the
next moves right after.
The view read its data from the one shared "Claude Code" pill. With several sessions
running, a new prompt in one of them wiped what the view showed and the project name
jumped between them.

Each session now has its own record, keyed by session_id, and the view shows the one
that was active last and has something to show. A session remembers the folder it
started in: its name, the paths in the diff and the folder the file is read from no
longer change when the shell cd's. A finished session is dropped after its view has
been shown; one that never says so is forgotten after 30 minutes.
As on the Mac (docs/INTEGRATIONS.md, "Jauge de forfait Claude"), for the Tauri build:

- A pill in the header of the overview ("Claude 73%", green below 50 %, orange up to
  80 %, red above, grey without data). Clicking it puts the plan card in place of the
  left card (5 hours and week, reset times, how old the numbers are), and Mochi wears
  the plan's colour while it is open. It closes when the view, the mode or the focus
  changes. Off by default.
- The numbers come from Claude Code's own status line (`rate_limits`), like on the Mac,
  and are checked the same way: 100-200 % is shown full, anything else is dropped, a
  reset more than 400 days away is milliseconds in disguise, and a window whose reset
  has passed counts as 0 %.
- The relay runs as the status line (`coucou-hook --statusline`), passes the limits on
  and runs the status line the user had before with the same input, printing its output
  untouched (10 s limit). That one is kept in statusline-previous.json beside the relay.
- Installing and removing the relay is its own step, apart from the hooks: Settings ->
  Plan usage shows the diff of the `statusLine` key only, backs settings.json up and
  writes after a click. Only `command` is swapped, so padding and the like stay;
  removing puts the previous status line back, or the key goes if there was none, and a
  status line the user changed since is left alone.
- Settings -> Plan usage -> Show in the notch turns it on and starts the install first
  when the relay is not in yet.

Calls using the older `coucou-hook StatusLine` form keep working.

This branch has not been deployed

No deployments
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