@sejuneoh/aitop 0.39.0 → 0.41.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/src/ui/detail.mjs CHANGED
@@ -60,6 +60,8 @@ export function fileRow(f, cwd, w, selected) {
60
60
  // 같은 파일을 여러 번 고치면 줄 번호 기준이 매번 달라져 하나의 diff 로 합칠 수 없다.
61
61
  export function diffBody(f, w) {
62
62
  if (f.hidden) return [[INDENT, { t: tr('detail.hidden'), fg: PALETTE.info, italic: true }]];
63
+ // 원격 세션(#308)은 파일 통계만 받고 변경 내용은 가져오지 않는다.
64
+ if (f.remote) return [[INDENT, { t: tr('detail.remoteDiff'), fg: PALETTE.info, italic: true }]];
63
65
  if (!f.hunks.length) return [[INDENT, { t: tr(f.deleted ? 'detail.deleted' : 'detail.noHunks'), fg: PALETTE.info, italic: true }]];
64
66
  const nums = w >= 50;
65
67
  const textW = w - 1 - (nums ? 5 : 0);
@@ -251,7 +253,8 @@ function linkLabel(url, full) {
251
253
  return `claude.ai/…${last.slice(-8)}`;
252
254
  }
253
255
 
254
- export function artifactRow(a, w) {
256
+ // selected: 목록에 들어가(v) 고른 줄. 들여 쓰기 자리에 ▸ 를 두고 배경을 칠해 폭은 그대로다.
257
+ export function artifactRow(a, w, selected = false) {
255
258
  const textW = Math.max(1, w - width(INDENT.t));
256
259
  const sep = { t: ' · ', fg: PALETTE.info };
257
260
  const url = artifactLink(a.url);
@@ -275,15 +278,26 @@ export function artifactRow(a, w) {
275
278
  const want = (k) => (k === 0 ? width(title) : Math.min(width(title), TITLE_MIN));
276
279
  const rest = options.find((o, k) => textW - segsWidth(o) >= want(k)) ?? [];
277
280
  const titleW = Math.max(1, textW - segsWidth(rest));
278
- return [INDENT, { t: truncate(title, titleW), fg: PALETTE.text, bold: true }, ...rest];
281
+ const row = [selected ? { t: '▸', fg: PALETTE.brand, bold: true } : INDENT, { t: truncate(title, titleW), fg: PALETTE.text, bold: true }, ...rest];
282
+ return selected ? fill(row, w, PALETTE.rowFocus) : row;
279
283
  }
280
284
 
281
- export function artifactBlock(s, w, max = ARTIFACT_LINES + 1) {
285
+ // view.focus 가 'artifacts' 면 고른 줄(view.artifactId)이 보이게 창을 옮기고, 구획 왼쪽에 ▌ 막대를 세운다 (변경 파일 목록과 같은 모양).
286
+ // 목록에 들어가 있지 않으면 가로줄 끝에 들어가는 키(v)를 알린다.
287
+ export function artifactBlock(s, w, max = ARTIFACT_LINES + 1, view = null) {
282
288
  const list = s.artifacts ?? [];
283
289
  if (!list.length || max < 2) return [];
284
- const shown = list.slice(0, max - 1);
290
+ const focused = view?.focus === 'artifacts';
291
+ const gutter = focused ? [{ t: glyphs().select, fg: PALETTE.brand }] : [];
292
+ const inner = w - segsWidth(gutter);
293
+ const slots = max - 1;
294
+ const sel = focused ? list.findIndex((a) => a.id === view.artifactId) : -1;
295
+ const start = sel >= slots ? sel - slots + 1 : 0;
296
+ const shown = list.slice(start, start + slots);
285
297
  const more = list.length - shown.length;
286
- return [rule([{ t: tr('detail.artifacts', { n: list.length }), fg: PALETTE.text, bold: true }], more ? `+${more}` : '', w), ...shown.map((a) => artifactRow(a, w))];
298
+ const meta = [more ? `+${more}` : '', focused ? '' : 'v'].filter(Boolean).join(' · ');
299
+ const head = rule([{ t: tr('detail.artifacts', { n: list.length }), fg: focused ? PALETTE.brand : PALETTE.text, bold: true }], meta, inner, focused ? PALETTE.brand : PALETTE.line);
300
+ return [head, ...shown.map((a, k) => artifactRow(a, inner, start + k === sel))].map((r) => [...gutter, ...r]);
287
301
  }
288
302
 
289
303
  // 오른쪽 칸: 고친 파일이 없으면 최근 활동만, 있으면 위쪽 절반까지 변경 파일 구획(배경 띠), 파일을 열면 diff.
@@ -293,7 +307,7 @@ export function rightColumn(s, w, rows, view) {
293
307
  const req = view?.showRequests ? requestBlock(s, w, Math.min(REQUEST_LINES, rows - 5)) : [];
294
308
  if (req.length) return [...req, ...rightColumn({ ...s, waitDetail: null }, w, rows - req.length, view)];
295
309
  // 아티팩트 구획은 diff 를 열지 않았을 때 그 아래에 둔다. 아래 구획(변경 파일·최근 활동)에 적어도 6줄을 남긴다.
296
- const art = view?.focus === 'diff' ? [] : artifactBlock(s, w, Math.min(ARTIFACT_LINES + 1, rows - 6));
310
+ const art = view?.focus === 'diff' ? [] : artifactBlock(s, w, Math.min(ARTIFACT_LINES + 1, rows - 6), view);
297
311
  if (art.length) return [...art, ...rightColumn({ ...s, waitDetail: null, artifacts: [] }, w, rows - art.length, view)];
298
312
  const all = s.files ?? [];
299
313
  const focused = view?.focus === 'files';
@@ -517,7 +531,8 @@ export function resumeSummary(s, w) {
517
531
  export function detail(s, W, H, frame, view) {
518
532
  const tc = PALETTE.tools[s.tool];
519
533
  // 제목: 세션 이름은 진하게, 도구·모델은 도구 색으로.
520
- const title = [{ t: s.name ?? s.tool, fg: PALETTE.text, bold: true }, { t: ` ${s.tool}${s.model ? ' · ' + s.model : ''}`, fg: tc }];
534
+ // 원격 세션(#308)은 제목 끝에 '@ 호스트' 를 붙인다.
535
+ const title = [{ t: s.name ?? s.tool, fg: PALETTE.text, bold: true }, { t: ` ${s.tool}${s.model ? ' · ' + s.model : ''}`, fg: tc }, ...(s.host ? [{ t: ` @ ${s.host}`, fg: PALETTE.muted }] : [])];
521
536
  if (W < NARROW_W) {
522
537
  const inner = W - 4;
523
538
  // 셋째 줄(이어 열기)은 오른쪽 칸이 넉넉할(ROOMY 줄 이상 남을) 때만 둔다. 낮은 화면의 구획 배치는 그대로다.
@@ -538,6 +553,7 @@ export function detail(s, W, H, frame, view) {
538
553
  const cache = cacheState(s);
539
554
  if (cache) L.push([{ t: ' ' }, { t: cache.expired ? tr('detail.cacheExpired', { ttl: cache.ttl }) : tr('detail.cacheLeft', { t: cache.left, ttl: cache.ttl }), fg: cache.expired ? PALETTE.info : cache.fg, bold: cache.bold }]);
540
555
  section(tr('detail.session'));
556
+ if (s.host) kv(tr('detail.host'), s.host);
541
557
  kv(tr('detail.folder'), tilde(s.cwd));
542
558
  if (s.branch) kv(tr('detail.branch'), s.branch);
543
559
  kv(tr('detail.model'), s.model ?? '-');
package/src/ui/table.mjs CHANGED
@@ -15,7 +15,7 @@ import { callsYou, isStopped } from '../attention.mjs';
15
15
  export function filterSessions(sessions, query) {
16
16
  const q = (query ?? '').trim().toLowerCase();
17
17
  if (!q) return sessions;
18
- return sessions.filter((s) => [s.name, s.project, s.cwd, s.model, s.tool].some((v) => String(v ?? '').toLowerCase().includes(q)));
18
+ return sessions.filter((s) => [s.name, s.project, s.cwd, s.model, s.tool, s.host].some((v) => String(v ?? '').toLowerCase().includes(q)));
19
19
  }
20
20
 
21
21
  // 표 폭이 WIDE 이상이면 COST 와 CONTEXT 막대 11칸을 그대로 두고, 폭에 따라 MODEL(104~)·PROJECT(110~) 를 더한다.
@@ -138,7 +138,7 @@ export function header(view, W) {
138
138
  const bar = u?.loading == null && u?.days7?.length ? [{ t: ' ', bg: B }, ...weekBar(u.days7, view.costMode).map((x) => ({ ...x, bg: B }))] : null;
139
139
  const week = (tok, withBar = false) => period(t('hdr.week'), u.week, tok, [], withBar && bar ? bar : []);
140
140
  // 장부를 못 읽었으면 화면에 있는 세션(모든 도구)의 누적 토큰이라도 보인다.
141
- const fallback = [{ t: `Σ ${fmtTokens(sessions.reduce((a, s) => a + (s.tokens?.total ?? 0), 0))} tok`, fg: PALETTE.muted, bg: B }];
141
+ const fallback = [{ t: `Σ ${fmtTokens(sessions.reduce((a, s) => a + (s.host ? 0 : (s.tokens?.total ?? 0)), 0))} tok`, fg: PALETTE.muted, bg: B }];
142
142
  const clockSeg = { t: clock(view.data.at), fg: PALETTE.muted, bg: B };
143
143
  // 비용은 API 정가 환산이다 (구독 요금제의 실제 청구액이 아님). 폭이 되면 그렇다고 적는다.
144
144
  const api = { t: `${t(net ? 'hdr.netLong' : 'hdr.apiLong')} `, fg: net ? PALETTE.brand : PALETTE.info, bg: B };
@@ -533,3 +533,29 @@ export function groupRow(g, W) {
533
533
  ...(g.cost > 0 || g.unknown ? [{ t: ' · ', fg: PALETTE.info }, { t: money(g.cost, g.unknown), fg: PALETTE.muted }] : []),
534
534
  ], W);
535
535
  }
536
+
537
+ // 원격 구분 줄 (#308): '── dev · 3 세션 · 10초 전 ──', 실패하면 '── dev · 연결 안 됨 (시간 초과) ──', 첫 결과 전에는 '── dev · 연결 중… ──'.
538
+ // r 은 remote.mjs 폴러의 상태({ name, ok, error, pending, at }), n 은 이 구획에 보이는 세션 수.
539
+ // 폭이 모자라면 호스트 이름을 먼저 줄이고 상태 글은 남긴다.
540
+ export function remoteAgo(at, now = NOW) {
541
+ if (!at) return '';
542
+ const sec = Math.max(0, Math.floor((now - at) / 1000));
543
+ return sec < 60 ? t('remote.secAgo', { n: sec }) : t('remote.minAgo', { n: Math.floor(sec / 60) });
544
+ }
545
+
546
+ export function remoteRow(r, n, W) {
547
+ const h = glyphs().rule;
548
+ const down = !r.ok && !r.pending;
549
+ // 잠깐 끊겨 직전 세션을 남겨 둔 동안(n > 0)은 실패 뒤에 그 세션을 받은 시각을 붙인다.
550
+ const ago = r.at ? ` · ${remoteAgo(r.at)}` : '';
551
+ const state = !r.ok && r.pending ? t('remote.pending') : down ? `${t('remote.down', { why: t(`remote.err.${r.error ?? 'unreachable'}`) })}${n ? ago : ''}` : `${t('remote.count', { n })}${ago}`;
552
+ const tail = ` · ${state} `;
553
+ const room = Math.max(1, W - 3 - width(tail) - 2);
554
+ const name = truncate(r.name, room);
555
+ return line([
556
+ { t: `${h}${h} `, fg: PALETTE.line },
557
+ { t: name, fg: PALETTE.muted, bold: true },
558
+ { t: tail, fg: down ? PALETTE.alert : PALETTE.info },
559
+ { t: h.repeat(Math.max(0, W - 3 - width(name) - width(tail))), fg: PALETTE.line },
560
+ ], W);
561
+ }
package/src/ui.mjs CHANGED
@@ -4,8 +4,9 @@ import { BRAND } from './brand.mjs';
4
4
  import { PALETTE } from './ui/theme.mjs';
5
5
  import { glyphMoves, line, setNow } from './ui/draw.mjs';
6
6
  import { glyphs } from './ui/glyphs.mjs';
7
- import { TABLE_BOX_H, columns, emptyLines, filterSessions, groupRow, header, memberRow, sessionRow, tableBox, tableHeader, toolStrip, topCost } from './ui/table.mjs';
7
+ import { TABLE_BOX_H, columns, emptyLines, filterSessions, groupRow, header, memberRow, remoteRow, sessionRow, tableBox, tableHeader, toolStrip, topCost } from './ui/table.mjs';
8
8
  import { detail } from './ui/detail.mjs';
9
+ import { artifactScreen } from './ui/artifact-view.mjs';
9
10
  import { detailOpen, footer, help } from './ui/chrome.mjs';
10
11
  import { arrange } from './order.mjs';
11
12
  import { callsYou } from './attention.mjs';
@@ -64,7 +65,9 @@ export function render(view, W, H) {
64
65
  return lines;
65
66
  }
66
67
  const { errors } = view.data;
67
- const { sessions, groups } = arrange(filterSessions(view.data.sessions, view.filter), view);
68
+ // 원격(#308) 상태 목록. 원격을 켜지 않았으면 비어 있고 화면은 예전과 같다.
69
+ const remotes = view.data.remotes ?? [];
70
+ const { sessions, groups, hosts } = arrange(filterSessions(view.data.sessions, view.filter), { ...view, remotes });
68
71
  const boxed = H >= TABLE_BOX_H && W >= 60;
69
72
  const TW = boxed ? W - 4 : W;
70
73
  const c = columns(TW);
@@ -74,6 +77,15 @@ export function render(view, W, H) {
74
77
  lines.push(footer({ ...view, showDetail: detailOpen(view, H) }, W, sessions.length));
75
78
  return lines;
76
79
  }
80
+ // 아티팩트 원본(#307)은 머리 줄과 키 줄 사이 전체를 쓴다.
81
+ if (view.focus === 'artifact' && view.artDoc) {
82
+ const s = view.data.sessions.find((x) => x.id === view.selectedId);
83
+ const a = s?.artifacts?.find((x) => x.id === view.artifactId) ?? null;
84
+ lines.push(header(view, W), ...artifactScreen(view.artDoc, a, W, Math.max(3, H - 2), view));
85
+ lines.length = H - 1;
86
+ lines.push(footer(view, W, sessions.length));
87
+ return lines;
88
+ }
77
89
  lines.push(header(view, W), toolStrip(view, W));
78
90
  if (!boxed) lines.push(line([], W));
79
91
  const table = [tableHeader(c, TW)];
@@ -83,12 +95,23 @@ export function render(view, W, H) {
83
95
  rows.push({ s });
84
96
  s.members.forEach((m, i) => rows.push({ s, m, last: i === s.members.length - 1 }));
85
97
  };
86
- if (groups) {
87
- for (const g of groups) {
88
- rows.push({ g });
89
- g.sessions.forEach(pushSession);
90
- }
91
- } else sessions.forEach(pushSession);
98
+ const pushPart = (part) => {
99
+ if (part.groups) {
100
+ for (const g of part.groups) {
101
+ rows.push({ g });
102
+ g.sessions.forEach(pushSession);
103
+ }
104
+ } else part.sessions.forEach(pushSession);
105
+ };
106
+ // 로컬 세션이 맨 위, 그 아래 원격마다 구분 줄 하나와 그 원격의 세션 (구획 안의 정렬·묶기는 arrange 가 정한다).
107
+ pushPart({ groups, sessions: hosts ? sessions.filter((s) => !s.host) : sessions });
108
+ const parts = new Map((hosts ?? []).map((h) => [h.host, h]));
109
+ const names = [...new Set([...remotes.map((r) => r.name), ...parts.keys()])];
110
+ for (const name of names) {
111
+ const part = parts.get(name) ?? { sessions: [], groups: null };
112
+ rows.push({ remote: remotes.find((r) => r.name === name) ?? { name, ok: true, at: null }, n: part.sessions.length });
113
+ pushPart(part);
114
+ }
92
115
  const sel = sessions.find((s) => s.id === view.selectedId) ?? sessions[0];
93
116
  const open = detailOpen(view, H);
94
117
  const wantDetail = open && Boolean(sel);
@@ -108,13 +131,13 @@ export function render(view, W, H) {
108
131
  const lastOfSel = selRow + (sel?.members.length ?? 0);
109
132
  let start = Math.min(Math.max(0, lastOfSel - shown + 1), Math.max(0, rows.length - shown), selRow);
110
133
  // 고른 세션이 묶음의 첫 행이고 자리가 남으면 그 묶음 머리도 보이게 한 줄 올린다.
111
- if (start === selRow && rows[start - 1]?.g && lastOfSel - start + 2 <= shown) start--;
134
+ if (start === selRow && (rows[start - 1]?.g || rows[start - 1]?.remote) && lastOfSel - start + 2 <= shown) start--;
112
135
  const isSession = (r) => r.s && !r.m;
113
136
  const visible = rows.slice(start, start + shown);
114
137
  // 준비 완료 전에는 값이 커지는 대로 ▲ 가 옮겨 다니므로 붙이지 않는다.
115
138
  const hot = view.ready === false ? null : topCost(visible.filter(isSession).map((r) => r.s), view.costMode);
116
139
  if (!sessions.length) table.push(...(view.filter ? [line([{ t: ` ${t('ui.noMatch', { q: view.filter })}`, fg: PALETTE.muted, italic: true }], TW)] : emptyLines(view, TW)));
117
- for (const r of visible) table.push(r.g ? groupRow(r.g, TW) : r.m ? memberRow(r.m, r.last, c, TW, view.frame, r.s.model, view.costMode, r.s.status) : sessionRow(r.s, c, TW, r.s === sel, view.frame, hot, view.costMode, Boolean(view.pins?.includes(r.s.id))));
140
+ for (const r of visible) table.push(r.remote ? remoteRow(r.remote, r.n, TW) : r.g ? groupRow(r.g, TW) : r.m ? memberRow(r.m, r.last, c, TW, view.frame, r.s.model, view.costMode, r.s.status) : sessionRow(r.s, c, TW, r.s === sel, view.frame, hot, view.costMode, Boolean(view.pins?.includes(r.s.id))));
118
141
  if (clipped) {
119
142
  const onScreen = new Set(visible.filter(isSession).map((r) => r.s));
120
143
  const hidden = sessions.filter((s) => !onScreen.has(s));