Skip to content

Fix: Always save notes to default session when no session is active - #13

Merged
ushmz merged 3 commits into
mainfrom
feat/always-use-default-session
Dec 13, 2025
Merged

Fix: Always save notes to default session when no session is active#13
ushmz merged 3 commits into
mainfrom
feat/always-use-default-session

Conversation

@ushmz

@ushmz ushmz commented Dec 13, 2025

Copy link
Copy Markdown
Owner

Summary

Fixed the behavior so that note operations (:Tabi note, :Tabi note edit, :Tabi note delete) always save to a consistent default session when the user hasn't explicitly started a session with :Tabi start.

Previous behavior:

  • When adding a note without starting a session, a new session with a timestamp-based name (e.g., session-20251214-143045) would be created
  • This resulted in multiple unintended sessions accumulating over time

New behavior:

  • All notes are saved to a single default session (id="default", name="default") when no session is active
  • The default session is automatically created and persisted on first use
  • Subsequent note operations reuse the same default session

Additionally, refactored the session determination logic by extracting a helper function to reduce code duplication across note commands.

Changes

Core fix: lua/tabi/session.lua

  • Modified get_or_create_default() to properly create and save a default session with fixed id="default" and name="default"
  • Previously created timestamp-based sessions or returned unpersisted fallback objects

Consistency fix: plugin/tabi.lua

  • Made note delete command use the same session logic as note and note edit commands

Refactoring: plugin/tabi.lua

  • Extracted get_session_for_note_operation() helper function to centralize session determination logic
  • Reduced code duplication (42 lines removed, 28 added)

Test plan

  • All 364 existing tests pass
  • luacheck and stylua checks pass
  • Verified notes are saved to default session when no session is active
  • Verified default session persists across Neovim restarts

Modified get_or_create_default() to always create a session with
id="default" and name="default" when the default session doesn't exist,
and properly save it to storage backend.

Previously, the fallback session object was created inline but never
persisted, which could lead to inconsistent behavior.
Changed note delete command to use get_or_create_default() instead of
directly loading "default" session, making it consistent with note
create and note edit commands.

This ensures that when no session is active, all note commands
(create/edit/delete) use the same default session logic.
Introduced get_session_for_note_operation() helper function to
centralize the logic for determining which session to use (retrace,
current, or default) for note operations.

This eliminates code duplication across note, note_edit, and
note_delete commands, making the session selection logic consistent
and easier to maintain.
@ushmz
ushmz merged commit 00f4c39 into main Dec 13, 2025
4 checks passed
@ushmz
ushmz deleted the feat/always-use-default-session branch December 13, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant