@selesai/code 0.1.17 → 0.1.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.
@@ -28,7 +28,6 @@ import { getChangelogPath, getNewEntries, normalizeChangelogLinks, parseChangelo
28
28
  import { copyToClipboard } from "../../utils/clipboard.js";
29
29
  import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
30
30
  import { parseGitUrl } from "../../utils/git.js";
31
- import { formatDimensionNote, resizeImage } from "../../utils/image-resize.js";
32
31
  import { getCwdRelativePath } from "../../utils/paths.js";
33
32
  import { getPiUserAgent } from "../../utils/pi-user-agent.js";
34
33
  import { killTrackedDetachedChildren } from "../../utils/shell.js";
@@ -152,7 +151,6 @@ export class InteractiveMode {
152
151
  isInitialized = false;
153
152
  onInputCallback;
154
153
  pendingUserInputs = [];
155
- pendingInputImages = [];
156
154
  loadingAnimation = undefined;
157
155
  workingMessage = undefined;
158
156
  workingVisible = true;
@@ -1995,66 +1993,27 @@ export class InteractiveMode {
1995
1993
  try {
1996
1994
  const image = await readClipboardImage();
1997
1995
  if (!image) {
1998
- this.showWarning("No image found in clipboard");
1999
1996
  return;
2000
1997
  }
1998
+ // Write to temp file
2001
1999
  const tmpDir = os.tmpdir();
2002
2000
  const ext = extensionForImageMimeType(image.mimeType) ?? "png";
2003
- const fileName = `pi-clipboard-${Date.now()}-${this.pendingInputImages.length + 1}.${ext}`;
2001
+ const fileName = `pi-clipboard-${crypto.randomUUID()}.${ext}`;
2004
2002
  const filePath = path.join(tmpDir, fileName);
2005
2003
  fs.writeFileSync(filePath, Buffer.from(image.bytes));
2006
- let attachment;
2007
- let dimensionNote;
2008
- const autoResizeImages = this.settingsManager.getImageAutoResize();
2009
- if (autoResizeImages) {
2010
- const resized = await resizeImage(image.bytes, image.mimeType).catch(() => null);
2011
- if (!resized) {
2012
- this.showWarning("Clipboard image attached without resize");
2013
- attachment = {
2014
- type: "image",
2015
- mimeType: image.mimeType,
2016
- data: Buffer.from(image.bytes).toString("base64"),
2017
- };
2018
- }
2019
- else {
2020
- dimensionNote = formatDimensionNote(resized);
2021
- attachment = {
2022
- type: "image",
2023
- mimeType: resized.mimeType,
2024
- data: resized.data,
2025
- };
2026
- }
2027
- }
2028
- else {
2029
- attachment = {
2030
- type: "image",
2031
- mimeType: image.mimeType,
2032
- data: Buffer.from(image.bytes).toString("base64"),
2033
- };
2034
- }
2035
- this.pendingInputImages.push(attachment);
2036
- const label = dimensionNote ? `${filePath} ${dimensionNote}` : filePath;
2037
- this.editor.insertTextAtCursor?.(label);
2004
+ // Insert file path directly
2005
+ this.editor.insertTextAtCursor?.(filePath);
2038
2006
  this.ui.requestRender();
2039
2007
  }
2040
- catch (error) {
2041
- this.showWarning(`Failed to paste image: ${error instanceof Error ? error.message : String(error)}`);
2042
- }
2043
- }
2044
- consumePendingInputImages() {
2045
- if (this.pendingInputImages.length === 0) {
2046
- return undefined;
2008
+ catch {
2009
+ // Silently ignore clipboard errors (may not have permission, etc.)
2047
2010
  }
2048
- const images = this.pendingInputImages;
2049
- this.pendingInputImages = [];
2050
- return images;
2051
2011
  }
2052
2012
  setupEditorSubmitHandler() {
2053
2013
  this.defaultEditor.onSubmit = async (text) => {
2054
2014
  text = text.trim();
2055
2015
  if (!text)
2056
2016
  return;
2057
- const images = this.consumePendingInputImages();
2058
2017
  // Handle commands
2059
2018
  if (text === "/settings") {
2060
2019
  this.showSettingsSelector();
@@ -2205,10 +2164,10 @@ export class InteractiveMode {
2205
2164
  if (this.isExtensionCommand(text)) {
2206
2165
  this.editor.addToHistory?.(text);
2207
2166
  this.editor.setText("");
2208
- await this.session.prompt(text, { images });
2167
+ await this.session.prompt(text);
2209
2168
  }
2210
2169
  else {
2211
- this.queueCompactionMessage(text, "steer", images);
2170
+ this.queueCompactionMessage(text, "steer");
2212
2171
  }
2213
2172
  return;
2214
2173
  }
@@ -2217,7 +2176,7 @@ export class InteractiveMode {
2217
2176
  if (this.session.isStreaming) {
2218
2177
  this.editor.addToHistory?.(text);
2219
2178
  this.editor.setText("");
2220
- await this.session.prompt(text, { streamingBehavior: "steer", images });
2179
+ await this.session.prompt(text, { streamingBehavior: "steer" });
2221
2180
  this.updatePendingMessagesDisplay();
2222
2181
  this.ui.requestRender();
2223
2182
  return;
@@ -2225,7 +2184,7 @@ export class InteractiveMode {
2225
2184
  // Normal message submission
2226
2185
  // First, move any pending bash components to chat
2227
2186
  this.flushPendingBashComponents();
2228
- const input = { text, images };
2187
+ const input = { text };
2229
2188
  if (this.onInputCallback) {
2230
2189
  this.onInputCallback(input);
2231
2190
  }
@@ -2923,24 +2882,22 @@ export class InteractiveMode {
2923
2882
  return;
2924
2883
  // Queue input during compaction (extension commands execute immediately)
2925
2884
  if (this.session.isCompacting) {
2926
- const images = this.consumePendingInputImages();
2927
2885
  if (this.isExtensionCommand(text)) {
2928
2886
  this.editor.addToHistory?.(text);
2929
2887
  this.editor.setText("");
2930
- await this.session.prompt(text, { images });
2888
+ await this.session.prompt(text);
2931
2889
  }
2932
2890
  else {
2933
- this.queueCompactionMessage(text, "followUp", images);
2891
+ this.queueCompactionMessage(text, "followUp");
2934
2892
  }
2935
2893
  return;
2936
2894
  }
2937
2895
  // Alt+Enter queues a follow-up message (waits until agent finishes)
2938
2896
  // This handles extension commands (execute immediately), prompt template expansion, and queueing
2939
2897
  if (this.session.isStreaming) {
2940
- const images = this.consumePendingInputImages();
2941
2898
  this.editor.addToHistory?.(text);
2942
2899
  this.editor.setText("");
2943
- await this.session.prompt(text, { streamingBehavior: "followUp", images });
2900
+ await this.session.prompt(text, { streamingBehavior: "followUp" });
2944
2901
  this.updatePendingMessagesDisplay();
2945
2902
  this.ui.requestRender();
2946
2903
  }
@@ -3083,7 +3040,6 @@ export class InteractiveMode {
3083
3040
  // =========================================================================
3084
3041
  clearEditor() {
3085
3042
  this.editor.setText("");
3086
- this.pendingInputImages = [];
3087
3043
  this.ui.requestRender();
3088
3044
  }
3089
3045
  showError(errorMessage) {