fix: derive green pallino from git status instead of in-memory tracker

The green dot (new note indicator) was disappearing after Cmd+S because
markSaved cleared it from the in-memory newPaths set. Now resolveNoteStatus
derives "new" status from git status (untracked/added files) so the green
dot persists until the note is committed. The in-memory tracker is only
used for the brief window between note creation and first save to disk.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-02-24 22:20:22 +01:00
parent 3ea175eec5
commit 8b44ebbc22
7 changed files with 77 additions and 48 deletions

View File

@@ -107,13 +107,10 @@ describe('useEditorSave', () => {
})
})
it.each([
{ name: 'onAfterSave', key: 'onAfterSave' as const },
{ name: 'onNoteSaved', key: 'onNoteSaved' as const },
])('calls $name callback after successful save', async ({ key }) => {
it('calls onAfterSave callback after successful save', async () => {
const cb = vi.fn()
const { result } = renderHook(() =>
useEditorSave({ updateVaultContent, setTabs, setToastMessage, [key]: cb })
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onAfterSave: cb })
)
act(() => {
@@ -142,15 +139,12 @@ describe('useEditorSave', () => {
expect(onAfterSave).toHaveBeenCalledOnce()
})
it.each([
{ name: 'onAfterSave', key: 'onAfterSave' as const },
{ name: 'onNoteSaved', key: 'onNoteSaved' as const },
])('does not call $name when save fails', async ({ key }) => {
it('does not call onAfterSave when save fails', async () => {
mockInvokeFn.mockRejectedValueOnce(new Error('Disk full'))
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const cb = vi.fn()
const { result } = renderHook(() =>
useEditorSave({ updateVaultContent, setTabs, setToastMessage, [key]: cb })
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onAfterSave: cb })
)
act(() => {