@sejuneoh/aitop 0.29.0 → 0.31.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
@@ -7,6 +7,7 @@ import { NOW, box, clock, fill, gauge, glyph, hhmm, levelBar, money, rule, segsW
7
7
  import { activitySeries } from '../sources/common.mjs';
8
8
  import { glyphs } from './glyphs.mjs';
9
9
  import { STRINGS, phaseText, t as tr } from '../i18n.mjs';
10
+ import { resumeCmd } from '../resume.mjs';
10
11
 
11
12
  // 탭 이름: 이번 지시·전체 탭은 turns.mjs 가 ko 이름을 붙이므로 지금 언어로 바꾼다. 지시 탭(T5)은 그대로.
12
13
  const tabLabel = (tab, short = false) => (tab.key === 'now' ? tr('detail.tabNow', null, { short }) : tab.key === 'all' ? tr('detail.tabAll') : tab.label);
@@ -318,13 +319,39 @@ export function summaryLines(s, w, frame, view) {
318
319
  return [first, [{ t: ' ' }, ...second]];
319
320
  }
320
321
 
322
+ // 이어 열기 명령을 폭에 맞춰 max 줄로 나눈다. 넘치면 마지막 줄 끝을 … 로 바꾼다 (복사하면 전체가 들어간다).
323
+ export function resumeLines(cmd, w, max) {
324
+ if (!cmd || max < 1) return [];
325
+ let lines = wrapText(cmd, Math.max(1, w));
326
+ if (lines.length > max) {
327
+ lines = lines.slice(0, max);
328
+ const mark = ellipsis(w);
329
+ const last = [...lines[max - 1]];
330
+ while (last.length && width(last.join('')) + width(mark) > w) last.pop();
331
+ lines[max - 1] = last.join('') + mark;
332
+ }
333
+ return lines;
334
+ }
335
+
336
+ // 좁은 화면의 셋째 요약 줄: '이어 열기 y …/repo && claude --resume <id>'. 한 줄을 넘으면 앞을 잘라 세션 id 를 남긴다.
337
+ export function resumeSummary(s, w) {
338
+ const cmd = resumeCmd(s);
339
+ if (!cmd) return null;
340
+ const head = [{ t: ' ' }, { t: tr('detail.resume'), fg: PALETTE.muted }, { t: ' y ', fg: PALETTE.info }];
341
+ const room = w - segsWidth(head);
342
+ if (room < 8) return null;
343
+ return [...head, { t: truncateLeft(cmd, room), fg: PALETTE.text }];
344
+ }
345
+
321
346
  export function detail(s, W, H, frame, view) {
322
347
  const tc = PALETTE.tools[s.tool];
323
348
  // 제목: 세션 이름은 진하게, 도구·모델은 도구 색으로.
324
349
  const title = [{ t: s.name ?? s.tool, fg: PALETTE.text, bold: true }, { t: ` ${s.tool}${s.model ? ' · ' + s.model : ''}`, fg: tc }];
325
350
  if (W < NARROW_W) {
326
351
  const inner = W - 4;
327
- const top = summaryLines(s, inner, frame, view);
352
+ // 셋째 줄(이어 열기)은 오른쪽 칸이 넉넉할(ROOMY 줄 이상 남을) 때만 둔다. 낮은 화면의 구획 배치는 그대로다.
353
+ const resume = H - 5 >= ROOMY ? resumeSummary(s, inner) : null;
354
+ const top = [...summaryLines(s, inner, frame, view), ...(resume ? [resume] : [])];
328
355
  const R = rightColumn(s, inner, H - 2 - top.length, view);
329
356
  return box(title, W, H, null, [...top, ...R], 0, tc, Boolean(view?.focus));
330
357
  }
@@ -362,6 +389,14 @@ export function detail(s, W, H, frame, view) {
362
389
  L.push([INDENT, { t: pad(tr('detail.context'), 9), fg: PALETTE.muted }, { t: pad(`${fmtTokens(s.context.used)}/${fmtTokens(s.context.window)}`, 11) + ' ', fg: PALETTE.text }, ...gauge(s.context.used, s.context.window, Math.max(4, leftW - width(INDENT.t) - 26))]);
363
390
  }
364
391
 
392
+ // 이어 열기: 다른 터미널에서 이 세션을 이어 여는 명령. y 로 복사한다. 맨 아래에 두고, 남는 줄(가로줄 + 적어도 1줄)이 있을 때만 최대 3줄.
393
+ const cmd = resumeCmd(s);
394
+ const room = H - 2 - L.length;
395
+ if (cmd && room >= 2) {
396
+ L.push(rule([{ t: tr('detail.resume'), fg: PALETTE.text, bold: true }], 'y', leftW));
397
+ for (const l of resumeLines(cmd, leftW - width(INDENT.t), Math.min(3, room - 1))) L.push([INDENT, { t: l, fg: PALETTE.muted }]);
398
+ }
399
+
365
400
  const R = rightColumn(s, W - leftW - 7, H - 2, view);
366
401
  return box(title, W, H, L, R, leftW, tc, Boolean(view?.focus));
367
402
  }