Skip to content

Lunavect 0.2.8: session limits, Agent Monitor, Year and All time statistics - #50

Merged
lovach merged 40 commits into
mainfrom
claude/release-0.2.8
Sep 30, 2026
Merged

lovach merged 40 commits into
mainfrom
claude/release-0.2.8

Conversation

@lovach

@lovach lovach commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Limits for running sessions. Limit Usage… stops a Claude or Codex session when the week reaches your level (suggested: today's share of what is left), with an on-by-default guard that lets the agent finish its step before the 5-hour window runs out. Near the level the agent wraps up and writes what is done and what is left; at the level its next action is refused through Lunavect's hooks, nothing is killed. The user's own message lifts the stop; Claude Code's own continuation after its usage limit does not. Continue Later… continues a session after a reset or at a time, typed into the session's own Terminal or iTerm2 tab only when Lunavect is sure the tab is that session's.
  • Agent Monitor: tokens per session, model and project from the local logs; each Claude response counts once, Codex threads are followed across files, moves and resets (ledger v4).
  • Statistics: Year and All time, a daily archive without a time limit, calendar, "When you work" clock, projects, waits and sessions.
  • Limits: a manual reset in the Claude or Codex app shows without waiting for the scheduled reset.
  • Widgets: plan end date from Subscriptions.
  • Sessions: claude -p runs show as background runs and no longer take over a session open in Terminal.
  • Pre-release audit (30.09): 27 findings, fixes with tests for every confirmed defect, including a crash when switching Sessions/Tasks with the panel open (found in the live re-check on the installed candidate).

Test plan

  • ./scripts/check.sh on the exact head (see comment below for the numbers)
  • Live on installed signed builds 212–218: weekly stop and hook refusal for Claude and Codex 0.159, agent summaries, the user's message lifting a stop, +5 %, Continue now (Claude with CR; Codex by folder and tab title; two Codex sessions in one folder get nothing), claude -p --resume keeps the session's row, panel tab switching 200× without a crash, chronod reload: succeeded after install
  • Independent token recount on real logs (Claude exact to the token over 30 days)
  • Signed release, Sparkle update 0.2.8 (218 local) → 0.2.8 (219), widget check after the update
  • Not checked live: real 5-hour cut-off (20x plan), a real Codex usage-limit cut-off, Claude's limit menu, iTerm2 (not installed), system notification banners (not authorized on this Mac)

🤖 Generated with Claude Code

vicey and others added 30 commits September 29, 2026 16:48
A `claude -p` run started by a plugin or script has no window or tab. Owner
report 29.09: the autoharness plugin's reflector appeared after every reply
as "Thinking" in DONE/Lunavect, counted as working, and clicking it asked to
open a Python window that does not exist.

Such a run (flag read from the runtime's arguments by the catalog and by the
hook helper, not kept) is listed as "Background run · <launching app>", is
not counted as working, sends no notifications, is not activity or Keep
Awake input, and clicking it explains that there is nothing to open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sion

Moving a running linker-signed fixture let macOS end it before detection, so
the test failed intermittently. Staleness is now decided through injectable
process facts; the real process only proves that its launch path is read.
The installed extension is also found through a linked path (/var and
/private/var), which the stop previously missed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idgets

Owner requests 29.09.

- Daily totals are kept forever in activity-archive.json (per source and
  together: hours, projects, sessions, live waiting). Days the 35-day history
  covers are recomputed from it; a one-time background read of every log
  still on the Mac adds older days, marked as recovered.
- Statistics gains Year (by week) and All time (adaptive buckets), a year
  calendar, a weekday × hour map, top projects, time agents waited for the
  user and session counts. Each source's line starts at its first record.
- Limits widgets show the plan end date compactly (orange in its last week,
  red once passed), with a switch in Settings → Widgets.
- A passed end date while the provider still reports subscription limits is
  offered for renewal in Settings → Subscriptions, with one notification.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The long-range chart, the calendar and the weekday grid had no hover:
the chart now shows a guide, points and a readout of the hovered week,
the calendar and the grid name the hovered day or hour in their header.
A year of unknown weeks squeezed the known ones into a strip, so the
chart and the calendar start at the week of the first record; the
calendar keeps the cell size of a full year and uses the free space for
the longest day and the average per day with work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner review 29.09: the weekday x hour grid was hard to read (156 of 168
cells filled, nearly one colour) and scrolling the statistics stuttered.

- When you work shows night, morning, afternoon and evening as shares
  and the time per weekday, as the owner chose.
- A live checkpoint recomputed the whole 34-day archive window on the
  main thread (about 40 ms on the owner's month) whenever agents changed
  state. It now recomputes the last days (about 5 ms); the whole window
  follows at launch, after an import, on a new day and every half hour.
  The day records are filtered to the window and updated in place.
- The calendar is one drawing with its own hover state, so moving over
  it redraws only that card; hover state is set only when it changes.
- The service test used an hour sixty days ago that crossed midnight
  when run late in the evening.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner request 29.09: where did the tokens go. A token ledger reads the
Claude and Codex logs incrementally (cursor per file; the first pass over
13.7 GB of the owner's logs takes about 35 s in the background, later
passes read only appended lines in under 0.1 s):

- Claude: message usage deduplicated by response id (one response is
  written on up to 18 lines), subagent files counted in their session.
- Codex: cumulative token_count totals as differences, spawned threads
  counted in their parent session.
- Each session's estimated share of the weekly limit splits the used
  percent by price-weighted tokens; the pace is its last hour.

The Agent Monitor window lists sessions with tokens, model, subagent
share, share of the week and current pace. Statistics gain Where tokens
went (cache share, subagents, projects and models) from daily token
entries kept in the archive. Session rows show the share of the week.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…work

Owner decisions 29.09: a task gets a share of the week (plus an optional
five-hour guard), is asked to wrap up at 80 %, is stopped softly at the
budget, and continues after the reset; its work must never be lost.

- Claude runs as claude -p with streamed JSON both ways (session id set by
  Lunavect, --permission-prompts none); Codex runs through its app-server
  (thread/start or thread/resume, turn/start, turn/steer, turn/interrupt).
  Both were checked live: a message reaches the agent mid-turn, interrupt
  ends the step cleanly, resume keeps the whole conversation.
- A git project gets a separate worktree on a lunavect/ branch; before any
  pause and at the end the changes are committed there (the user's own
  identity when set). The user's folder changes only on Accept changes.
- Permission profiles: careful (edits and safe commands), auto, and full
  access only when chosen for the task.
- Budget: price-weighted tokens of the task times the week's percent per
  weighted token from the token ledger; a new week restores the budget.
- The sessions panel gains a Tasks tab and New Task window; task sessions
  are labelled as Lunavect tasks instead of background runs.
- Live runs: Claude and Codex each created a file in their copy and
  committed it; a budget-paused Claude task continued the same
  conversation after Add budget and finished.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first pass over the owner's 13.7 GB of logs peaked at 3.1 GB: Data
kept growing while lines were removed from its front, so a large log
stayed in memory whole. The partial line now goes into a fresh buffer,
chunks are 2 MB with autorelease pools, and lines over 256 KB are never
parsed whole (Claude's usage and a few short fields are cut out). Peak
footprint 295 MB, 29 s.

The Tasks tab sizes the panel by its cards and hides the hidden-sessions
footer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Near the end of a week with at least 20 % left and tasks waiting for the
reset, one notice suggests starting them. The monitor's share column is
wider and task budgets read as whole percentages. CHANGELOG and the
privacy table cover the token ledger, tasks and their project copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner review 30.09: the percentage in the row is noise. It stays in the
row's tooltip and in the Agent Monitor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner review 30.09: writing a task into Lunavect, choosing a project and
a budget preset is not how people work; the prompt lives in Claude or
Codex. Tasks now start from a session that is already running:

- Limit Usage… (two-finger click or ⋯ on the session): stop when the week
  reaches a level the user types, optionally continue after the reset.
- Continue Later…: after the five-hour or weekly reset or at a set time.
- Near the level the agent is asked, through the hooks Lunavect already
  installs, to finish its step and write what is left; at the level its
  next action is refused and a new prompt is blocked with the reason
  (PreToolUse deny, UserPromptSubmit block; both documented by Claude
  Code and Codex). Nothing is killed; files and the conversation stay.
- The continuation is typed into the session's own Terminal or iTerm2 tab
  once it is idle; elsewhere a notification says what to write.
- The Tasks tab lists these sessions; a small symbol marks them in the
  list. The week's level is the last reading plus the tokens seen since.

The separate task engine (headless runs, worktrees, the New Task window)
is removed; the token monitor stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mit, draw the day as a clock

- Limit Usage gains "Don't get cut off by the 5-hour window" (on by default): the agent wraps
  up near 88 % of the window and rests from 96 % (hooks refuse like a stop), then Lunavect
  types the continuation after the reset. The level starts at today's share of the week.
- A Codex turn the usage limit ended (task_complete with usage_limit_exceeded) is offered
  for continuation after the reset; setting in General -> Sessions: Ask, Continue without
  asking, Do nothing. Claude Code 2.1.234+ continues by itself, so for Claude only the ends
  of its own wait count: Enter after a sleep (stale), an offer when it gave up or is off.
- Continuing types the message while the agent runs in its tab, runs claude --resume /
  codex resume at a shell prompt, and opens a new Terminal window when the tab is gone.
- Notification buttons: Continue now, +5 %, Continue after the reset, No thanks, Continue
  in Terminal. Tasks cards show the agent's summary from its log.
- When you work: the day as a 24-hour clock with hover, parts beside it, weekday bars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code writes copies of earlier responses back into the same transcript hours later
(same uuid and timestamp). The 64-id window counted them again: in three long sessions
this put the last 35 days 5.8 % too high. A response over a minute older than one already
read in the file is now skipped; ledger version 2 rereads the logs once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whole-hour buckets counted the tokens spent before a reading in the same hour as spent
after it, and the ratio used the tokens up to now rather than up to the reading. For the
5-hour window that could move the level by a fifth of the window. The ledger now keeps
per-minute totals for the last six hours, and the ratio ends at the reading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live checks 30.09 in Terminal with real Claude Code 2.1.283 and Codex 0.155.1:
- The tab check knew only claude, codex and node; the native Claude installer's binary is
  named by its version. Every Lunavect runtime name counts now, a name starting with a
  digit too, and the session's own runtime process name when its pid is known.
- Codex reads fast input as a paste, where the one Return is a new line: the text stayed in
  its composer. For Codex a second Return follows after 0.6 s, and the message is sent.
Claude typing (one Return), resume at a shell prompt and a new window after the tab closed
worked as built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner report 30.09: after a Codex usage-limit reset the widget kept 0 % because a used-up
window was not asked about before its scheduled reset, three days away. Manual resets and
added credits lift a limit early, so a used-up window is asked about hourly and after
session activity; Claude's "limit reached" pause lasts at most an hour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The store tests hold the reasons: Claude's /usage probe cannot answer while a window is
used up and Claude has no manual reset, so its pause until the reset stays. Codex's
rate-limit read always answers and Codex offers manual resets, so only a used-up Codex
window is asked about hourly and after activity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live check 30.09: Codex's hooks/list showed all eight Lunavect hooks "modified" for two days
while the other tools' hooks were trusted, so Codex sent Lunavect nothing and a limit could
not stop a Codex session. Codex asks to trust changed or moved hooks again and skips them
silently until then. Lunavect now asks the read-only hooks/list at launch and hourly, and
Settings -> Connections shows a warning with Open Codex in Terminal (in a folder Codex
already trusts) and Check again; Limit Usage says the same for a Codex session. Lunavect
never writes the trust itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Claude app offers a manual limit reset too (owner report 30.09). A timer probe
while Claude is used up brought back the hourly visible probe of R1-01, so only a
session response the limit did not refuse asks, at most hourly; refused attempts
(StopFailure rate_limit) and timers still ask nothing. A reached limit may be asked
again the same way after an hour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a continuation

Review of the 0.2.8 session controls:
- the limit file is rewritten before a continuation is typed, so the hooks no longer
  block the message that continues a stopped or resting session;
- a message is typed only while this session's runtime runs on the tab's device, and a
  resume command always changes to the session's folder: macOS reuses a closed tab's
  device and the user may run another agent or program there;
- a long message no longer cuts the resume command inside its quotes; a message
  starting with - is not read as an option;
- the control is read again after typing, so one removed or changed meanwhile stays so;
- limit entries lapse five minutes after their window resets, also when Lunavect is not
  running; a rest is kept while the 5-hour level is unknown;
- Claude Code's own limit wait survives the catalog merge, so the slept-through-reset and
  auto-continue-off paths reach Terminal sessions;
- removing a card declines its cut-off; a failed Enter keeps its way and offers no second
  process; the automatic Enter waits a minute for the notice's button; a continuation
  whose reset was unknown, or a cut-off no reading shows, is filled in later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The Automation prompt and privacy.md name typing a continuation, resuming and
  opening Codex for hook trust, not only bringing a tab to the front.
- notifications.md and menu-bar-limits.md no longer say a used-up window cannot
  change before its reset; session-limit notices and their switches are described.
- settings.md lists If a limit cuts work off, Show plan end date and the new
  Statistics ranges and cards; sessions.md documents Limit Usage and Continue Later.
- The notice after a new window names Terminal or iTerm2 and no longer claims the
  tab was closed when it runs something else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner 30.09: a stopped session should stop, and a message she writes to it should
continue it. UserPromptSubmit is no longer blocked: in a stopped or resting session the
hook notes the message in limit-overrides.json, tells the agent the limit is lifted, and
lets its next actions through; Lunavect then lifts the week's limit (or rests the 5-hour
guard until that window resets), rewrites the hooks' file and removes the note. A note
older than the stop is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Data review of 0.2.8, checked against the owner's logs (30.09):
- a resumed or forked session's new transcript starts with copies of earlier responses
  (1656 of 93852 responses, 3.6 % of tokens); every response now counts once by its
  message id across all files, which also replaces the time rule for written-back
  copies (a clock set back no longer drops responses). Ledger version 3 rescans.
- the first pass no longer drops days between its slices, which left old days with the
  last slice's share; the archive takes older days only when they rise, so a partial
  pass or transcripts Claude has deleted never lower them.
- after the first pass a response older than the kept window is not counted into a day.
- the level estimate waits for the first pass; its minute data counts from its end.
- a Codex rollout rewritten at the same path continues its cumulative total; merge state
  of files quiet for an hour is dropped, so the ledger stops growing with every file.
- scan slices are five seconds, so quitting during the first pass no longer waits 20 s.
- a failed Codex trust check keeps the known state and retries in five minutes; an
  unknown status warns of nothing; a long reply keeps its closing Done/Left lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live check 30.09: Terminal ends `do script` with a line feed, which Claude Code's
fullscreen interface ("tui": "fullscreen") takes as a new line, so a typed
continuation, and the Enter for a Claude Code waiting after its usage limit, stayed
in the input box. A pty check showed only a carriage return sends. The text for a
Claude session now ends with one; Lunavect's scheduled continuation was then sent and
answered in the owner's Terminal (build 213).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live check 30.09: Codex 0.159 runs its hooks from a shared daemon
(codex app-server --managed-daemon) that has no terminal, so a Codex session in
Terminal carries no device and a scheduled continuation fell back to a notice. A
session without a recorded device now uses the fallback opening already uses: the
one running process of its provider in the session's folder names the tab; several
sessions in one folder are never guessed. Lunavect's continuation was then typed and
answered in the owner's Terminal (build 214).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vicey and others added 10 commits September 30, 2026 21:51
… Claude's own continue

Pre-release audit 30.09 (findings in __local_0.2.8/audit-prerelease-0930/FINDINGS.md):
- a Codex tab found only by its folder gets the text only when its title names the session
  (Codex 0.159 runs hooks without a terminal); a Claude session without a device is never
  guessed; a new window opens only when the session's own recorded tab is gone, never for a
  session that is unlisted (hidden, or not read yet after launch);
- continuations and cut-off notices wait for the first read of the session list;
- Claude Code's automatic continuation after its usage limit (fixed prompt through
  UserPromptSubmit, docs) no longer counts as the user's message: a week's stop holds it back,
  a rest lets it go; rests are written as resting for the hooks;
- nothing is typed into a Claude session the usage limit cut off: Claude Code may show its limit
  options, which Enter would answer;
- late notification buttons act only on the state they were posted for (continue now, +5 %,
  continue in Terminal, no thanks); +5 % at the 100 % cap keeps the stop and leaves nothing to
  type later; an offer the user made moot by writing to the session is dropped;
- session-limit notices show while Lunavect is active; categories are registered at launch;
  undelivered notices are logged;
- a print-mode run on a session open interactively elsewhere no longer takes its tab, runtime or
  client, and its end is not the session's end; an interactive runtime clears a print run's mark;
- iTerm2 gets the same carriage return; a stop without a known reset still ends; an unreadable
  controls file is kept aside; Codex 0.159 replies are read from task_complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent recount 30.09: a thread continued in a new file (history_base) added the earlier
file's running total again (+30 M tokens on one day), a rollout moved to the archive would be
read again, and the response after a reset total was lost. The baseline of a continuation is
the earlier file's last total (or its own first one), a moved file keeps its cursor by inode,
and a fallen total counts in full. Ledger version 4 recounts the kept window. Adds the first
TokenService test (old days whole across the first pass's slices).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test waited for a pid a just-written script had not yet written: macOS's first-run check of
a new executable took over the helper's 1 s budget while other new programs started (reproduced
3/8 under that load; the app's timeout, cancellation and cleanup were correct). /bin/sh reads the
fixture at once; the test still catches a MainActor block, a surviving helper and a missed budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Full check 30.09 (iCloud sync at ~100 % CPU): the unsupported /usage screen test got timedOut
instead of unsupportedResponse because macOS's first-run check of the just-written fixture took
its 1 s budget (same cause as the hung-helper test). Tests timing a fixture's answer, not its
launch, run it once first; budgets are unchanged, tests that expect a timeout are untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A limit set below the week's level stopped the session at once, and the
card said "Stopped at 77 % of the week" while the week was at 83 %. The
card now shows the limit and the week, and the refusal says the week
reached this session's limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Switching Sessions and Tasks while the panel was open crashed Lunavect
(EXC_BAD_ACCESS in UpdateCycle): the height callback set the popover's
size inside SwiftUI's update, and the popover animated the resize in a
nested run loop that re-entered the update cycle. Reproduced on build 215
within 50 switches; 200 switches on the fix without a crash. A hidden
popover still takes its size at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AppleScript starts the app it talks to: with Terminal closed, typing a
continuation launched it, and the new window it opens can get the old
tab's device, so the text would go to a fresh shell. The typing script
now returns at once when Terminal or iTerm2 is not running; a session
with a known device then gets a new window with its resume command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `claude -p --resume` started from inside another Claude session is a
nested run. Its hooks marked the interactive session it resumed as nested
too, and Lunavect hid the session's row (live check on build 217). The
print run now keeps the interactive session's own mark, as it already
kept its tab, runtime and client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The installed local build is 218, and Sparkle and the release preflight
need a build above it and above the published 194. The changelog notes
the three fixes from the live re-check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lovach

lovach commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

./scripts/check.sh on d7f174e (clean tree, provenance passed): Swift 1344 (1265 passed, 79 skipped, 0 failures), Python 170 (169 passed, 1 skipped), IDE connector, widget probe/fallback/private ABI, unsigned build, hook helper, product and intent resources. native_render, live_clients, desktop_widget and signed_distribution are not run by this command.

@lovach
lovach merged commit f342daa into main Sep 30, 2026
4 checks passed
@lovach
lovach deleted the claude/release-0.2.8 branch September 30, 2026 21:03
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