agy-bar 1.0.0 → 1.0.1
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.
- package/CHANGELOG.md +9 -0
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- package/bin/agy-bar.mjs +22 -3
- package/package.json +1 -1
- package/src/statusline.mjs +29 -5
- package/src/step-timing.mjs +77 -0
- package/src/telemetry.mjs +13 -3
- package/src/title.mjs +35 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **agy-bar** are documented here.
|
|
4
4
|
|
|
5
|
+
## [1.0.1] - 2026-11-27
|
|
6
|
+
|
|
7
|
+
### Fixed & Improved
|
|
8
|
+
- **Automatic Summary Tab Titles on Brand-New Conversations (`src/step-timing.mjs`, `src/title.mjs`, `src/statusline.mjs`, `src/telemetry.mjs`, `bin/agy-bar.mjs`)**:
|
|
9
|
+
- When Antigravity CLI omits `conversation_title` from live `statusLine`/`title` JSON payloads on newly started sessions (even after AGY's background summarizer has already generated a title), `agy-bar` now falls back to reading only the current session's `title` column from local `~/.gemini/antigravity-cli/conversation_summaries.db` in `readOnly: true` mode (Node `>= 22.13`, zero chat text read, respects `dbTiming: false`).
|
|
10
|
+
- Uses `.db`/`.db-wal` `mtime` stamp caching plus a 15s recheck throttle once populated so idle and active hot paths remain near-zero overhead, emits a one-shot tab update if the initial summary lands after turn 1 goes idle, and anchors `customTitleBase` so early `agy-bar title` overrides are preserved while later `/rename` actions still supersede them cleanly.
|
|
11
|
+
- **Documentation (`README.md`, `README.zh-CN.md`)**:
|
|
12
|
+
- Updated the global rules path in the automatic topic-summarization tip to Antigravity's official global file `~/.gemini/AGENTS.md`.
|
|
13
|
+
|
|
5
14
|
## [1.0.0] - 2026-11-27
|
|
6
15
|
|
|
7
16
|
First stable release of **agy-bar** — zero-dependency statusline HUD, native AGY window/tab title hook, no-TUN local proxy launcher, 52-week token heatmap, live 3-tier pricing cache, and multi-CLI monitor for Antigravity CLI (`agy`).
|
package/README.md
CHANGED
|
@@ -83,16 +83,16 @@ Running 3–5 `agy` sessions across different repos? Open `agy-bar monitor` in a
|
|
|
83
83
|
|
|
84
84
|
### 5. Automatic Terminal Tab Titles (`●` / `● [N]` / `?` / `✓`) & Agent Summarization (`agy-bar title`)
|
|
85
85
|
|
|
86
|
-
Replaces identical `agy --dangerously-skip-permissions` tabs across Ghostty, iTerm2, Kitty, WezTerm, macOS Terminal, Windows Terminal, and VS Code using **Antigravity CLI's official `title` hook** (`settings.json` → `title`, with automatic OSC 0/2 fallback for older sessions) to show live activity state (`●` working, `● [N]` running subagents, `?` waiting for user input/confirmation, `✗` error, `✓` truly idle) + concise topic title (zero extra tokens, full macOS / Linux / Windows support):
|
|
86
|
+
Replaces identical `agy --dangerously-skip-permissions` tabs across Ghostty, iTerm2, Kitty, WezTerm, macOS Terminal, Windows Terminal, and VS Code using **Antigravity CLI's official `title` hook** (`settings.json` → `title`, with automatic OSC 0/2 fallback for older sessions) to show live activity state (`●` working, `● [N]` running subagents, `?` waiting for user input/confirmation, `✗` error, `✓` truly idle) + concise topic title (automatically picking up AGY's generated summary title even on brand-new conversations, zero extra tokens, full macOS / Linux / Windows support):
|
|
87
87
|
|
|
88
88
|

