paneful 0.5.1 → 0.5.2

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.
@@ -229,9 +229,7 @@ function startServer(devMode, port) {
229
229
  return;
230
230
  }
231
231
  const processes = stdout.trim().split('\n').map((p) => p.trim()).filter(Boolean);
232
- console.log('[active-editor] processes:', processes);
233
232
  const editorProcess = processes.find((p) => editorPatterns.some((pat) => p.toLowerCase().includes(pat)));
234
- console.log('[active-editor] matched:', editorProcess ?? 'none');
235
233
  if (!editorProcess) {
236
234
  res.json({ projectName: null });
237
235
  return;
@@ -247,22 +245,29 @@ function startServer(devMode, port) {
247
245
  end tell
248
246
  return ""
249
247
  `;
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');
248
+ execFile('osascript', ['-e', titleScript], { timeout: 2000 }, (err2, stdout2) => {
253
249
  if (err2 || !stdout2.trim()) {
254
250
  res.json({ projectName: null });
255
251
  return;
256
252
  }
257
253
  const title = stdout2.trim();
258
- // Editor titles: "file — project — Editor" or "project — Editor"
259
- const parts = title.split(' \u2014 ');
260
254
  let projectName = null;
261
- if (parts.length >= 3) {
262
- projectName = parts[parts.length - 2];
255
+ // Try to extract a path from the title (e.g. "~/Documents/source/foo - branch")
256
+ const pathMatch = title.match(/^(~?\/[^\s]+)/);
257
+ if (pathMatch) {
258
+ // Grab the deepest folder from the path
259
+ const segments = pathMatch[1].replace(/\/$/, '').split('/');
260
+ projectName = segments[segments.length - 1] || null;
263
261
  }
264
- else if (parts.length === 2) {
265
- projectName = parts[0];
262
+ // Fallback: default title format "file — project — Editor" or "project — Editor"
263
+ if (!projectName) {
264
+ const parts = title.split(' \u2014 ');
265
+ if (parts.length >= 3) {
266
+ projectName = parts[parts.length - 2];
267
+ }
268
+ else if (parts.length === 2) {
269
+ projectName = parts[0];
270
+ }
266
271
  }
267
272
  res.json({ projectName });
268
273
  });