opencode-miniterm 1.0.18 → 1.0.19

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/bun.lock CHANGED
@@ -5,7 +5,7 @@
5
5
  "": {
6
6
  "name": "opencode-miniterm",
7
7
  "dependencies": {
8
- "@opencode-ai/sdk": "^1.2.25",
8
+ "@opencode-ai/sdk": "^1.2.27",
9
9
  "allmark": "^1.0.2",
10
10
  },
11
11
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-miniterm",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "A small front-end terminal UI for OpenCode",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
@@ -99,6 +99,7 @@ async function handleKey(state: State, key: Key, str?: string) {
99
99
  config.agentID = selected.id;
100
100
  saveConfig();
101
101
  const activeDisplay = await getActiveDisplay(state.client);
102
+ console.log();
102
103
  console.log(activeDisplay);
103
104
  console.log();
104
105
  }
@@ -116,6 +116,7 @@ async function handleKey(state: State, key: Key, str?: string) {
116
116
  config.modelID = selected.modelID;
117
117
  saveConfig();
118
118
  const activeDisplay = await getActiveDisplay(state.client);
119
+ console.log();
119
120
  console.log(activeDisplay);
120
121
  console.log();
121
122
  }
@@ -135,6 +135,7 @@ async function handleKey(state: State, key: Key, str?: string) {
135
135
  if (selected) {
136
136
  config.sessionIDs[process.cwd()] = selected.id;
137
137
  saveConfig();
138
+ console.log();
138
139
  console.log(`Switched to session: ${selected.id.substring(0, 8)}...`);
139
140
  if (selected.title) {
140
141
  console.log(` Title: ${selected.title}`);
package/src/input.ts CHANGED
@@ -59,8 +59,9 @@ export function renderLine(): void {
59
59
  // Move to the start of the line (i.e. the prompt position)
60
60
  process.stdout.write(ansi.CURSOR_HOME);
61
61
  if (oldWrappedRows > 0) {
62
- if (cursorPosition < inputBuffer.length) {
63
- process.stdout.write(ansi.CURSOR_DOWN(oldWrappedRows - oldCursorRow));
62
+ let rowsToMove = oldWrappedRows - oldCursorRow;
63
+ if (cursorPosition < inputBuffer.length && rowsToMove > 0) {
64
+ process.stdout.write(ansi.CURSOR_DOWN(rowsToMove));
64
65
  }
65
66
  process.stdout.write(ansi.CURSOR_UP(oldWrappedRows));
66
67
  }
@@ -75,17 +76,12 @@ export function renderLine(): void {
75
76
  if (oldInputBuffer[i] !== inputBuffer[i]) {
76
77
  break;
77
78
  }
78
- if (inputBuffer[i] === "\n") {
79
+ if (currentCol >= consoleWidth) {
80
+ currentCol = 0;
79
81
  currentRow++;
80
- currentCol = 2;
81
- } else {
82
- if (currentCol >= consoleWidth) {
83
- currentCol = 0;
84
- currentRow++;
85
- newWrappedRows++;
86
- }
87
- currentCol++;
82
+ newWrappedRows++;
88
83
  }
84
+ currentCol++;
89
85
  start++;
90
86
  }
91
87
 
@@ -112,48 +108,31 @@ export function renderLine(): void {
112
108
  // Write the changes from the new input buffer
113
109
  let renderExtent = Math.max(cursorPosition + 1, inputBuffer.length);
114
110
  for (let i = start; i < renderExtent; i++) {
115
- if (i < inputBuffer.length && inputBuffer[i] === "\n") {
111
+ if (currentCol >= consoleWidth) {
116
112
  process.stdout.write("\n");
117
- currentRow++;
118
- currentCol = 2;
119
- } else {
120
- if (currentCol >= consoleWidth) {
121
- process.stdout.write("\n");
122
- currentCol = 0;
123
- newWrappedRows++;
124
- }
125
- if (i < inputBuffer.length) {
126
- process.stdout.write(inputBuffer[i]!);
127
- }
128
- currentCol++;
113
+ currentCol = 0;
114
+ newWrappedRows++;
129
115
  }
116
+ if (i < inputBuffer.length) {
117
+ process.stdout.write(inputBuffer[i]!);
118
+ }
119
+ currentCol++;
130
120
  }
131
121
 
132
122
  // Calculate and move to the cursor's position
133
- let row = 0;
134
- let col = 2;
135
- for (let i = 0; i < cursorPosition; i++) {
136
- if (i < inputBuffer.length && inputBuffer[i] === "\n") {
137
- row++;
138
- col = 2;
139
- } else {
140
- col++;
141
- if (col >= consoleWidth) {
142
- row++;
143
- col = 0;
144
- }
145
- }
146
- }
123
+ let absolutePos = 2 + cursorPosition;
124
+ let newCursorRow = Math.floor(absolutePos / consoleWidth);
125
+ let newCursorCol = absolutePos % consoleWidth;
147
126
  process.stdout.write(ansi.CURSOR_HOME);
148
- let rowsToMove = newWrappedRows - row;
127
+ let rowsToMove = newWrappedRows - newCursorRow;
149
128
  if (rowsToMove > 0) {
150
129
  process.stdout.write(ansi.CURSOR_UP(rowsToMove));
151
130
  }
152
- process.stdout.write(ansi.CURSOR_COL(col));
131
+ process.stdout.write(ansi.CURSOR_COL(newCursorCol));
153
132
 
154
133
  oldInputBuffer = inputBuffer;
155
134
  oldWrappedRows = newWrappedRows;
156
- oldCursorRow = row;
135
+ oldCursorRow = newCursorRow;
157
136
  }
158
137
 
159
138
  export async function handleKeyPress(state: State, str: string, key: Key) {