|
|
89
89
|
|
|
90
90
|
<sub>Real Ghostty tab bar: auto-synced tabs (`● agy-bar 开源状态栏`, `📊 agy-bar Token 热力图`) right next to an unmodified default `agy --dangerously-skip-per...` tab.</sub>
|
|
91
91
|
|
|
92
92
|
> **Pro Tip — Auto-summarize tab titles on topic shifts (~10 tokens, zero extra API calls)**
|
|
93
|
-
> Add this one line to your global `~/.gemini/
|
|
93
|
+
> Add this one line to your global `~/.gemini/AGENTS.md`:
|
|
94
94
|
> ```text
|
|
95
|
-
>
|
|
95
|
+
> In Antigravity CLI (`agy`) sessions, when starting a clear task or switching to a new topic in a long session, silently run `agy-bar title "<4-8 word concise topic>"` once to keep the terminal tab title up to date.
|
|
96
96
|
> ```
|
|
97
97
|
> *Ghostty tip*: prefer `agy-bar title "..."` over right-clicking **Change Title…** in Ghostty, which sets a manual `tabOverride` and blocks dynamic `●` / `✓` updates until cleared.
|
|
98
98
|
|
|
@@ -103,7 +103,7 @@ Replaces identical `agy --dangerously-skip-permissions` tabs across Ghostty, iTe
|
|
|
103
103
|
| Guarantee | How It Works |
|
|
104
104
|
| --- | --- |
|
|
105
105
|
| **100% Official `statusLine` + `title` Hooks** | Zero binary patching, zero Electron injection, zero Google/AGY private API calls, zero account credential access. Survives every AGY update cleanly. |
|
|
106
|
-
| **Read-Only Local Telemetry** | SQLite
|
|
106
|
+
| **Read-Only Local Telemetry** | SQLite scans (`Node >= 22.13`) open local AGY DBs in `readOnly: true` mode and extract **only numeric timestamps, token counts, subagent parent IDs, and the session's own `title` metadata** — never prompts or replies. |
|
|
107
107
|
| **Transparent Network Policy** | Statusline rendering itself **never touches the network**. Only an optional 24-hour background sync fetches public unauthenticated pricing JSON (`models.dev` / `LiteLLM`); run `agy-bar config set pricingAutoSync off` for strict offline mode. |
|
|
108
108
|
| **Zero-Dep Fast Hot Path** | `0` runtime dependencies, zero-subprocess idle refreshes (PID fast-path + 3s Git cache + SQLite `mtime` skip + 5-min Windows theme cache), and atomic file writes across concurrent terminals. |
|
|
109
109
|
|
|
@@ -226,7 +226,7 @@ eval "$(agy-bar uninstall --remove-skill --purge --print-cleanup)"
|
|
|
226
226
|
## Development
|
|
227
227
|
|
|
228
228
|
```sh
|
|
229
|
-
npm test # Cross-platform Node.js built-in test suite (
|
|
229
|
+
npm test # Cross-platform Node.js built-in test suite (88 tests)
|
|
230
230
|
npm run preview # Render live terminal preview
|
|
231
231
|
npm run preview:svg # Regenerate all 5 showcase SVGs in assets/
|
|
232
232
|
npm run stats # Show local usage stats
|
package/README.zh-CN.md
CHANGED
|
@@ -83,16 +83,16 @@ CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·15
|
|
|
83
83
|
|
|
84
84
|
### 5. 终端标签页标题自动同步 (`●` / `● [N]` / `?` / `✓`) 与 Agent 摘要 (`agy-bar title`)
|
|
85
85
|
|
|
86
|
-
彻底告别多开时所有标签页都叫 `agy --dangerously-skip-permissions` 的烦恼:接入 **Antigravity CLI 官方原生 `title` 接口**(`settings.json` → `title`,旧会话自动回退 OSC 0/2),在 macOS / Linux / 原生 Windows Terminal 下的 Ghostty、iTerm2、Kitty、WezTerm、Terminal.app、VS Code 中稳定同步精确状态(`●` 工作中、`● [N]` 子代理运行中、`?` 等待你确认/输入、`✗` 报错、`✓`
|
|
86
|
+
彻底告别多开时所有标签页都叫 `agy --dangerously-skip-permissions` 的烦恼:接入 **Antigravity CLI 官方原生 `title` 接口**(`settings.json` → `title`,旧会话自动回退 OSC 0/2),在 macOS / Linux / 原生 Windows Terminal 下的 Ghostty、iTerm2、Kitty、WezTerm、Terminal.app、VS Code 中稳定同步精确状态(`●` 工作中、`● [N]` 子代理运行中、`?` 等待你确认/输入、`✗` 报错、`✓` 全部完成)与精简主题(新开对话亦会自动同步 AGY 首轮概括标题,零额外 Token、无字节交错):
|
|
87
87
|
|
|
88
88
|

|
|
89
89
|
|
|
90
90
|
<sub>Ghostty 标签栏真机对比:左侧已自动同步为 `● agy-bar 开源状态栏`、`📊 agy-bar Token 热力图`,右侧为未启用前的默认 `agy --dangerously-skip-per...`。</sub>
|
|
91
91
|
|
|
92
92
|
> **进阶技巧 — 让 Agent 换话题时自动缩写标签名(仅耗 ~10 tokens,零额外 API 调用)**
|
|
93
|
-
> 在你的全局 `~/.gemini/
|
|
93
|
+
> 在你的全局 `~/.gemini/AGENTS.md` 里加上这一句即可:
|
|
94
94
|
> ```text
|
|
95
|
-
>
|
|
95
|
+
> 在 Antigravity CLI (`agy`) 终端会话中,当用户发起明确的新任务或在长对话中切换到新话题时,静默执行一次 `agy-bar title "<4~8字中文简短主题>"` 更新终端标签页标题。
|
|
96
96
|
> ```
|
|
97
97
|
> *Ghostty 小贴士*:自定义标签名请优先使用 `agy-bar title "..."`,不要用 Ghostty 右键 **Change Title…**(会写入 `tabOverride` 锁死标签并屏蔽后续 `●` / `✓` 自动更新,清空留空回车即可解锁)。
|
|
98
98
|
|
|
@@ -103,7 +103,7 @@ CTX ▮▮▮▯▯▯▯▯ 42.6% (1.0M) │ CACHE 88%·3m42s │ TTFT 1.9s·15
|
|
|
103
103
|
| 承诺 | 实现机制 |
|
|
104
104
|
| --- | --- |
|
|
105
105
|
| **100% 官方原生 `statusLine` + `title` 接口** | 不修改/不注入任何客户端二进制,不调用任何 Google/AGY 私有接口,不接触账号凭据;官方任意升级不失效、零封号风险。 |
|
|
106
|
-
|
|
|
106
|
+
| **只读本地元数据遥测** | SQLite 扫描(`Node >= 22.13`)全程 `readOnly: true`,**仅提取数值时间戳、Token 计数、子代理父子 ID 与当前会话 `title` 元数据**,绝不读取聊天正文。 |
|
|
107
107
|
| **透明联网策略** | 底栏渲染热路径**完全不联网**;仅默认每 24 小时后台异步拉取一次公开免鉴权的 `models.dev` / `LiteLLM` 参考单价,随时可 `agy-bar config set pricingAutoSync off` 严格离线。 |
|
|
108
108
|
| **零依赖极致流畅** | `0` 第三方依赖,空闲刷新零子进程(PID 快速路径 + 3s Git 缓存 + SQLite `mtime` 跳过 + 5 分钟 Windows 主题缓存),多终端并发采用原子写防文件损坏。 |
|
|
109
109
|
|
|
@@ -226,7 +226,7 @@ eval "$(agy-bar uninstall --remove-skill --purge --print-cleanup)"
|
|
|
226
226
|
## 本地开发
|
|
227
227
|
|
|
228
228
|
```sh
|
|
229
|
-
npm test # 运行内置单元测试(
|
|
229
|
+
npm test # 运行内置单元测试(88 项,macOS / Linux / Windows 三端 CI 验证)
|
|
230
230
|
npm run preview # 终端实时预览
|
|
231
231
|
npm run preview:svg # 重新生成 assets/ 下全部 5 张展示 SVG
|
|
232
232
|
npm run stats # 查看本机统计
|
package/bin/agy-bar.mjs
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
} from '../src/shell-hook.mjs';
|
|
65
65
|
import { aggregateStats, formatStatsReport, HEATMAP_PALETTE_NAMES, PERIOD_NAMES, readLedger, SOURCE_NAMES } from '../src/stats.mjs';
|
|
66
66
|
import { runStatusline } from '../src/statusline.mjs';
|
|
67
|
+
import { readConversationSummaryTitle } from '../src/step-timing.mjs';
|
|
67
68
|
import { buildTabTitle, resolveTerminalTarget, writeOscTitle } from '../src/tab-title.mjs';
|
|
68
69
|
import {
|
|
69
70
|
armPayloadCapture,
|
|
@@ -452,13 +453,22 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
452
453
|
return;
|
|
453
454
|
}
|
|
454
455
|
const nativeTitleActive = isNativeTitleActive(target.sessionId, { hostPid: hostPid ?? process.ppid });
|
|
456
|
+
const resolvedConvTitle =
|
|
457
|
+
target.conversationTitle ||
|
|
458
|
+
(cfg.dbTiming !== false
|
|
459
|
+
? readConversationSummaryTitle(target.sessionId, {
|
|
460
|
+
prevDbStamp: target.summaryDbStamp ?? null,
|
|
461
|
+
prevTitle: target.conversationTitle ?? null,
|
|
462
|
+
recheckIntervalMs: 0,
|
|
463
|
+
})?.title || null
|
|
464
|
+
: null);
|
|
455
465
|
const computedTitle = buildTabTitle(
|
|
456
466
|
{
|
|
457
467
|
agent_state: target.agentState,
|
|
458
468
|
subagents: target.runningSubagents || 0,
|
|
459
469
|
task_count: target.runningTasks || 0,
|
|
460
470
|
tool_confirmation_pending: Boolean(target.toolConfirmationPending),
|
|
461
|
-
conversation_title:
|
|
471
|
+
conversation_title: resolvedConvTitle,
|
|
462
472
|
cwd: target.cwd,
|
|
463
473
|
},
|
|
464
474
|
{
|
|
@@ -475,7 +485,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
475
485
|
nativeTitleActive,
|
|
476
486
|
source: cfg.tabTitleSource,
|
|
477
487
|
customTitle: target.customTitle || null,
|
|
478
|
-
conversationTitle:
|
|
488
|
+
conversationTitle: resolvedConvTitle,
|
|
479
489
|
activeTabTitle: (nativeTitleActive ? computedTitle : target.lastTabTitle || computedTitle) || null,
|
|
480
490
|
},
|
|
481
491
|
null,
|
|
@@ -491,13 +501,22 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
491
501
|
hostPid,
|
|
492
502
|
clear: Boolean(flags.clear),
|
|
493
503
|
});
|
|
504
|
+
const resolvedConvTitle =
|
|
505
|
+
updated.conversationTitle ||
|
|
506
|
+
(cfg.dbTiming !== false
|
|
507
|
+
? readConversationSummaryTitle(updated.sessionId, {
|
|
508
|
+
prevDbStamp: updated.summaryDbStamp ?? null,
|
|
509
|
+
prevTitle: updated.conversationTitle ?? null,
|
|
510
|
+
recheckIntervalMs: 0,
|
|
511
|
+
})?.title || null
|
|
512
|
+
: null);
|
|
494
513
|
const renderedTitle = buildTabTitle(
|
|
495
514
|
{
|
|
496
515
|
agent_state: updated.agentState,
|
|
497
516
|
subagents: updated.runningSubagents || 0,
|
|
498
517
|
task_count: updated.runningTasks || 0,
|
|
499
518
|
tool_confirmation_pending: Boolean(updated.toolConfirmationPending),
|
|
500
|
-
conversation_title:
|
|
519
|
+
conversation_title: resolvedConvTitle,
|
|
501
520
|
cwd: updated.cwd,
|
|
502
521
|
},
|
|
503
522
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-bar",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Zero-dependency terminal statusline, no-TUN proxy launcher, exact TTFT & tok/s speed, 5-min cache TTL countdown, live pricing cache, automatic tab titles, 52-week token heatmap, and multi-CLI monitor for Antigravity CLI (agy).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/statusline.mjs
CHANGED
|
@@ -2,13 +2,14 @@ import { realpathSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { classifyAgentActivity, extractNativeCostUsd } from './agent-state.mjs';
|
|
5
|
+
import { sanitizeText } from './ansi.mjs';
|
|
5
6
|
import { loadConfig } from './config.mjs';
|
|
6
7
|
import { readGitInfo } from './git.mjs';
|
|
7
8
|
import { getOrRefreshUsageSummary } from './history-scan.mjs';
|
|
8
9
|
import { maybeTriggerBackgroundPricingSync } from './pricing-sync.mjs';
|
|
9
10
|
import { extractAccountKey, syncSharedQuota } from './quota-sync.mjs';
|
|
10
11
|
import { renderFallback, renderStatusline } from './render.mjs';
|
|
11
|
-
import { readLatestStepTiming } from './step-timing.mjs';
|
|
12
|
+
import { readConversationSummaryTitle, readLatestStepTiming } from './step-timing.mjs';
|
|
12
13
|
import { syncTabTitle } from './tab-title.mjs';
|
|
13
14
|
import { deriveSessionId, maybeCaptureRedactedPayload, peekSessionState, recordTelemetry, resolveSessionTitles } from './telemetry.mjs';
|
|
14
15
|
import { isNativeTitleActive } from './title.mjs';
|
|
@@ -57,14 +58,35 @@ export async function runStatusline({ stdin = process.stdin, stdout = process.st
|
|
|
57
58
|
})
|
|
58
59
|
: null;
|
|
59
60
|
|
|
61
|
+
const hasPayloadTitle = Boolean(sanitizeText(effectivePayload?.conversation_title || ''));
|
|
62
|
+
const summaryTitle =
|
|
63
|
+
config.tabTitle && !hasPayloadTitle && config.tabTitleSource !== 'dir' && config.dbTiming !== false
|
|
64
|
+
? readConversationSummaryTitle(effectivePayload, {
|
|
65
|
+
prevDbStamp: prevSession?.summaryDbStamp ?? null,
|
|
66
|
+
prevTitle: prevSession?.conversationTitle ?? null,
|
|
67
|
+
prevCheckedAt: prevSession?.summaryTitleCheckedAt ?? null,
|
|
68
|
+
now,
|
|
69
|
+
recheckIntervalMs: 15_000,
|
|
70
|
+
})
|
|
71
|
+
: null;
|
|
72
|
+
const { conversationTitle, customTitle } = resolveSessionTitles(effectivePayload, prevSession, {
|
|
73
|
+
dbTitle: summaryTitle?.title ?? null,
|
|
74
|
+
});
|
|
75
|
+
const payloadForTitle =
|
|
76
|
+
conversationTitle && !hasPayloadTitle
|
|
77
|
+
? { ...effectivePayload, conversation_title: conversationTitle }
|
|
78
|
+
: effectivePayload;
|
|
79
|
+
|
|
60
80
|
// Sync terminal tab title synchronously before async DB scans when AGY's native
|
|
61
|
-
// `settings.json.title` hook is not already driving this session's title
|
|
81
|
+
// `settings.json.title` hook is not already driving this session's title, OR as a
|
|
82
|
+
// one-shot push the moment a brand-new conversation's initial summary title lands.
|
|
62
83
|
let tabSync = null;
|
|
63
84
|
if (!plain && config.tabTitle) {
|
|
64
85
|
const sessionIdForTitle = deriveSessionId(effectivePayload);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
86
|
+
const nativeActive = isNativeTitleActive(sessionIdForTitle, { now, hostPid: process.ppid });
|
|
87
|
+
const newlyDiscoveredDbTitle = Boolean(!hasPayloadTitle && !prevSession?.conversationTitle && conversationTitle && !customTitle);
|
|
88
|
+
if (!nativeActive || newlyDiscoveredDbTitle) {
|
|
89
|
+
tabSync = syncTabTitle(payloadForTitle, {
|
|
68
90
|
config,
|
|
69
91
|
git,
|
|
70
92
|
customTitle,
|
|
@@ -72,6 +94,7 @@ export async function runStatusline({ stdin = process.stdin, stdout = process.st
|
|
|
72
94
|
prevTabHostPid: prevSession?.lastTabHostPid ?? null,
|
|
73
95
|
prevTabTty: prevSession?.lastTabTty || null,
|
|
74
96
|
hostPidHint: process.ppid,
|
|
97
|
+
force: nativeActive && newlyDiscoveredDbTitle,
|
|
75
98
|
resolveOpts: { env },
|
|
76
99
|
});
|
|
77
100
|
}
|
|
@@ -84,6 +107,7 @@ export async function runStatusline({ stdin = process.stdin, stdout = process.st
|
|
|
84
107
|
now,
|
|
85
108
|
git,
|
|
86
109
|
stepTiming,
|
|
110
|
+
summaryTitle,
|
|
87
111
|
prevSession,
|
|
88
112
|
tabSync,
|
|
89
113
|
cacheTtlSec: config.cacheTtlSec,
|
package/src/step-timing.mjs
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { existsSync, statSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
4
|
import { join } from 'node:path';
|
|
4
5
|
|
|
5
6
|
const UUID_RE = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
|
|
6
7
|
|
|
8
|
+
let cachedDatabaseSync;
|
|
9
|
+
function loadDatabaseSync() {
|
|
10
|
+
if (cachedDatabaseSync !== undefined) return cachedDatabaseSync;
|
|
11
|
+
try {
|
|
12
|
+
const req = createRequire(import.meta.url);
|
|
13
|
+
cachedDatabaseSync = req('node:sqlite').DatabaseSync || null;
|
|
14
|
+
} catch {
|
|
15
|
+
cachedDatabaseSync = null;
|
|
16
|
+
}
|
|
17
|
+
return cachedDatabaseSync;
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
export function decodePbFields(buf) {
|
|
8
21
|
const b = Buffer.isBuffer(buf) ? buf : Buffer.from(buf || []);
|
|
9
22
|
let offset = 0;
|
|
@@ -162,3 +175,67 @@ export async function readLatestStepTiming(payload, { home = homedir(), prevDbSt
|
|
|
162
175
|
}
|
|
163
176
|
}
|
|
164
177
|
}
|
|
178
|
+
|
|
179
|
+
export function summaryDbPath(home = homedir()) {
|
|
180
|
+
return join(home, '.gemini', 'antigravity-cli', 'conversation_summaries.db');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Reads ONLY the generated title column for the active conversation from AGY's local
|
|
184
|
+
// conversation_summaries.db (never reads previews, prompts, or replies) when AGY CLI
|
|
185
|
+
// omits conversation_title from live payloads on brand-new conversations.
|
|
186
|
+
export function readConversationSummaryTitle(
|
|
187
|
+
payload,
|
|
188
|
+
{
|
|
189
|
+
home = homedir(),
|
|
190
|
+
dbPath = null,
|
|
191
|
+
prevDbStamp = null,
|
|
192
|
+
prevTitle = null,
|
|
193
|
+
prevCheckedAt = null,
|
|
194
|
+
now = Date.now(),
|
|
195
|
+
recheckIntervalMs = 15_000,
|
|
196
|
+
} = {},
|
|
197
|
+
) {
|
|
198
|
+
const id = typeof payload === 'string' ? payload : payload?.conversation_id || payload?.session_id;
|
|
199
|
+
if (typeof id !== 'string' || !UUID_RE.test(id)) return null;
|
|
200
|
+
|
|
201
|
+
const targetDb = dbPath || summaryDbPath(home);
|
|
202
|
+
if (!existsSync(targetDb)) return null;
|
|
203
|
+
|
|
204
|
+
const dbStamp = getDbVersionStamp(targetDb);
|
|
205
|
+
if (prevDbStamp && dbStamp && dbStamp === prevDbStamp) {
|
|
206
|
+
return { title: prevTitle || null, unchanged: true, dbStamp, checkedAt: prevCheckedAt ?? now };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Once we already have a title for this session, throttle re-checks while other chats write to the shared WAL.
|
|
210
|
+
if (
|
|
211
|
+
prevTitle &&
|
|
212
|
+
recheckIntervalMs > 0 &&
|
|
213
|
+
typeof prevCheckedAt === 'number' &&
|
|
214
|
+
now >= prevCheckedAt &&
|
|
215
|
+
now - prevCheckedAt < recheckIntervalMs
|
|
216
|
+
) {
|
|
217
|
+
return { title: prevTitle, unchanged: true, dbStamp: prevDbStamp || dbStamp, checkedAt: prevCheckedAt };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const DatabaseSync = loadDatabaseSync();
|
|
221
|
+
if (!DatabaseSync) return null;
|
|
222
|
+
|
|
223
|
+
let db;
|
|
224
|
+
try {
|
|
225
|
+
db = new DatabaseSync(targetDb, { readOnly: true });
|
|
226
|
+
const row = db
|
|
227
|
+
.prepare('SELECT title FROM conversation_summaries WHERE conversation_id = ? LIMIT 1')
|
|
228
|
+
.get(id);
|
|
229
|
+
const raw = typeof row?.title === 'string' ? row.title.trim() : '';
|
|
230
|
+
return { title: raw || null, unchanged: false, dbStamp, checkedAt: now };
|
|
231
|
+
} catch {
|
|
232
|
+
// Gracefully fall back on Node < 22.13, locked DBs, or schema changes.
|
|
233
|
+
return null;
|
|
234
|
+
} finally {
|
|
235
|
+
try {
|
|
236
|
+
db?.close();
|
|
237
|
+
} catch {
|
|
238
|
+
// Ignore close errors.
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
package/src/telemetry.mjs
CHANGED
|
@@ -158,8 +158,10 @@ function pickQuotaSnapshot(quota) {
|
|
|
158
158
|
return Object.keys(out).length > 0 ? out : null;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
export function resolveSessionTitles(payload = {}, prev = null) {
|
|
162
|
-
const
|
|
161
|
+
export function resolveSessionTitles(payload = {}, prev = null, { dbTitle = null } = {}) {
|
|
162
|
+
const payloadTitle = sanitizeText(payload?.conversation_title || '') || null;
|
|
163
|
+
const fallbackDbTitle = sanitizeText(dbTitle || '') || null;
|
|
164
|
+
const conversationTitle = payloadTitle || fallbackDbTitle || prev?.conversationTitle || null;
|
|
163
165
|
// If user explicitly renamed the conversation via /rename (conversation_title changed),
|
|
164
166
|
// clear any older custom tab override automatically.
|
|
165
167
|
let customTitle = prev?.customTitle || null;
|
|
@@ -167,6 +169,9 @@ export function resolveSessionTitles(payload = {}, prev = null) {
|
|
|
167
169
|
if (customTitle && conversationTitle && customTitleBase && conversationTitle !== customTitleBase) {
|
|
168
170
|
customTitle = null;
|
|
169
171
|
customTitleBase = null;
|
|
172
|
+
} else if (customTitle && !customTitleBase && !payloadTitle && fallbackDbTitle) {
|
|
173
|
+
// Anchor customTitleBase once AGY's initial background summary lands so a later /rename still supersedes it.
|
|
174
|
+
customTitleBase = fallbackDbTitle;
|
|
170
175
|
}
|
|
171
176
|
return { conversationTitle, customTitle, customTitleBase };
|
|
172
177
|
}
|
|
@@ -177,6 +182,7 @@ export function recordTelemetry(
|
|
|
177
182
|
now = Date.now(),
|
|
178
183
|
git = null,
|
|
179
184
|
stepTiming = null,
|
|
185
|
+
summaryTitle = null,
|
|
180
186
|
prevSession = undefined,
|
|
181
187
|
tabSync = null,
|
|
182
188
|
baseDir = configDir(homedir()),
|
|
@@ -390,7 +396,9 @@ export function recordTelemetry(
|
|
|
390
396
|
const cacheRemainingSec =
|
|
391
397
|
lastActivityAt !== null ? Math.max(0, Math.round((cacheTtlMs - (now - lastActivityAt)) / 1000)) : null;
|
|
392
398
|
|
|
393
|
-
const { conversationTitle, customTitle, customTitleBase } = resolveSessionTitles(p, prev
|
|
399
|
+
const { conversationTitle, customTitle, customTitleBase } = resolveSessionTitles(p, prev, {
|
|
400
|
+
dbTitle: summaryTitle?.title ?? null,
|
|
401
|
+
});
|
|
394
402
|
const tabWritten = Boolean(tabSync?.written && tabSync.title);
|
|
395
403
|
const nextTabTitle = tabWritten ? tabSync.title : prev?.lastTabTitle || null;
|
|
396
404
|
const nextTabHostPid = tabWritten
|
|
@@ -418,6 +426,8 @@ export function recordTelemetry(
|
|
|
418
426
|
gitRemoved: typeof git?.removed === 'number' ? git.removed : prev?.gitRemoved ?? null,
|
|
419
427
|
gitCheckedAt: git?.dirtyChecked ? now : prev?.gitCheckedAt ?? null,
|
|
420
428
|
dbStamp: stepTiming?.dbStamp ?? prev?.dbStamp ?? null,
|
|
429
|
+
summaryDbStamp: summaryTitle?.dbStamp ?? prev?.summaryDbStamp ?? null,
|
|
430
|
+
summaryTitleCheckedAt: summaryTitle?.checkedAt ?? prev?.summaryTitleCheckedAt ?? null,
|
|
421
431
|
agentState: sanitizeText(p.agent_state || '') || 'idle',
|
|
422
432
|
activityKind: activity.kind,
|
|
423
433
|
needsAttention: activity.needsAttention,
|
package/src/title.mjs
CHANGED
|
@@ -5,6 +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
9
|
import { buildTabTitle } from './tab-title.mjs';
|
|
9
10
|
import { deriveSessionId, peekSessionState, resolveSessionTitles, sessionsDir } from './telemetry.mjs';
|
|
10
11
|
|
|
@@ -65,19 +66,41 @@ export function isNativeTitleActive(
|
|
|
65
66
|
|
|
66
67
|
export function renderNativeTitle(
|
|
67
68
|
payload = {},
|
|
68
|
-
{
|
|
69
|
+
{
|
|
70
|
+
config = loadConfig(),
|
|
71
|
+
prevSession = undefined,
|
|
72
|
+
home = homedir(),
|
|
73
|
+
baseDir = configDir(home),
|
|
74
|
+
summaryDbPath = null,
|
|
75
|
+
now = Date.now(),
|
|
76
|
+
hostPid = process.ppid,
|
|
77
|
+
touchMarker = true,
|
|
78
|
+
} = {},
|
|
69
79
|
) {
|
|
70
80
|
if (config.tabTitle === false) return '';
|
|
71
81
|
|
|
72
82
|
const p = payload && typeof payload === 'object' ? payload : {};
|
|
73
83
|
const sessionId = deriveSessionId(p);
|
|
74
84
|
const prev = prevSession !== undefined ? prevSession : peekSessionState(p, { baseDir });
|
|
75
|
-
const
|
|
85
|
+
const hasPayloadTitle = Boolean(sanitizeText(p?.conversation_title || ''));
|
|
86
|
+
const summaryLookup =
|
|
87
|
+
!hasPayloadTitle && config.tabTitleSource !== 'dir' && config.dbTiming !== false
|
|
88
|
+
? readConversationSummaryTitle(p, {
|
|
89
|
+
home,
|
|
90
|
+
dbPath: summaryDbPath,
|
|
91
|
+
prevDbStamp: prev?.summaryDbStamp ?? null,
|
|
92
|
+
prevTitle: prev?.conversationTitle ?? null,
|
|
93
|
+
prevCheckedAt: prev?.summaryTitleCheckedAt ?? null,
|
|
94
|
+
now,
|
|
95
|
+
recheckIntervalMs: 5_000,
|
|
96
|
+
})
|
|
97
|
+
: null;
|
|
98
|
+
const { conversationTitle, customTitle } = resolveSessionTitles(p, prev, {
|
|
99
|
+
dbTitle: summaryLookup?.title ?? null,
|
|
100
|
+
});
|
|
76
101
|
|
|
77
102
|
const cwd = p?.workspace?.current_dir || p?.cwd || prev?.cwd || null;
|
|
78
|
-
const needsGit =
|
|
79
|
-
config.tabTitleSource === 'dir' ||
|
|
80
|
-
(!customTitle && !sanitizeText(p?.conversation_title || ''));
|
|
103
|
+
const needsGit = config.tabTitleSource === 'dir' || (!customTitle && !conversationTitle);
|
|
81
104
|
let git = null;
|
|
82
105
|
if (needsGit && cwd) {
|
|
83
106
|
if (prev && prev.cwd === cwd && prev.branch) {
|
|
@@ -88,7 +111,9 @@ export function renderNativeTitle(
|
|
|
88
111
|
}
|
|
89
112
|
}
|
|
90
113
|
|
|
91
|
-
const
|
|
114
|
+
const effectivePayload =
|
|
115
|
+
conversationTitle && !hasPayloadTitle ? { ...p, conversation_title: conversationTitle } : p;
|
|
116
|
+
const title = buildTabTitle(effectivePayload, { config, git, customTitle });
|
|
92
117
|
if (touchMarker) {
|
|
93
118
|
touchNativeTitleMarker(sessionId, { now, hostPid, baseDir });
|
|
94
119
|
}
|
|
@@ -98,7 +123,9 @@ export function renderNativeTitle(
|
|
|
98
123
|
export async function runTitleCommand({
|
|
99
124
|
stdin = process.stdin,
|
|
100
125
|
stdout = process.stdout,
|
|
101
|
-
|
|
126
|
+
home = homedir(),
|
|
127
|
+
baseDir = configDir(home),
|
|
128
|
+
summaryDbPath = null,
|
|
102
129
|
config = undefined,
|
|
103
130
|
now = Date.now(),
|
|
104
131
|
hostPid = process.ppid,
|
|
@@ -111,7 +138,7 @@ export async function runTitleCommand({
|
|
|
111
138
|
try {
|
|
112
139
|
const payload = raw.trim() ? JSON.parse(raw) : {};
|
|
113
140
|
const cfg = config ?? loadConfig();
|
|
114
|
-
const title = renderNativeTitle(payload, { config: cfg, baseDir, now, hostPid });
|
|
141
|
+
const title = renderNativeTitle(payload, { config: cfg, home, baseDir, summaryDbPath, now, hostPid });
|
|
115
142
|
if (title) {
|
|
116
143
|
stdout.write(`${title}\n`);
|
|
117
144
|
}
|