paneful 0.5.0 → 0.5.1
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/dist/server/index.js +44 -24
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -210,42 +210,62 @@ function startServer(devMode, port) {
|
|
|
210
210
|
res.json({ projectName: null });
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
// Step 1: Find editor processes dynamically — match known editor keywords
|
|
214
|
+
const editorPatterns = ['cursor', 'code', 'vscode', 'visual studio code', 'zed', 'windsurf'];
|
|
215
|
+
const findScript = `
|
|
214
216
|
tell application "System Events"
|
|
215
|
-
set
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if exists front window then
|
|
220
|
-
return name of front window
|
|
221
|
-
end if
|
|
222
|
-
end tell
|
|
223
|
-
end if
|
|
217
|
+
set procNames to name of every process whose background only is false
|
|
218
|
+
set output to ""
|
|
219
|
+
repeat with p in procNames
|
|
220
|
+
set output to output & p & linefeed
|
|
224
221
|
end repeat
|
|
222
|
+
return output
|
|
225
223
|
end tell
|
|
226
|
-
return ""
|
|
227
224
|
`;
|
|
228
|
-
execFile('osascript', ['-e',
|
|
225
|
+
execFile('osascript', ['-e', findScript], { timeout: 2000 }, (err, stdout, stderr) => {
|
|
229
226
|
if (err) {
|
|
230
227
|
const needsAccess = stderr?.includes('not allowed assistive access') || stderr?.includes('1719');
|
|
231
228
|
res.json({ projectName: null, needsAccessibility: needsAccess || undefined });
|
|
232
229
|
return;
|
|
233
230
|
}
|
|
234
|
-
|
|
231
|
+
const processes = stdout.trim().split('\n').map((p) => p.trim()).filter(Boolean);
|
|
232
|
+
console.log('[active-editor] processes:', processes);
|
|
233
|
+
const editorProcess = processes.find((p) => editorPatterns.some((pat) => p.toLowerCase().includes(pat)));
|
|
234
|
+
console.log('[active-editor] matched:', editorProcess ?? 'none');
|
|
235
|
+
if (!editorProcess) {
|
|
235
236
|
res.json({ projectName: null });
|
|
236
237
|
return;
|
|
237
238
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
239
|
+
// Step 2: Get the front window title of the matched editor
|
|
240
|
+
const titleScript = `
|
|
241
|
+
tell application "System Events"
|
|
242
|
+
tell process "${editorProcess.replace(/"/g, '\\"')}"
|
|
243
|
+
if exists front window then
|
|
244
|
+
return name of front window
|
|
245
|
+
end if
|
|
246
|
+
end tell
|
|
247
|
+
end tell
|
|
248
|
+
return ""
|
|
249
|
+
`;
|
|
250
|
+
execFile('osascript', ['-e', titleScript], { timeout: 2000 }, (err2, stdout2, stderr2) => {
|
|
251
|
+
console.log('[active-editor] title stdout:', JSON.stringify(stdout2));
|
|
252
|
+
console.log('[active-editor] title err:', err2?.message ?? 'none');
|
|
253
|
+
if (err2 || !stdout2.trim()) {
|
|
254
|
+
res.json({ projectName: null });
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const title = stdout2.trim();
|
|
258
|
+
// Editor titles: "file — project — Editor" or "project — Editor"
|
|
259
|
+
const parts = title.split(' \u2014 ');
|
|
260
|
+
let projectName = null;
|
|
261
|
+
if (parts.length >= 3) {
|
|
262
|
+
projectName = parts[parts.length - 2];
|
|
263
|
+
}
|
|
264
|
+
else if (parts.length === 2) {
|
|
265
|
+
projectName = parts[0];
|
|
266
|
+
}
|
|
267
|
+
res.json({ projectName });
|
|
268
|
+
});
|
|
249
269
|
});
|
|
250
270
|
});
|
|
251
271
|
// Resolve a dropped file's full path using OS file index (Spotlight on macOS)
|