You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(file-preview): attribute events to source tools (#479)
* fix(file-preview): attribute events to source tools
File preview UI events were always reported as read_file, which hid whether the preview came from write_file or edit_block. Carry sourceTool through structured content so analytics reflects the initiating tool.
Move default editor detection out of the browser UI and onto the server as a lazy macOS-only cached lookup. This avoids repeated hidden start_process/osascript calls from the preview and keeps command execution in server code.
* fix(file-preview): harden editor metadata lookup
Narrow sourceTool to the known file-preview tool names so telemetry attribution cannot drift silently.
Cache failed default-editor detections briefly and keep getDefaultEditorMetadata best-effort so editor metadata lookup cannot repeatedly spawn osascript or break successful file operations.
constscript=`set appAlias to default application of (info for POSIX file "${escapeAppleScriptString(filePath)}")\nreturn (name of (info for appAlias)) & linefeed & POSIX path of appAlias`;
@@ -306,20 +306,23 @@ async function testReadFilePreviewMetadata() {
306
306
assert.ok(markdownResult.structuredContent,'Markdown should include structuredContent');
307
307
assert.strictEqual(markdownResult.structuredContent.fileType,'markdown','Markdown fileType should be markdown');
308
308
assert.strictEqual(markdownResult.structuredContent.filePath,MD_FILE,'Markdown file path should be present');
309
+
assert.strictEqual(markdownResult.structuredContent.sourceTool,'read_file','Markdown preview should preserve source tool');
309
310
assert.strictEqual(markdownResult.structuredContent.content,markdownResult.content[0].text,'Markdown structuredContent should include returned content');
@@ -332,6 +335,7 @@ async function testReadFilePreviewMetadata() {
332
335
assert.strictEqual(imageResult.structuredContent.content,imageResult.structuredContent.imageData,'Image structuredContent should include file content');
333
336
assert.strictEqual(imageResult.structuredContent.mimeType,'image/png','Image structured payload should include mimeType');
334
337
assert.strictEqual(imageResult.structuredContent.filePath,IMAGE_FILE,'Image file path should be present');
338
+
assert.strictEqual(imageResult.structuredContent.sourceTool,'read_file','Image preview should preserve source tool');
0 commit comments