@sejuneoh/aitop 0.42.1 → 0.43.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.
package/README.md CHANGED
@@ -147,6 +147,7 @@ Subagents show as `├─` rows under their session, on the live screen.
147
147
  - A dim `stalled?` appears when a working subagent's log has not changed for 3 minutes. It is only a guess.
148
148
  - While it runs a tool that can be slow, the limit is 10 minutes.
149
149
  - When an Antigravity subagent waits for your approval, its parent row waits too, as `<agent>: <tool>`.
150
+ - Antigravity `/swarm` workers (conversations like `@fix-1`, `@verifier`) show under the coordinator as subagents, with their cost added. A parent id wins; without one, a row is grouped only when a conversation whose id equals its `group_id` (the coordinator) is listed. Preview: based on the official docs, not yet checked against real swarm logs.
150
151
  - A `claude -p` run started from a Claude session (by its process, or from `~/.claude/jobs/<id>/` once ended) shows as a `-p` row under that session, with its cost added; one with no parent (cron) stays on top marked `auto` and never counts as waiting for you.
151
152
  - If the parent session stays open for more than 24 hours, `claude -p` runs that ended before that are left out of its total.
152
153
 
@@ -684,6 +685,8 @@ The UI follows your locale: English by default, Korean when the locale starts wi
684
685
  - Sessions that run in the cloud or on another host (Claude Code on the web/`--cloud`, Cowork cloud tasks, Codex cloud tasks, Antigravity `--remote-agent`, SSH hosts) leave no history on this machine, so aitop can't show them.
