codeam-cli 1.4.43 → 1.4.45

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 +43 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
116
116
  // package.json
117
117
  var package_default = {
118
118
  name: "codeam-cli",
119
- version: "1.4.43",
119
+ version: "1.4.45",
120
120
  description: "Remote control Claude Code from your mobile device",
121
121
  main: "dist/index.js",
122
122
  bin: {
@@ -1178,14 +1178,26 @@ var OutputService = class _OutputService {
1178
1178
  /** Max idle with no visible content (spinner only) before finalizing. */
1179
1179
  static EMPTY_TIMEOUT_MS = 6e4;
1180
1180
  static MAX_MS = 12e4;
1181
- /** Called by the terminal-turn callback after posting the user message. */
1182
- startTerminalTurn() {
1181
+ /**
1182
+ * Called by the terminal-turn callback once the user message is known.
1183
+ * Sequences: clear → user_message (if any) → new_turn → start timer.
1184
+ * This guarantees the user message appears before the typing placeholder
1185
+ * in the apps, with no race against the clear event.
1186
+ */
1187
+ async startTerminalTurn(userText) {
1183
1188
  this.terminalTurnPending = false;
1184
- this.newTurn();
1185
- }
1186
- /** Post a user_message chunk so apps display what was typed in the terminal. */
1187
- postUserMessage(text) {
1188
- return this.postChunk({ type: "user_message", content: text, done: true });
1189
+ this.stopPoll();
1190
+ this.rawBuffer = "";
1191
+ this.lastSentContent = "";
1192
+ this.lastPushTime = 0;
1193
+ this.active = true;
1194
+ this.startTime = Date.now();
1195
+ await this.postChunk({ clear: true });
1196
+ if (userText) {
1197
+ await this.postChunk({ type: "user_message", content: userText, done: true });
1198
+ }
1199
+ await this.postChunk({ type: "new_turn", content: "", done: false });
1200
+ this.pollTimer = setInterval(() => this.tick(), _OutputService.POLL_MS);
1189
1201
  }
1190
1202
  newTurn() {
1191
1203
  this.stopPoll();
@@ -1515,13 +1527,28 @@ var HistoryService = class {
1515
1527
  getCurrentConversationId() {
1516
1528
  return this.currentConversationId;
1517
1529
  }
1518
- /** Return the text of the last user message in the current conversation, or null. */
1519
- getLastUserMessage() {
1520
- if (!this.currentConversationId) return null;
1530
+ /** Return the current message count in the active conversation. */
1531
+ getCurrentMessageCount() {
1532
+ if (!this.currentConversationId) return 0;
1521
1533
  const filePath = path4.join(this.projectDir, `${this.currentConversationId}.jsonl`);
1522
- const messages = parseJsonl(filePath);
1523
- for (let i = messages.length - 1; i >= 0; i--) {
1524
- if (messages[i].role === "user") return messages[i].text;
1534
+ return parseJsonl(filePath).length;
1535
+ }
1536
+ /**
1537
+ * Poll the JSONL until a new user message appears after previousCount entries.
1538
+ * Returns the text of the new user message, or null if not found within timeoutMs.
1539
+ */
1540
+ async waitForNewUserMessage(previousCount, timeoutMs = 4e3) {
1541
+ const deadline = Date.now() + timeoutMs;
1542
+ while (Date.now() < deadline) {
1543
+ if (!this.currentConversationId) return null;
1544
+ const filePath = path4.join(this.projectDir, `${this.currentConversationId}.jsonl`);
1545
+ const messages = parseJsonl(filePath);
1546
+ if (messages.length > previousCount) {
1547
+ for (let i = messages.length - 1; i >= previousCount; i--) {
1548
+ if (messages[i].role === "user") return messages[i].text;
1549
+ }
1550
+ }
1551
+ await new Promise((r) => setTimeout(r, 150));
1525
1552
  }
1526
1553
  return null;
1527
1554
  }
@@ -1886,14 +1913,8 @@ except Exception:sys.exit(0)
1886
1913
  fetchQuotaUsage();
1887
1914
  }
1888
1915
  }, () => {
1889
- setTimeout(async () => {
1890
- const userText = historySvc.getLastUserMessage();
1891
- if (userText) {
1892
- await outputSvc.postUserMessage(userText).catch(() => {
1893
- });
1894
- }
1895
- outputSvc.startTerminalTurn();
1896
- }, 300);
1916
+ const prevCount = historySvc.getCurrentMessageCount();
1917
+ historySvc.waitForNewUserMessage(prevCount).then((userText) => outputSvc.startTerminalTurn(userText ?? void 0)).catch(() => outputSvc.startTerminalTurn(void 0));
1897
1918
  });
1898
1919
  function sendPrompt(prompt) {
1899
1920
  outputSvc.newTurn();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "1.4.43",
3
+ "version": "1.4.45",
4
4
  "description": "Remote control Claude Code from your mobile device",
5
5
  "main": "dist/index.js",
6
6
  "bin": {