codeam-cli 1.4.16 → 1.4.18

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.
Files changed (2) hide show
  1. package/dist/index.js +28 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
115
115
  // package.json
116
116
  var package_default = {
117
117
  name: "codeam-cli",
118
- version: "1.4.16",
118
+ version: "1.4.18",
119
119
  description: "Remote control Claude Code from your mobile device",
120
120
  main: "dist/index.js",
121
121
  bin: {
@@ -1411,6 +1411,23 @@ var HistoryService = class {
1411
1411
  setCurrentConversationId(id) {
1412
1412
  this.currentConversationId = id;
1413
1413
  }
1414
+ /** Detect the active conversation by finding the most recently modified JSONL file */
1415
+ detectCurrentConversation() {
1416
+ const dir = this.projectDir;
1417
+ try {
1418
+ const files = fs4.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
1419
+ try {
1420
+ return { name: e.name, mtime: fs4.statSync(path4.join(dir, e.name)).mtimeMs };
1421
+ } catch {
1422
+ return { name: e.name, mtime: 0 };
1423
+ }
1424
+ }).sort((a, b) => b.mtime - a.mtime);
1425
+ if (files.length > 0) {
1426
+ this.currentConversationId = path4.basename(files[0].name, ".jsonl");
1427
+ }
1428
+ } catch {
1429
+ }
1430
+ }
1414
1431
  /** Extract conversation ID from Claude output (e.g., from session resume messages) */
1415
1432
  tryExtractConversationIdFromOutput(output) {
1416
1433
  const patterns = [
@@ -1450,17 +1467,9 @@ var HistoryService = class {
1450
1467
  }
1451
1468
  }).sort((a, b) => b.mtime - a.mtime);
1452
1469
  if (files.length === 0) return null;
1453
- if (this.currentConversationId) {
1454
- const conversationFile = `${this.currentConversationId}.jsonl`;
1455
- if (files.some((f) => f.name === conversationFile)) {
1456
- return this.extractUsageFromFile(path4.join(dir, conversationFile));
1457
- }
1458
- }
1459
- for (const file of files) {
1460
- const result = this.extractUsageFromFile(path4.join(dir, file.name));
1461
- if (result) return result;
1462
- }
1463
- return null;
1470
+ const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
1471
+ if (!files.some((f) => f.name === targetFile)) return null;
1472
+ return this.extractUsageFromFile(path4.join(dir, targetFile));
1464
1473
  }
1465
1474
  extractUsageFromFile(filePath) {
1466
1475
  let raw;
@@ -1506,14 +1515,16 @@ var HistoryService = class {
1506
1515
  return 0;
1507
1516
  }
1508
1517
  const now = /* @__PURE__ */ new Date();
1509
- const monthStart = new Date(now.getFullYear(), now.getMonth(), 1).getTime();
1518
+ const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
1519
+ const monthStartIso = monthStart.toISOString();
1520
+ const monthStartMs = monthStart.getTime();
1510
1521
  let totalCost = 0;
1511
1522
  for (const projectDir of projectDirs) {
1512
1523
  let files;
1513
1524
  try {
1514
1525
  files = fs4.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
1515
1526
  try {
1516
- return fs4.statSync(path4.join(projectDir, f)).mtimeMs >= monthStart;
1527
+ return fs4.statSync(path4.join(projectDir, f)).mtimeMs >= monthStartMs;
1517
1528
  } catch {
1518
1529
  return false;
1519
1530
  }
@@ -1532,6 +1543,8 @@ var HistoryService = class {
1532
1543
  try {
1533
1544
  const record = JSON.parse(line);
1534
1545
  if (record["type"] !== "assistant") continue;
1546
+ const timestamp = record["timestamp"];
1547
+ if (timestamp && timestamp < monthStartIso) continue;
1535
1548
  const msg = record["message"];
1536
1549
  if (!msg || msg["model"] === "<synthetic>") continue;
1537
1550
  const model = msg["model"] || "";
@@ -1785,6 +1798,7 @@ async function start() {
1785
1798
  process.once("SIGINT", sigintHandler);
1786
1799
  claude.spawn();
1787
1800
  setTimeout(() => {
1801
+ historySvc.detectCurrentConversation();
1788
1802
  historySvc.load().catch(() => {
1789
1803
  });
1790
1804
  }, 2e3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "1.4.16",
3
+ "version": "1.4.18",
4
4
  "description": "Remote control Claude Code from your mobile device",
5
5
  "main": "dist/index.js",
6
6
  "bin": {