vscode-pi-companion 0.2.10 → 0.2.11

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.
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
+ import { Text } from "@earendil-works/pi-tui";
8
9
  import * as fs from "fs";
9
10
  import * as path from "path";
10
11
  import * as os from "os";
@@ -135,21 +136,25 @@ async function getLivePort(): Promise<number | undefined> {
135
136
  return (await isPortAlive(info.port)) ? info.port : undefined;
136
137
  }
137
138
 
139
+ function setWidget(text: string): void {
140
+ currentCtx?.ui.setWidget("pi-companion", () => new Text(text, 0, 0));
141
+ }
142
+
138
143
  function updateWidget(): void {
139
144
  if (!currentCtx) return;
140
145
 
141
146
  if (!isConnected) {
142
- currentCtx.ui.setWidget("pi-companion", ["vscode: disconnected"]);
147
+ setWidget("vscode: disconnected");
143
148
  return;
144
149
  }
145
150
 
146
151
  if (!currentContext) {
147
- currentCtx.ui.setWidget("pi-companion", ["vscode: connected"]);
152
+ setWidget("vscode: connected");
148
153
  return;
149
154
  }
150
155
 
151
156
  if (!currentContext.workspaceState.openFiles.length) {
152
- currentCtx.ui.setWidget("pi-companion", ["vscode: no files"]);
157
+ setWidget("vscode: no files");
153
158
  return;
154
159
  }
155
160
 
@@ -162,17 +167,19 @@ function updateWidget(): void {
162
167
  let location = "";
163
168
  if (activeFile.selectionStart && activeFile.selectionEnd) {
164
169
  const start = activeFile.selectionStart.line;
165
- const end = activeFile.selectionEnd.line;
170
+ const end = activeFile.selectionEnd.character === 1 && activeFile.selectionEnd.line > start
171
+ ? activeFile.selectionEnd.line - 1
172
+ : activeFile.selectionEnd.line;
166
173
  location = start === end ? ` L${start}` : ` L${start}:${end}`;
167
174
  }
168
175
  const label = filenames.length === 1
169
176
  ? `${filename}${location}`
170
177
  : `${filename}${location} +${filenames.length - 1}`;
171
- currentCtx.ui.setWidget("pi-companion", [label]);
178
+ setWidget(label);
172
179
  return;
173
180
  }
174
181
 
175
- currentCtx.ui.setWidget("pi-companion", [filenames.join(", ")]);
182
+ setWidget(filenames.join(", "));
176
183
  }
177
184
 
178
185
  async function connectSSE(): Promise<void> {
@@ -4,6 +4,7 @@
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
6
  "@earendil-works/pi-coding-agent": "*",
7
+ "@earendil-works/pi-tui": "*",
7
8
  "typebox": "*"
8
9
  }
9
10
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "displayName": "PI Companion",
4
4
  "description": "Share VS Code context with pi coding agent",
5
5
  "repository": "https://github.com/ravshansbox/vscode-pi-companion",
6
- "version": "0.2.10",
6
+ "version": "0.2.11",
7
7
  "publisher": "ravshansbox",
8
8
  "keywords": [
9
9
  "pi-package"