Fix: Always save notes to default session when no session is active - #13
Merged
Conversation
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.
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.
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:
session-20251214-143045) would be createdNew behavior:
id="default",name="default") when no session is activeAdditionally, refactored the session determination logic by extracting a helper function to reduce code duplication across note commands.
Changes
Core fix:
lua/tabi/session.luaget_or_create_default()to properly create and save a default session with fixedid="default"andname="default"Consistency fix:
plugin/tabi.luanote deletecommand use the same session logic asnoteandnote editcommandsRefactoring:
plugin/tabi.luaget_session_for_note_operation()helper function to centralize session determination logicTest plan