agy-bar 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { homedir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
 
6
6
  const UUID_RE = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
7
+ export const STEP_STATUS_WAITING = 9;
7
8
 
8
9
  let cachedDatabaseSync;
9
10
  function loadDatabaseSync() {
@@ -143,7 +144,10 @@ export function getDbVersionStamp(dbPath) {
143
144
  }
144
145
  }
145
146
 
146
- export async function readLatestStepTiming(payload, { home = homedir(), prevDbStamp = null } = {}) {
147
+ export async function readLatestStepTiming(
148
+ payload,
149
+ { home = homedir(), prevDbStamp = null, prevWaitingForInput = undefined } = {},
150
+ ) {
147
151
  const id = payload?.conversation_id || payload?.session_id;
148
152
  if (typeof id !== 'string' || !UUID_RE.test(id)) return null;
149
153
 
@@ -152,7 +156,9 @@ export async function readLatestStepTiming(payload, { home = homedir(), prevDbSt
152
156
 
153
157
  const dbStamp = getDbVersionStamp(dbPath);
154
158
  if (prevDbStamp && dbStamp && dbStamp === prevDbStamp) {
155
- return { unchanged: true, dbStamp };
159
+ return typeof prevWaitingForInput === 'boolean'
160
+ ? { unchanged: true, dbStamp, waitingForInput: prevWaitingForInput }
161
+ : { unchanged: true, dbStamp };
156
162
  }
157
163
 
158
164
  let db;
@@ -162,8 +168,15 @@ export async function readLatestStepTiming(payload, { home = homedir(), prevDbSt
162
168
  const row = db
163
169
  .prepare('SELECT idx, metadata FROM steps WHERE step_type = 15 AND status = 3 ORDER BY idx DESC LIMIT 1')
164
170
  .get();
171
+ // Indexed numeric enum lookup (status = 9 -> WAITING for ask_question/user input); zero chat text read.
172
+ const waitingRow = db.prepare(`SELECT 1 AS w FROM steps WHERE status = ${STEP_STATUS_WAITING} LIMIT 1`).get();
173
+ const waitingForInput = Boolean(waitingRow?.w);
165
174
  const parsed = row ? parseStepTimingMetadata(row.metadata, row.idx) : null;
166
- return parsed ? { ...parsed, dbStamp } : dbStamp ? { unchanged: false, dbStamp } : null;
175
+ return parsed
176
+ ? { ...parsed, dbStamp, waitingForInput }
177
+ : dbStamp
178
+ ? { unchanged: false, dbStamp, waitingForInput }
179
+ : null;
167
180
  } catch {
168
181
  // Gracefully fall back on Node < 22.13, locked DBs, or schema changes.
169
182
  return null;
@@ -176,6 +189,42 @@ export async function readLatestStepTiming(payload, { home = homedir(), prevDbSt
176
189
  }
177
190
  }
178
191
 
192
+ // Synchronous indexed lookup for native title hook: checks ONLY whether any step in the
193
+ // active conversation currently has numeric status = 9 (WAITING, e.g. ask_question).
194
+ export function readConversationWaitingForInput(
195
+ payload,
196
+ { home = homedir(), prevDbStamp = null, prevWaitingForInput = false } = {},
197
+ ) {
198
+ const id = typeof payload === 'string' ? payload : payload?.conversation_id || payload?.session_id;
199
+ if (typeof id !== 'string' || !UUID_RE.test(id)) return false;
200
+
201
+ const dbPath = join(home, '.gemini', 'antigravity-cli', 'conversations', `${id}.db`);
202
+ if (!existsSync(dbPath)) return false;
203
+
204
+ const dbStamp = getDbVersionStamp(dbPath);
205
+ if (prevDbStamp && dbStamp && dbStamp === prevDbStamp) {
206
+ return Boolean(prevWaitingForInput);
207
+ }
208
+
209
+ const DatabaseSync = loadDatabaseSync();
210
+ if (!DatabaseSync) return false;
211
+
212
+ let db;
213
+ try {
214
+ db = new DatabaseSync(dbPath, { readOnly: true });
215
+ const waitingRow = db.prepare(`SELECT 1 AS w FROM steps WHERE status = ${STEP_STATUS_WAITING} LIMIT 1`).get();
216
+ return Boolean(waitingRow?.w);
217
+ } catch {
218
+ return false;
219
+ } finally {
220
+ try {
221
+ db?.close();
222
+ } catch {
223
+ // Ignore close errors.
224
+ }
225
+ }
226
+ }
227
+
179
228
  export function summaryDbPath(home = homedir()) {
180
229
  return join(home, '.gemini', 'antigravity-cli', 'conversation_summaries.db');
181
230
  }
package/src/telemetry.mjs CHANGED
@@ -426,6 +426,10 @@ export function recordTelemetry(
426
426
  gitRemoved: typeof git?.removed === 'number' ? git.removed : prev?.gitRemoved ?? null,
427
427
  gitCheckedAt: git?.dirtyChecked ? now : prev?.gitCheckedAt ?? null,
428
428
  dbStamp: stepTiming?.dbStamp ?? prev?.dbStamp ?? null,
429
+ dbWaitingForInput:
430
+ typeof stepTiming?.waitingForInput === 'boolean'
431
+ ? stepTiming.waitingForInput
432
+ : Boolean(prev?.dbWaitingForInput),
429
433
  summaryDbStamp: summaryTitle?.dbStamp ?? prev?.summaryDbStamp ?? null,
430
434
  summaryTitleCheckedAt: summaryTitle?.checkedAt ?? prev?.summaryTitleCheckedAt ?? null,
431
435
  agentState: sanitizeText(p.agent_state || '') || 'idle',
package/src/title.mjs CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
5
5
  import { sanitizeText } from './ansi.mjs';
6
6
  import { configDir, loadConfig } from './config.mjs';
7
7
  import { readGitInfo } from './git.mjs';
8
- import { readConversationSummaryTitle } from './step-timing.mjs';
8
+ import { readConversationSummaryTitle, readConversationWaitingForInput } from './step-timing.mjs';
9
9
  import { buildTabTitle } from './tab-title.mjs';
10
10
  import { deriveSessionId, peekSessionState, resolveSessionTitles, sessionsDir } from './telemetry.mjs';
11
11
 
@@ -111,8 +111,23 @@ export function renderNativeTitle(
111
111
  }
112
112
  }
113
113
 
114
- const effectivePayload =
115
- conversationTitle && !hasPayloadTitle ? { ...p, conversation_title: conversationTitle } : p;
114
+ const rawState = String(p?.agent_state || '').trim().toLowerCase();
115
+ const isBusyState = rawState === 'working' || rawState === 'tool_use' || rawState === 'thinking';
116
+ const waitingForInput =
117
+ p?.waiting_for_input === true ||
118
+ (isBusyState &&
119
+ p?.tool_confirmation_pending !== true &&
120
+ config.dbTiming !== false &&
121
+ readConversationWaitingForInput(p, {
122
+ home,
123
+ prevDbStamp: prev?.dbStamp ?? null,
124
+ prevWaitingForInput: Boolean(prev?.dbWaitingForInput),
125
+ }));
126
+
127
+ let effectivePayload = conversationTitle && !hasPayloadTitle ? { ...p, conversation_title: conversationTitle } : p;
128
+ if (waitingForInput && effectivePayload.waiting_for_input !== true) {
129
+ effectivePayload = { ...effectivePayload, waiting_for_input: true };
130
+ }
116
131
  const title = buildTabTitle(effectivePayload, { config, git, customTitle });
117
132
  if (touchMarker) {
118
133
  touchNativeTitleMarker(sessionId, { now, hostPid, baseDir });