experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(editor): set window title from item title for datastore-item editors

Previously the editor only called updateWindowTitle() when opened
with a file path; datastore-item editors fell through to the static
"Editor" fallback. Result: every note-editing window showed up in
the Windows switcher and other consumers as "editor" — visually
indistinguishable.

The window-presenter (the standard interface for window appearance)
reads win.getTitle(), which is what document.title propagates to.
Each window self-presents its title; consumers don't case-by-case.
This fix completes the editor's side of that contract:

- Track currentItemTitle alongside currentItemId on item load.
- updateWindowTitle resolves filename → currentItemTitle → "Editor".
- Re-fire updateWindowTitle when the autosave path detects a title
change (first heading edit, etc.) and when a deferred-new-note
item is first created.

+18 -2
+18 -2
features/editor/home.js
··· 24 24 25 25 // Autosave state 26 26 let currentItemId = null; 27 + let currentItemTitle = null; // Tracks the loaded item's title (datastore-item path) 27 28 let currentFilePath = null; // Tracks the open file on disk 28 29 let saveStatus = 'saved'; // 'saved' | 'saving' | 'unsaved' 29 30 let saveTimer = null; ··· 213 214 if (result.success && result.data) { 214 215 initialContent = result.data.content || ''; 215 216 currentItemId = itemIdParam; 217 + currentItemTitle = result.data.title || null; 216 218 hasExplicitSource = true; 217 219 debug && console.log('[editor] Loaded item from datastore:', itemIdParam); 218 220 ··· 252 254 updateWindowTitle(); 253 255 // Set base path for resolving relative image paths in preview 254 256 editorLayout.setBasePath(extractDirname(currentFilePath)); 257 + } else if (currentItemId) { 258 + updateWindowTitle(); 255 259 } 256 260 257 261 // Set up Cmd+O (open file) and Cmd+S (save file) keyboard shortcuts ··· 495 499 }; 496 500 497 501 /** 498 - * Update the window title and filename display to show the current filename. 502 + * Update the window title and filename display. 503 + * 504 + * Title resolution: filename (file path) → item title (datastore item) → 505 + * fallback "Editor". The window-presenter pulls win.getTitle() into its 506 + * canonical WindowPresentation, so consumers (Windows switcher, session 507 + * save) inherit whatever we set here without any per-feature awareness. 499 508 */ 500 509 const updateWindowTitle = () => { 501 510 const filename = currentFilePath ? extractFilename(currentFilePath) : null; 502 - const title = filename || 'Editor'; 511 + const title = filename || currentItemTitle || 'Editor'; 503 512 document.title = title; 504 513 if (api?.window?.setTitle) { 505 514 api.window.setTitle(title); ··· 639 648 saveStatus = 'saved'; 640 649 debug && console.log('[editor] Autosaved item:', currentItemId, 'title:', title); 641 650 651 + if (title !== currentItemTitle) { 652 + currentItemTitle = title; 653 + updateWindowTitle(); 654 + } 655 + 642 656 // Publish change event 643 657 if (api?.pubsub?.publish) { 644 658 api.pubsub.publish('editor:changed', { action: 'update', itemId: currentItemId }); ··· 669 683 const result = await api.datastore.addItem('text', { content, title }); 670 684 if (result.success && result.data) { 671 685 currentItemId = result.data.id; 686 + currentItemTitle = title || null; 687 + updateWindowTitle(); 672 688 debug && console.log('[editor] Created new note item on first content:', currentItemId); 673 689 674 690 // Tag with 'note' and 'from:cmd'