685
686
  - SSH hosts you can reach show up with [`--remote`](#remote-hosts-and-wsl-distros), if aitop is installed there.
686
687
  - Remote Control sessions run locally and do show up.
688
+ - Codex app and VS Code extension sessions (one `codex app-server` process for many sessions) are paired by the logs that process holds open on Linux; elsewhere an app or IDE session counts as running while it was written after the server started and in the last 10 minutes. The detail panel and `--json` (`origin`: app, ide or cli, plus `originator`) show where a session came from.
689
+ - An app session is told apart by `source: vscode` and an `originator` containing "Desktop". The desktop app's real `originator` value is not confirmed yet; if it differs, the session shows as IDE with the raw value in brackets.
687
690
 
688
691
  ## How it differs from similar tools
689
692
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sejuneoh/aitop",
3
- "version": "0.42.1",
3
+ "version": "0.43.0",
4
4
  "description": "터미널에서 Claude Code · Codex · Antigravity · Gemini 세션과 토큰을 실시간으로 보는 읽기 전용 모니터",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/json.mjs CHANGED
@@ -70,6 +70,9 @@ export function toJson(data, version = null, opts = {}) {
70
70
  entrypoint: s.entrypoint ?? null,
71
71
  // 기록이 온 곳. Antigravity(tool 'gemini' 이고 기록이 있는 세션)만 'cli'(agy CLI) 또는 'app'(데스크톱 앱), 나머지는 null (#303).
72
72
  source: s.source ?? null,
73
+ // Codex 세션이 열린 곳 (#306): 'app'(Codex 앱) · 'ide'(VS Code 등 확장) · 'cli', originator 는 기록의 원래 값. Codex 밖은 null.
74
+ origin: s.origin ?? null,
75
+ originator: s.originator ?? null,
73
76
  auto: Boolean(s.auto),
74
77
  pid: s.pid ?? null,
75
78
  live: Boolean(s.live),
package/src/procs.mjs CHANGED
@@ -180,9 +180,39 @@ export function findProcesses(match) {
180
180
  // Windows 목록기를 쓰는 동안(테스트가 끼운 것 포함)은 Windows 규칙으로 읽는다.
181
181
  const base = (p) => exeName(p, win ? 'win32' : process.platform);
182
182
 
183
- // `codex` 는 node 스크립트(…/bin/codex.js)이거나 네이티브 바이너리(codex-*)로 뜬다.
183
+ // Codex 가 띄우는 보조 실행 파일. 같은 바이너리를 이 이름(arg0 링크)으로 다시 부르는 것이라 세션이 아니다 (#306).
184
+ // 예: codex-linux-sandbox (Linux 샌드박스), codex-windows-sandbox-setup·codex-command-runner (Windows 샌드박스).
185
+ const CODEX_HELPER = /sandbox|^codex-(command-runner|execve-wrapper|responses-api-proxy)$/;
186
+
187
+ // `codex` 는 node 스크립트(…/bin/codex.js)이거나 네이티브 바이너리(codex-<플랫폼>, 예: codex-aarch64-apple-darwin)로 뜬다.
188
+ const isCodexExe = (a) => {
189
+ const b = base(a);
190
+ return /^codex(\.js)?$/.test(b) || (/^codex-[\w-]+$/.test(b) && !CODEX_HELPER.test(b));
191
+ };
192
+
184
193
  export function isCodex(argv) {
185
- return argv.slice(0, 2).some((a) => /^codex(\.js)?$/.test(base(a)) || /^codex-[\w-]+$/.test(base(a)));
194
+ return argv.slice(0, 2).some(isCodexExe);
195
+ }
196
+
197
+ // 값을 따로 받는 codex 전역 옵션 (-c key=value 등). 하위 명령 자리를 셀 때 그 값은 건너뛴다.
198
+ const CODEX_VALUE_FLAGS = new Set(['-c', '--config', '--enable', '--disable', '-p', '--profile', '-m', '--model', '-C', '--cd', '-s', '--sandbox', '-a', '--ask-for-approval', '-i', '--image', '--add-dir', '--local-provider']);
199
+
200
+ // Codex 앱(ChatGPT Desktop)·VS Code 확장이 띄우는 `codex app-server`. 한 프로세스가 여러 세션을 돌리고,
201
+ // 프로세스의 작업 폴더는 세션 폴더와 상관이 없다 (#306).
202
+ // 실행 파일(codex, node …/codex.js) 뒤 옵션이 아닌 첫 인자가 app-server 일 때만 맞다. `--` 뒤는 지시 글이라 하위 명령이 아니다.
203
+ export function isCodexAppServer(argv) {
204
+ const at = argv.slice(0, 2).findIndex(isCodexExe);
205
+ if (at < 0) return false;
206
+ for (let i = at + 1; i < argv.length; i++) {
207
+ const a = argv[i];
208
+ if (a === '--') return false;
209
+ if (a.startsWith('-')) {
210
+ if (CODEX_VALUE_FLAGS.has(a)) i++;
211
+ continue;
212
+ }
213
+ return a === 'app-server';
214
+ }
215
+ return false;
186
216
  }
187
217
 
188
218
  export function isGemini(argv) {
package/src/remote.mjs CHANGED
@@ -72,6 +72,7 @@ const STATUSES = new Set(['waiting', 'busy', 'shell', 'live', 'idle', 'ended']);
72
72
  const MEMBER_STATUSES = new Set(['busy', 'idle', 'waiting', 'done']);
73
73
  const STOP_KINDS = new Set(['auth', 'network', 'api']);
74
74
  const SOURCES = new Set(['cli', 'app']);
75
+ const ORIGINS = new Set(['app', 'ide', 'cli']);
75
76
 
76
77
  export function cleanStr(v, max = STR_MAX) {
77
78
  if (typeof v !== 'string') return null;
@@ -189,6 +190,9 @@ export function cleanSession(raw, host) {
189
190
  kind: cleanStr(o.kind, 40),
190
191
  entrypoint: cleanStr(o.entrypoint, 40),
191
192
  source: SOURCES.has(o.source) ? o.source : null,
193
+ // Codex 세션이 열린 곳과 originator 원래 값 (#306).
194
+ origin: ORIGINS.has(o.origin) ? o.origin : null,
195
+ originator: cleanStr(o.originator, 40),
192
196
  auto: o.auto === true,
193
197
  live: o.live === true,
194
198
  status,
@@ -617,14 +617,20 @@ function readSummaries(root = AGY_ROOT, source = 'cli') {
617
617
  try {
618
618
  db = openReadOnly(path);
619
619
  if (!db) return [];
620
- const rows = db
621
- .prepare(
622
- `select conversation_id id, title, step_count steps, last_modified_time modified, workspace_uris ws, status,
623
- agent_name agent, parent_conversation_id parent, not_fully_idle busy, killed
624
- from conversation_summaries order by last_modified_time desc limit 500`,
625
- )
626
- .all()
627
- .map((r) => ({ ...r, cwd: cwdOf(r.ws), updatedAt: parseTime(r.modified), running: r.status === RUNNING || Boolean(r.busy), root, source }));
620
+ // group_id 는 새 기록에만 있는 열이다. 없는 열을 고르면 select 전체가 실패해 목록이 통째로 비므로, 있을 때만 고른다.
621
+ // 열 확인은 서명이 바뀌어 다시 읽을 때만 한다 (서명이 같으면 위에서 지난 목록을 쓴다).
622
+ const cols = new Set(db.prepare('pragma table_info(conversation_summaries)').all().map((c) => c.name));
623
+ const group = cols.has('group_id') ? 'group_id' : "''";
624
+ const rows = groupRows(
625
+ db
626
+ .prepare(
627
+ `select conversation_id id, title, step_count steps, last_modified_time modified, workspace_uris ws, status,
628
+ agent_name agent, parent_conversation_id parent, not_fully_idle busy, killed, ${group} grp
629
+ from conversation_summaries order by last_modified_time desc limit 500`,
630
+ )
631
+ .all()
632
+ .map((r) => ({ ...r, cwd: cwdOf(r.ws), updatedAt: parseTime(r.modified), running: r.status === RUNNING || Boolean(r.busy), root, source })),
633
+ );
628
634
  if (sigOf(path, false) === mainSig) summaryCache.set(root, (summaries = { sig, rows }));
629
635
  } catch (e) {
630
636
  debugIo('agy', 'conversation_summaries read failed', e, path);
@@ -635,6 +641,30 @@ function readSummaries(root = AGY_ROOT, source = 'cli') {
635
641
  return summaries.rows;
636
642
  }
637
643
 
644
+ // swarm 워커 묶기 (#334, 미리 보기). 공식 문서는 `/swarm` 이 지금 대화를 조정자로 바꾸고 워커마다 대화를 따로 만든다고만 한다.
645
+ // 워커가 어느 열을 채우는지는 실제 기록으로 확인하지 못했다. 그래서 부모 id 가 있으면 지금처럼 부모를 따르고(부모가 이긴다),
646
+ // 부모 id 가 비었는데 group_id 가 있는 줄은 id 가 그 group_id 와 같은 줄(조정자 대화)이 목록에 있을 때만 그 아래 서브에이전트로 붙인다.
647
+ // 그런 줄이 없으면 묶음의 줄을 모두 지금처럼 최상위로 둔다. group_id 가 swarm 말고 다른 뜻(작업 폴더 등)으로 채워져도
648
+ // 상관없는 대화를 한 줄 아래 접어 숨기지 않기 위해서다. 조정자 자신의 부모 사슬은 그대로 따른다.
649
+ // 묶인 줄은 parent 에 조정자 id 를 넣어 rootOf·matchLive·appLive·collectAgy 가 기존 서브에이전트와 똑같이 다룬다.
650
+ // 조정자의 부모 사슬에 그 줄이 들어 있으면 고리가 생기므로 그 줄은 그대로 둔다. battle·winner 는 다루지 않는다.
651
+ export function groupRows(rows) {
652
+ const groups = new Map();
653
+ for (const r of rows) if (!r.parent && r.grp) groups.set(r.grp, [...(groups.get(r.grp) ?? []), r]);
654
+ if (!groups.size) return rows;
655
+ const byId = new Map(rows.map((r) => [r.id, r]));
656
+ for (const [gid, members] of groups) {
657
+ const rep = byId.get(gid);
658
+ if (!rep) continue;
659
+ // 조정자의 부모 사슬 (고리 막기용). 원래 부모 id 와 앞선 묶음이 이 함수에서 바꿔 넣은 부모를 함께 따라간다.
660
+ // 바꿔 넣은 부모까지 따라가야 묶음이 서로 엇갈려도 고리가 생기지 않는다.
661
+ const chain = new Set();
662
+ for (let cur = rep, i = 0; cur && i < 10; i++, cur = byId.get(cur.parent)) chain.add(cur.id);
663
+ for (const r of members) if (r !== rep && !chain.has(r.id)) r.parent = rep.id;
664
+ }
665
+ return rows;
666
+ }
667
+
638
668
  // 열린 파일 경로에서 대화 id 를 꺼낸다 (presence/<id>.lock, conversations/<id>.db[-wal|-shm]).
639
669
  // root 는 agyRoot() 로 바꾼 경로여야 한다.
640
670
  export function idFromPath(p, root = AGY_ROOT) {
@@ -5,7 +5,7 @@ import { readdirSync, statSync, existsSync, realpathSync, openSync, readSync, cl
5
5
  import { join, basename } from 'node:path';
6
6
  import { JsonlTail } from '../tail.mjs';
7
7
  import { loadCache, markDirty } from '../cache.mjs';
8
- import { canListProcesses, findProcesses, isCodex, openFiles, processStart } from '../procs.mjs';
8
+ import { canListProcesses, findProcesses, isCodex, isCodexAppServer, openFiles, processStart } from '../procs.mjs';
9
9
  import { addActivity, emptyTokens, parseTs, pushEvent, describeTool, isNoisePrompt, sessionName } from './common.mjs';
10
10
  import { addChange, mergeFiles } from './files.mjs';
11
11
  import { codexCost } from '../pricing.mjs';
@@ -96,24 +96,66 @@ const cwdByPath = new Map();
96
96
  const foundByPid = new Map();
97
97
  let headBuf = null;
98
98
 
99
- // session_meta 첫 줄은 지침 글 때문에 길 수 있어 JSON 전체 대신 앞부분의 cwd 만 찾는다.
100
- function headCwd(path) {
99
+ // session_meta 의 source 칸: 'cli' · 'vscode' · 'exec' 같은 글이거나, 서브에이전트는 { subagent: … } 객체다. 객체면 키 이름만.
100
+ const sourceName = (v) => (typeof v === 'string' ? v : v && typeof v === 'object' ? (Object.keys(v)[0] ?? null) : null);
101
+
102
+ // 앞부분 글에서 "key":"값" 의 값을 찾는다. 지침 글 안의 따옴표는 \" 로 이스케이프돼 있어 이 패턴에 걸리지 않는다.
103
+ const headStr = (key, text) => {
104
+ const m = new RegExp(`"${key}":("(?:[^"\\\\]|\\\\.)*")`).exec(text);
105
+ try {
106
+ return m ? JSON.parse(m[1]) : null;
107
+ } catch {
108
+ return null;
109
+ }
110
+ };
111
+
112
+ // 첫 줄(session_meta)에서만 originator·source 를 읽는다. 다 들어왔으면 JSON 으로 읽고,
113
+ // HEAD_BYTES 를 넘는 긴 줄은 잘린 첫 줄 글에서 찾는다.
114
+ function firstLineMeta(text) {
115
+ const nl = text.indexOf('\n');
116
+ const line = nl >= 0 ? text.slice(0, nl) : text;
117
+ if (nl >= 0) {
118
+ try {
119
+ const x = JSON.parse(line);
120
+ if (x?.type !== 'session_meta') return { originator: null, source: null };
121
+ const p = x.payload ?? {};
122
+ return { originator: typeof p.originator === 'string' ? p.originator : null, source: sourceName(p.source) };
123
+ } catch {}
124
+ }
125
+ if (!line.includes('"session_meta"')) return { originator: null, source: null };
126
+ return { originator: headStr('originator', line), source: headStr('source', line) ?? (/"source":\{"subagent"/.test(line) ? 'subagent' : null) };
127
+ }
128
+
129
+ // session_meta 첫 줄은 지침 글 때문에 길 수 있어 앞부분만 읽는다. cwd 는 예전처럼 앞부분 어디서든(turn_context 포함) 찾는다.
130
+ function headMeta(path) {
101
131
  if (cwdByPath.has(path)) return cwdByPath.get(path);
102
- let cwd = null;
132
+ const meta = { cwd: null, originator: null, source: null };
103
133
  try {
104
134
  const fd = openSync(path, 'r');
105
135
  try {
106
136
  headBuf ??= Buffer.alloc(HEAD_BYTES);
107
- const m = /"cwd":("(?:[^"\\]|\\.)*")/.exec(headBuf.toString('utf8', 0, readSync(fd, headBuf, 0, HEAD_BYTES, 0)));
108
- if (m) cwd = JSON.parse(m[1]);
137
+ const text = headBuf.toString('utf8', 0, readSync(fd, headBuf, 0, HEAD_BYTES, 0));
138
+ meta.cwd = headStr('cwd', text);
139
+ Object.assign(meta, firstLineMeta(text));
109
140
  } finally {
110
141
  closeSync(fd);
111
142
  }
112
143
  } catch (e) {
113
144
  debugIo('codex', 'rollout head read failed', e, path);
114
145
  }
115
- cwdByPath.set(path, cwd);
116
- return cwd;
146
+ cwdByPath.set(path, meta);
147
+ return meta;
148
+ }
149
+
150
+ const headCwd = (path) => headMeta(path).cwd;
151
+
152
+ // 세션이 어디서 열렸는지 (#306). app-server 로 연 세션(Codex 앱·VS Code 확장)은 source 가 늘 'vscode' 이고,
153
+ // originator 로 둘을 가른다: VS Code 는 'codex_vscode', 앱은 이름에 Desktop 이 든다
154
+ // (upstream 테스트의 'Codex Desktop'. 실제 앱 기록의 값은 아직 확인하지 못했다).
155
+ // 그 밖(cli·exec·mcp·subagent, 칸이 없는 예전 기록)은 'cli'.
156
+ export function originOf({ source, originator } = {}) {
157
+ if (source !== 'vscode') return 'cli';
158
+ return /desktop/i.test(originator ?? '') ? 'app' : 'ide';
117
159
  }
118
160
 
119
161
  // 홈마다 sessions 경로와 그 실제 경로(realpath). 처음 쓸 때 한 번 만든다.
@@ -170,7 +212,8 @@ function latestFor(dirs, cwd, since, taken) {
170
212
  } catch {
171
213
  continue;
172
214
  }
173
- if (m >= since && (!best || m > best.mtime) && headCwd(p) === cwd) best = { path: p, mtime: m };
215
+ // CLI 프로세스에는 CLI 세션만 준다. 앱·IDE 세션은 app-server 의 것이다 (#306).
216
+ if (m >= since && (!best || m > best.mtime) && headCwd(p) === cwd && originOf(headMeta(p)) === 'cli') best = { path: p, mtime: m };
174
217
  }
175
218
  }
176
219
  for (const p of cwdByPath.keys()) if (!listed.has(p)) cwdByPath.delete(p);
@@ -226,15 +269,23 @@ function indexName(path, id) {
226
269
  return null;
227
270
  }
228
271
 
229
- const SAVED = ['id', 'threadName', 'cwd', 'branch', 'model', 'busy', 'tokens', 'context', 'window', 'events', 'lastTool', 'startedAt', 'lastKind', 'files', 'turns', 'turnCount', 'activity', 'pendingAt'];
272
+ const SAVED = ['id', 'threadName', 'originator', 'source', 'cwd', 'branch', 'model', 'busy', 'tokens', 'context', 'window', 'events', 'lastTool', 'startedAt', 'lastKind', 'files', 'turns', 'turnCount', 'activity', 'pendingAt'];
230
273
 
231
274
  function newState(path) {
232
- const st = { tail: new JsonlTail(path), id: basename(path), threadName: null, cwd: null, branch: null, model: null, busy: false, tokens: emptyTokens(), context: 0, window: 0, events: [], lastTool: null, startedAt: null, pending: new Map(), lastKind: null, files: [], turns: [], turnCount: 0, patches: {}, activity: {}, pendingAt: {} };
275
+ const st = { tail: new JsonlTail(path), id: basename(path), threadName: null, originator: null, source: null, cwd: null, branch: null, model: null, busy: false, tokens: emptyTokens(), context: 0, window: 0, events: [], lastTool: null, startedAt: null, pending: new Map(), lastKind: null, files: [], turns: [], turnCount: 0, patches: {}, activity: {}, pendingAt: {} };
233
276
  const c = loadCache(path);
234
277
  if (c) {
235
278
  st.tail.offset = c.offset;
236
279
  for (const k of SAVED) if (k in c) st[k] = c[k];
237
280
  st.pending = new Map(c.pending ?? []);
281
+ // originator·source 를 담기 전의 캐시는 session_meta 를 다시 읽지 않으므로 기록 첫 줄에서 채운다 (#306).
282
+ // 채운 값을 캐시에 다시 써서 다음 실행부터는 앞부분을 다시 읽지 않는다.
283
+ if (!('originator' in c)) {
284
+ const m = headMeta(path);
285
+ st.originator = m.originator;
286
+ st.source = m.source;
287
+ markDirty(path, () => snapshot(st));
288
+ }
238
289
  }
239
290
  return st;
240
291
  }
@@ -266,6 +317,8 @@ function applyLine(st, x) {
266
317
  if (x.type === 'session_meta') {
267
318
  st.id = p.id ?? st.id;
268
319
  st.cwd = p.cwd ?? st.cwd;
320
+ if (typeof p.originator === 'string') st.originator = p.originator;
321
+ st.source = sourceName(p.source) ?? st.source;
269
322
  st.branch = p.git?.branch ?? st.branch;
270
323
  st.startedAt = Date.parse(p.timestamp) || st.startedAt;
271
324
  } else if (x.type === 'turn_context') {
@@ -435,8 +488,19 @@ export function collectCodex({ showEnded, budget, filesOf = openFiles, startOf =
435
488
  };
436
489
 
437
490
  // 프로세스가 열어 둔 rollout 파일(Linux)이 가장 정확하므로 먼저 짝짓는다.
491
+ // app-server(Codex 앱·VS Code 확장)는 한 프로세스가 여러 세션을 돌리므로 열어 둔 rollout 을 모두 받고,
492
+ // 작업 폴더·시작 시각 짝짓기(slots·pairByStart·searchByCwd)와 '첫 입력 전' 줄에서는 뺀다 (#306).
438
493
  const rest = [];
494
+ const servers = [];
439
495
  for (const p of procs) {
496
+ if (isCodexAppServer(p.argv ?? [])) {
497
+ const opened = filesOf(p.pid);
498
+ // 열린 파일을 모르면(Linux 밖, 권한 없음) 아래에서 수정 시각으로 짐작한다. 목록을 얻었으면 그대로 믿는다:
499
+ // rollout 이 하나도 없으면 불러 둔 세션이 없는 것이다.
500
+ if (opened == null) servers.push(p);
501
+ else for (const f of opened) if (isRollout(f) && !liveByPath.has(f)) claim(f, p.pid);
502
+ continue;
503
+ }
440
504
  const opened = filesOf(p.pid)?.find((f) => isRollout(f) && !liveByPath.has(f));
441
505
  if (!opened || !claim(opened, p.pid)) rest.push(p);
442
506
  }
@@ -449,8 +513,10 @@ export function collectCodex({ showEnded, budget, filesOf = openFiles, startOf =
449
513
  if (p.cwdUnknown) anyCwd.push(p.pid);
450
514
  else slots.set(p.cwd, [...(slots.get(p.cwd) ?? []), p.pid]);
451
515
  }
516
+ // CLI 프로세스(작업 폴더·시작 시각 짝짓기)에는 CLI 세션만 준다. 앱·IDE 세션은 app-server 의 것이다 (#306).
517
+ const cliOnly = (f) => originOf(states.get(f.path) ?? {}) === 'cli';
452
518
  for (const f of files) {
453
- if (liveByPath.has(f.path) || isZst(f.path)) continue;
519
+ if (liveByPath.has(f.path) || isZst(f.path) || !cliOnly(f)) continue;
454
520
  const free = slots.get(states.get(f.path).cwd);
455
521
  const i = free?.findIndex((pid) => {
456
522
  const since = startOf(pid);
@@ -460,7 +526,7 @@ export function collectCodex({ showEnded, budget, filesOf = openFiles, startOf =
460
526
  }
461
527
  // 작업 폴더를 모르는 프로세스(Windows)는 폴더와 상관없이 시작 시각으로만 짝짓는다 (pairByStart).
462
528
  if (anyCwd.length) {
463
- const free = files.filter((f) => !liveByPath.has(f.path) && !isZst(f.path));
529
+ const free = files.filter((f) => !liveByPath.has(f.path) && !isZst(f.path) && cliOnly(f));
464
530
  for (const [path, pid] of pairByStart(anyCwd, free, (p) => states.get(p)?.startedAt, startOf)) liveByPath.set(path, pid);
465
531
  }
466
532
 
@@ -473,6 +539,18 @@ export function collectCodex({ showEnded, budget, filesOf = openFiles, startOf =
473
539
  }
474
540
  }
475
541
 
542
+ // 열린 파일을 모르는 app-server 가 살아 있으면, 짝 없는 앱·IDE 세션(origin 이 cli 가 아닌 것) 가운데
543
+ // 그 프로세스가 뜬 뒤에 쓰였고 NO_PROC_LIVE_MS 안에 바뀐 것을 실행 중으로 본다 (pid 는 그 프로세스).
544
+ // 어느 세션을 불러 두었는지 남는 파일이 없어(종료도 기록하지 않는다) 수정 시각으로 짐작한다.
545
+ if (servers.length) {
546
+ const order = servers.map((p) => ({ pid: p.pid, since: startOf(p.pid) })).sort((a, b) => (b.since ?? -Infinity) - (a.since ?? -Infinity));
547
+ for (const f of files) {
548
+ if (liveByPath.has(f.path) || !fresh(f) || originOf(states.get(f.path) ?? {}) === 'cli') continue;
549
+ const server = order.find((s) => s.since === null || f.mtime >= s.since);
550
+ if (server) liveByPath.set(f.path, server.pid);
551
+ }
552
+ }
553
+
476
554
  if (blind) for (const f of files) if (fresh(f)) liveByPath.set(f.path, null);
477
555
 
478
556
  const seen = new Set(files.map((f) => f.path));
@@ -495,6 +573,9 @@ export function collectCodex({ showEnded, budget, filesOf = openFiles, startOf =
495
573
  id: st.id,
496
574
  pid: pid ?? null,
497
575
  kind: 'interactive',
576
+ // 어디서 연 세션인지 'app' · 'ide' · 'cli' (originOf)와 기록의 originator 원래 값 (#306).
577
+ origin: originOf(st),
578
+ originator: st.originator ?? null,
498
579
  name: customName ?? (lastName(st.cwd) || 'codex'),
499
580
  customName,
500
581
  // rollout 이 든 Codex 홈. 기본 홈이 아니면 이어 열기 명령에 CODEX_HOME 을 붙인다.
@@ -528,7 +609,7 @@ export function collectCodex({ showEnded, budget, filesOf = openFiles, startOf =
528
609
  // 아직 세션 파일을 만들지 않은(첫 입력 전) codex 프로세스도 보여 준다.
529
610
  for (const [cwd, pids] of slots) {
530
611
  for (const pid of pids) {
531
- out.push({ tool: 'codex', id: `pid-${pid}`, pid, kind: 'interactive', name: lastName(cwd) || 'codex', cwd, project: lastName(cwd), live: true, status: 'idle', phase: { kind: 'idle', msg: 'firstInput' }, cost: null, now: '', updatedAt: Date.now(), tokens: emptyTokens(), context: { used: 0, window: 0 }, events: [], members: [] });
612
+ out.push({ tool: 'codex', id: `pid-${pid}`, pid, kind: 'interactive', origin: 'cli', originator: null, name: lastName(cwd) || 'codex', cwd, project: lastName(cwd), live: true, status: 'idle', phase: { kind: 'idle', msg: 'firstInput' }, cost: null, now: '', updatedAt: Date.now(), tokens: emptyTokens(), context: { used: 0, window: 0 }, events: [], members: [] });
532
613
  }
533
614
  }
534
615
  return out;
package/src/ui/detail.mjs CHANGED
@@ -375,6 +375,20 @@ function fitGroups(groups, w) {
375
375
  return kept.flatMap((g) => g.segs);
376
376
  }
377
377
 
378
+ // Codex 세션이 열린 곳 (#306): 앱 · IDE · CLI. originator 가 이미 아는 값이 아니면 괄호로 원래 값을 덧붙인다.
379
+ const KNOWN_ORIGINATORS = new Set(['codex_cli_rs', 'codex_vscode', 'codex_exec']);
380
+ function originText(s) {
381
+ if (s.tool !== 'codex' || !s.origin) return '';
382
+ const label = s.origin === 'app' ? tr('detail.app') : s.origin === 'ide' ? 'IDE' : 'CLI';
383
+ return s.originator && !KNOWN_ORIGINATORS.has(s.originator) ? `${label} (${s.originator})` : label;
384
+ }
385
+
386
+ // 종류 칸의 글: 종류 뒤에 Antigravity 앱(#303)은 '앱', Cowork(#304)는 실행 방식(local-agent), Codex 는 열린 곳(#306)을 붙인다.
387
+ function kindText(s) {
388
+ const extra = s.source === 'app' ? tr('detail.app') : s.tool === 'cowork' && s.entrypoint ? s.entrypoint : originText(s);
389
+ return `${s.kind ?? '-'}${extra ? ` · ${extra}` : ''}`;
390
+ }
391
+
378
392
  // 좁은 화면의 요약 두 줄.
379
393
  // 1줄: 상태 · 폴더 · 브랜치 · 종류 · 시작.
380
394
  // 2줄: 571k +서브2 (입력 90.3k·출력 18.4k·캐시 463k·적중 80%) · $0.17 · ctx 5% · pid 218093. 캐시는 읽기와 쓰기를 더한 값이다.
@@ -387,8 +401,8 @@ export function summaryLines(s, w, frame, view) {
387
401
  const cache = cacheState(s);
388
402
  const optional = [
389
403
  s.branch && [sep, { t: s.branch, fg: PALETTE.info }],
390
- // Cowork(#304)는 실행 방식(local-agent)을 붙인다.
391
- s.kind && [sep, { t: s.source === 'app' ? `${s.kind} · ${tr('detail.app')}` : s.tool === 'cowork' && s.entrypoint ? `${s.kind} · ${s.entrypoint}` : s.kind, fg: PALETTE.info }],
404
+ // Cowork(#304)는 실행 방식(local-agent), Codex(#306)는 열린 곳을 붙인다 (kindText).
405
+ s.kind && [sep, { t: kindText(s), fg: PALETTE.info }],
392
406
  s.startedAt && [sep, { t: tr('detail.startedAgo', { at: hhmm(s.startedAt), ago: fmtAgo(NOW - s.startedAt) }), fg: PALETTE.info }],
393
407
  // 캐시 남은 시간은 표의 STATUS 칸과 같은 짧은 글로, 가장 먼저 뺀다.
394
408
  cache && [sep, { t: cache.text, fg: cache.fg, bold: cache.bold }],
@@ -561,8 +575,8 @@ export function detail(s, W, H, frame, view) {
561
575
  kv(tr('detail.folder'), tilde(s.cwd));
562
576
  if (s.branch) kv(tr('detail.branch'), s.branch);
563
577
  kv(tr('detail.model'), s.model ?? '-');
564
- // Antigravity 데스크톱 앱의 대화는 종류 뒤에 짧게 '앱' 을 붙인다 (#303, 표에는 열을 만들지 않는다).
565
- kv(tr('detail.kind'), `${s.kind ?? '-'}${s.source === 'app' ? ` · ${tr('detail.app')}` : ''}${s.tool === 'cowork' && s.entrypoint ? ` · ${s.entrypoint}` : ''}${s.pid ? ` · pid ${s.pid}` : ''}`);
578
+ // Antigravity 데스크톱 앱의 대화는 종류 뒤에 짧게 '앱' 을 붙인다 (#303, 표에는 열을 만들지 않는다). Codex 는 열린 곳(#306).
579
+ kv(tr('detail.kind'), `${kindText(s)}${s.pid ? ` · pid ${s.pid}` : ''}`);
566
580
  if (s.startedAt) kv(tr('detail.started'), tr('detail.ago', { at: clock(s.startedAt), ago: fmtAgo(NOW - s.startedAt) }));
567
581
 
568
582
  // 합계 = 메인 + 서브 = 입력 + 출력 + 캐시 읽기 + 캐시 쓰기 가 화면에서 그대로 맞아떨어지게 보인다.