@townco/cli 0.1.108 → 0.1.109

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.
@@ -3,7 +3,7 @@ import { spawn } from "node:child_process";
3
3
  import { existsSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { LOG_FILE_NAME } from "@townco/core";
6
- import { Box, Text, useInput } from "ink";
6
+ import { Box, Static, Text, useInput } from "ink";
7
7
  import TextInput from "ink-text-input";
8
8
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
9
9
  const LOG_LEVELS = [
@@ -14,8 +14,6 @@ const LOG_LEVELS = [
14
14
  "error",
15
15
  "fatal",
16
16
  ];
17
- // Max lines to keep in buffer
18
- const MAX_LINES = 1000;
19
17
  function buildCommand(logsDir, pretty, level, sessionStartTime) {
20
18
  const logFile = join(logsDir, LOG_FILE_NAME);
21
19
  const tailCmd = `tail -n +1 -f "${logFile}"`;
@@ -44,20 +42,12 @@ export function LogsPane({ logsDir: customLogsDir } = {}) {
44
42
  const [customCommand, setCustomCommand] = useState("");
45
43
  const [outputLines, setOutputLines] = useState([]);
46
44
  const [error, setError] = useState(null);
47
- const [terminalHeight, setTerminalHeight] = useState(process.stdout.rows ?? 30);
48
45
  const processRef = useRef(null);
49
46
  const commandRunIdRef = useRef(0);
47
+ const lineIdRef = useRef(0);
50
48
  const activeCommand = useMemo(() => editMode
51
49
  ? customCommand
52
50
  : buildCommand(logsDir, pretty, level, sessionStartTime), [editMode, customCommand, logsDir, pretty, level, sessionStartTime]);
53
- // Track terminal resize
54
- useEffect(() => {
55
- const handleResize = () => setTerminalHeight(process.stdout.rows ?? 30);
56
- process.stdout.on("resize", handleResize);
57
- return () => {
58
- process.stdout.off("resize", handleResize);
59
- };
60
- }, []);
61
51
  // Spawn tail process
62
52
  useEffect(() => {
63
53
  if (!existsSync(logsDir)) {
@@ -68,8 +58,9 @@ export function LogsPane({ logsDir: customLogsDir } = {}) {
68
58
  processRef.current.kill();
69
59
  processRef.current = null;
70
60
  }
71
- // Clear output when command changes
61
+ // Clear output and reset line counter when command changes
72
62
  setOutputLines([]);
63
+ lineIdRef.current = 0;
73
64
  const runId = ++commandRunIdRef.current;
74
65
  const timeoutId = setTimeout(() => {
75
66
  if (runId !== commandRunIdRef.current)
@@ -83,14 +74,21 @@ export function LogsPane({ logsDir: customLogsDir } = {}) {
83
74
  if (runId !== commandRunIdRef.current)
84
75
  return;
85
76
  const lines = data.toString().split("\n").filter(Boolean);
86
- setOutputLines((prev) => [...prev, ...lines].slice(-MAX_LINES));
77
+ const newLines = lines.map((text) => ({
78
+ id: ++lineIdRef.current,
79
+ text,
80
+ }));
81
+ setOutputLines((prev) => [...prev, ...newLines]);
87
82
  });
88
83
  proc.stderr?.on("data", (data) => {
89
84
  if (runId !== commandRunIdRef.current)
90
85
  return;
91
86
  const text = data.toString().trim();
92
87
  if (text && !text.includes("parse error")) {
93
- setOutputLines((prev) => [...prev, `[stderr] ${text}`].slice(-MAX_LINES));
88
+ setOutputLines((prev) => [
89
+ ...prev,
90
+ { id: ++lineIdRef.current, text: `[stderr] ${text}` },
91
+ ]);
94
92
  }
95
93
  });
96
94
  proc.on("error", (err) => {
@@ -147,12 +145,8 @@ export function LogsPane({ logsDir: customLogsDir } = {}) {
147
145
  if (error) {
148
146
  return (_jsx(Box, { flexDirection: "column", padding: 1, children: _jsx(Text, { color: "red", children: error }) }));
149
147
  }
150
- // Calculate visible lines based on terminal height
151
- // Reserve: footer (4 lines) + status bar (3 lines) + padding
152
- const visibleLines = Math.max(5, terminalHeight - 10);
153
- const displayLines = outputLines.slice(-visibleLines);
154
- return (_jsxs(Box, { flexDirection: "column", height: "100%", children: [
155
- _jsx(Box, { flexDirection: "column", flexGrow: 1, overflow: "hidden", children: displayLines.length === 0 ? (_jsx(Text, { dimColor: true, children: "Waiting for logs..." })) : (displayLines.map((line, idx) => (_jsx(Text, { children: line }, `${idx}-${line.slice(0, 20)}`)))) }), _jsxs(Box, { borderStyle: "single", borderTop: true, borderColor: "gray", paddingX: 1, flexDirection: "column", flexShrink: 0, children: [editMode ? (_jsxs(Box, { children: [
148
+ return (_jsxs(Box, { flexDirection: "column", children: [
149
+ _jsx(Static, { items: outputLines, children: (line) => _jsx(Text, { children: line.text }, line.id) }), outputLines.length === 0 && _jsx(Text, { dimColor: true, children: "Waiting for logs..." }), _jsxs(Box, { borderStyle: "single", borderTop: true, borderColor: "gray", paddingX: 1, flexDirection: "column", flexShrink: 0, children: [editMode ? (_jsxs(Box, { children: [
156
150
  _jsx(Text, { color: "cyan", children: "$ " }), _jsx(TextInput, { value: customCommand, onChange: setCustomCommand, placeholder: "Enter command..." }), _jsx(Text, { dimColor: true, children: " (Enter to apply, Esc to cancel)" })
157
151
  ] })) : (_jsxs(Box, { children: [
158
152
  _jsx(Text, { dimColor: true, children: "$ " }), _jsx(Text, { children: activeCommand })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@townco/cli",
3
- "version": "0.1.108",
3
+ "version": "0.1.109",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "town": "./dist/index.js"
@@ -15,7 +15,7 @@
15
15
  "build": "tsgo"
16
16
  },
17
17
  "devDependencies": {
18
- "@townco/tsconfig": "0.1.100",
18
+ "@townco/tsconfig": "0.1.101",
19
19
  "@types/archiver": "^7.0.0",
20
20
  "@types/bun": "^1.3.1",
21
21
  "@types/ignore-walk": "^4.0.3",
@@ -24,13 +24,13 @@
24
24
  "dependencies": {
25
25
  "@optique/core": "^0.6.2",
26
26
  "@optique/run": "^0.6.2",
27
- "@townco/agent": "0.1.111",
28
- "@townco/apiclient": "0.0.23",
29
- "@townco/core": "0.0.81",
30
- "@townco/debugger": "0.1.59",
31
- "@townco/env": "0.1.53",
32
- "@townco/secret": "0.1.103",
33
- "@townco/ui": "0.1.103",
27
+ "@townco/agent": "0.1.112",
28
+ "@townco/apiclient": "0.0.24",
29
+ "@townco/core": "0.0.82",
30
+ "@townco/debugger": "0.1.60",
31
+ "@townco/env": "0.1.54",
32
+ "@townco/secret": "0.1.104",
33
+ "@townco/ui": "0.1.104",
34
34
  "@trpc/client": "^11.7.2",
35
35
  "archiver": "^7.0.1",
36
36
  "eventsource": "^4.1.0",