opencode-miniterm 1.0.6 → 1.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-miniterm",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A small front-end terminal UI for OpenCode",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
package/src/render.ts CHANGED
@@ -43,8 +43,12 @@ export function render(state: State, details = false): void {
43
43
  if (!part.text.trim()) continue;
44
44
 
45
45
  if (part.title === "thinking") {
46
+ const doc = parse(part.text.trimStart(), gfm);
47
+ let partText = ansi.stripAnsiCodes(renderToConsole(doc));
48
+
46
49
  // Show max 10 thinking lines
47
- const partText = details ? part.text.trimStart() : lastThinkingLines(part.text.trimStart());
50
+ partText = details ? partText : lastThinkingLines(partText);
51
+
48
52
  output += "<ocmt-thinking>\n";
49
53
  output += `💭 ${partText}\n\n`;
50
54
  output += "</ocmt-thinking>\n";
@@ -221,19 +225,27 @@ export function wrapText(text: string, width: number): string[] {
221
225
  }
222
226
  };
223
227
 
228
+ let atLineStart = true;
229
+ let lineIndent = "";
224
230
  while (i < text.length) {
225
231
  const char = text[i];
226
232
 
227
233
  if (char === "\n") {
228
234
  pushLine();
235
+ atLineStart = true;
236
+ lineIndent = "";
229
237
  i++;
230
238
  } else if (char === "\r") {
231
239
  i++;
232
240
  } else if (char === " " || char === "\t") {
241
+ if (atLineStart) {
242
+ lineIndent += char;
243
+ }
233
244
  i++;
234
245
  } else {
235
- let word = "";
236
- let wordVisibleLength = 0;
246
+ let word = lineIndent;
247
+ let wordVisibleLength = lineIndent.length;
248
+ atLineStart = false;
237
249
 
238
250
  while (i < text.length) {
239
251
  const char = text[i];
@@ -256,6 +268,7 @@ export function wrapText(text: string, width: number): string[] {
256
268
  }
257
269
 
258
270
  addWord(word, wordVisibleLength);
271
+ atLineStart = false;
259
272
  }
260
273
  }
261
274
 
@@ -344,6 +344,11 @@ describe("wrapText", () => {
344
344
  const result = wrapText("line1\n\nline3", 20);
345
345
  expect(result).toEqual([" line1", " ", " line3"]);
346
346
  });
347
+
348
+ it("should preserve indents", () => {
349
+ const result = wrapText("line1\n line2\n line3", 20);
350
+ expect(result).toEqual([" line1", " line2", " line3"]);
351
+ });
347
352
  });
348
353
 
349
354
  describe("ANSI codes", () => {