From 8c1c5786ebfe8dda40a70571f332e876b184ad4d Mon Sep 17 00:00:00 2001 From: t Date: Tue, 1 Dec 2026 16:31:43 -0700 Subject: Isolate ACP via custom agent and add steering, usage, reseed, and footer updates Replace the osascript permission dialog and settings.json permission seed with a per-thread generated custom main agent (excludeDefaultComponents, tools: [], no inherited customizations or MCP) launched with --agent, --include-default-customizations=false, and --dangerously-skip-permissions. Keep HOME unchanged (isolating via --gemini-dir only) so macOS finds the login Keychain, mark exported tools with antigravity/alwaysLoad, and require the relay to serve tools/list before the first prompt. Add ACP turn steering for queued user and workflow text at tool boundaries, preserve agent_thought_chunk thinking blocks with block-aware checkpoint hashing, report live usage_update context snapshots and deduplicated final plus steering token usage, and mount a live above-input native tool activity component for up to six non-MCP ACP calls. Support reseeding a new ACP session from history_transcript after /tree or cold resume, allow direct submissions to take over an idle session from another thread, and let extension follow-ups continue a matching warm session. Update the usage footer with startup and three-minute timer refreshes, 1w/5h labels, per-letter antigravity colors, and expired-bucket handling. --- quota.lua | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'quota.lua') diff --git a/quota.lua b/quota.lua index 3b6ecbc..7b32a55 100644 --- a/quota.lua +++ b/quota.lua @@ -39,6 +39,10 @@ function M.parse(body, reset_time) end if pct or at then local label = group ~= '' and group ~= bucket and (group .. ' / ' .. bucket) or bucket + if group == 'Gemini Models' then + if bucket == 'Weekly Limit Remaining' then label = '1w' + elseif bucket == 'Five Hour Limit Remaining' then label = '5h' end + end windows[#windows + 1] = { label = pct and label:gsub(' Limit Remaining$', ' Limit Used') or label, used_percent = pct and 100 - pct or nil, @@ -58,6 +62,7 @@ function M.activate(ext, footer, acp) if not state or state.closed then return function() end end if state.antigravity_refresh then return state.antigravity_refresh end local alive, ready, pending, next_run = true, false, nil, 0 + local clock local function publish(windows) if not alive then return end @@ -66,7 +71,8 @@ function M.activate(ext, footer, acp) end local render if windows and #windows > 0 then - local expires = os.time() + stale_s + local sampled = os.time() + local expires = sampled + stale_s local stale = section({}, 'stale') local cached, deadline = nil, 0 render = function(now) @@ -74,13 +80,16 @@ function M.activate(ext, footer, acp) if not cached or now >= deadline then local current = {} deadline = expires + local expired = false for _, w in ipairs(windows) do if not w.resets_at or w.resets_at > now then current[#current + 1] = w if w.resets_at then deadline = math.min(deadline, w.resets_at) end + elseif w.resets_at > sampled then + expired = true -- crossed a real reset since this reading end end - cached = section(current, #current < #windows and 'stale' or nil) + cached = section(current, (#current == 0 or expired) and 'stale' or nil) end return cached(now) end @@ -91,8 +100,7 @@ function M.activate(ext, footer, acp) pcall(footer.publish, ext, key, render) end - -- The caller supplies direct-turn provenance. Only a visible footer needs - -- a sample. Drop duplicate calls in flight or inside the cooldown; no polling. + -- Only a visible footer needs a sample. Coalesce startup and turn reads. local function refresh() if not alive or not ready or not state.handle or pending then return end local now = uv.hrtime() / 1000000 @@ -151,13 +159,24 @@ function M.activate(ext, footer, acp) ext.on('session_ready', function(event) if not alive or ready or event.has_tui == false then return end ready = true - -- Show a placeholder without touching the account; only a direct turn - -- may replace it with an actual reading. - pcall(footer.publish,ext,key,footer.section(ext,'antigravity',{}, {status='awaiting first turn'})) + pcall(footer.publish,ext,key,footer.section(ext,'antigravity',{}, {status='loading'})) + refresh() + -- A long-running or idle Neon thread may not cross a turn boundary + -- before the five-minute sample expires. No polling on other models. + clock = uv.new_timer() + clock:start(180000, 180000, function() + if not alive or not state.handle then return end + local info = ext.session_info() + local provider = info and info.model and info.model:match('^([^:]+):') + local cfg = provider and ext.config.providers[provider] + if cfg and cfg.protocol == 'antigravity-acp' and cfg.usage_footer ~= false then refresh() end + end) + clock:unref() end) state.antigravity_refresh = refresh ext.on('session_end', function() alive = false + close(clock) if pending then pending.stop() end state.antigravity_refresh, state.sections[key] = nil, nil end) -- cgit v1.3