Repository navigation
Navigation store: reopen a restored Daily Journal tab on today's date - #3854
Merged
Merged
Conversation
mstomar125
commented
Oct 20, 2026
mstomar125
left a comment
Contributor
Author
There was a problem hiding this comment.
Review (initial) - #3854
Verdict: APPROVE WITH NITS
Reviewed at head, against #3836. Ran bun x vitest run src/tests/stores/navigation.test.ts in a throwaway worktree: 73 passed.
Requirements (#3836)
- Unit test: past-dated daily-journal tab shows today after load; non-daily-journal date tab untouched (
navigation.test.ts"Daily Journal date", 3 cases). - Midnight rollover with the app left open is explicitly noted as not handled in the PR body, as the issue allows.
Scenario check
- Stale persisted date (the reported bug): covered.
loadPersistedStatemaps restored tabs throughwithDailyJournalOnToday; onlyid === DAILY_JOURNAL_TAB_IDwith adatenode type andnodeId !== todayis rewritten. - Deliberately opened past day: safe. Tabs opened through
NavigationService.focusOrOpenNodeget a freshuuidv4()id (navigation-service.ts:523,:571), neverdaily-journal, so a past journal day the user opened on purpose is not matched. The test "leaves a date tab that is not the Daily Journal untouched" covers it. The one case that is rewritten is thedaily-journaltab itself after the user paged it with the arrows or navigated it in place (pane-content.svelte:227,navigation-service.ts:425/447). That is exactly what the issue asks for ("also if the user paged with the arrows"), so it is correct, but see nit 3. - Timezone / DST:
getTodayDateId()isformatDateISO(new Date()), i.e. the local calendar date, compared as a plainYYYY-MM-DDstring. No date arithmetic, so DST transitions cannot shift it. A state saved in one timezone and restored in another is simply compared against the local date at load, which is the desired behaviour. The test uses the local-timeDateconstructor, consistent with that. - Multiple tabs / panes: only the single tab with the reserved id is touched; the map preserves tab order and pane/
activeTabIdsreferences (the id is unchanged). Other tabs, including other date tabs, keep their state. - Title / expansion state:
expandedNodeIdsis dropped for a rewritten tab only (correct: those ids belong to the other day's nodes, andscheduleRestorationthen skips it); a tab already on today keeps it (tested). The rewrittentitleis cosmetic, because tab titles are derived at render (tab-system.svelte:301viacomputeTabTitle, and the date viewer shows "Today"). - A tab with missing
contentor a non-date type returns early (tab.content?.nodeType+isA), so a malformed persisted entry cannot throw.
Findings
- Non-blocking (nit)
packages/desktop-app/src/lib/stores/navigation.svelte.ts:181-186: the two-line comment ("The Daily Journal tab always opens on the current date...") is duplicated verbatim, and the blank line between the copies has trailing whitespace. Remove one copy. - Non-blocking (nit)
navigation.svelte.ts:185:persisted.tabs = ...mutates the object returned byTabPersistenceService.load(). Harmless today (fresh parse each call), but building the new tabs array into thestateassignment directly is cleaner and avoids surprising a future cachingload(). - Non-blocking (follow-up) midnight rollover: with the app left open overnight the
daily-journaltab stays on yesterday, and the sidebar "Daily Journal" button then opens a second tab for the new today (navigation-sidebar.svelte:~250,matchNodeType) rather than re-pointing the journal tab. Fine per the issue, but worth a tracking issue so it is not forgotten. - Non-blocking (test gap) no test for a non-date
content.nodeTypeon thedaily-journalid (the in-place-navigated-to-a-regular-node case, which must stay untouched), nor for a two-pane layout. The code path is covered by the early return; a one-line test would lock it. - Informational a
daily-journaltab navigated in place to a non-date node restores that node forever (pre-existing, out of scope here).
No security or performance concerns. Docs: none needed.
loadPersistedState rewrote nothing, so the daily-journal tab kept the date it was saved with. withDailyJournalOnToday re-points a date-typed daily-journal tab at the current local date, updates its title and drops its saved expansion state; other tabs are untouched. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ly-journal tab is kept Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mstomar125
force-pushed
the
fix/3836-daily-journal-today
branch
from
October 20, 2026 11:29
11e72bc to
1c0f963
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
loadPersistedStatenow passes restored tabs throughwithDailyJournalOnToday: a tab withid === DAILY_JOURNAL_TAB_IDwhose node type is a date and whosenodeIdis not today (local date) is re-pointed at today, its title set to the date, and its savedexpandedNodeIdsdropped (they belong to the other day's nodes). Other tabs, including other date tabs, are untouched. Node type is resolved withisA(ADR-086 gate).Midnight rollover with the app left open is not handled here (separate from restore, as the issue allows).
Testing
bunx vitest run src/tests/stores/navigation.test.ts: 73 passed, with new cases: past-dated daily-journal tab shows today (title updated, expansion state dropped); tab already on today kept; non-daily-journal date tab untouched. Removing the fix makes the rewrite test fail.svelte-check: clean. Pre-push gate passed.Closes #3836
🤖 Generated with Claude Code