Skip to content

Remember last model used #194

Closed
Closed

Description

@AnthonyRonning

There should be logic in the model selector/dropdown for last model used. I think however this is only applying to session storage? refreshing the app will remove it.

Can we store it a bit more semi-permentantly? maybe local storage or something? that way an app restart or fresh will still show the last model used.

Though keep in mind that we need to maintain the logic that uses the model that was last used in a specific chat, if it is in a specific chat.

Activity

  1. AnthonyRonning commented on Aug 15, 2025

    @AnthonyRonning
    ContributorAuthor

    @claude can you handle this? existing behavior should be maintained but swap it out for more persistant storage (client side).

  2. claude commented on Aug 15, 2025

    @claude
    Contributor

    Claude finished @AnthonyRonning's task —— View job • claude/issue-194-20250815-0321 • Create PR ➔


    Todo List

    • Analyze current model selector implementation
    • Find session storage usage for model persistence
    • Replace session storage with local storage
    • Ensure chat-specific model logic is preserved
    • Run formatting, linting, and build commands
    • Commit and push changes

    ✅ Implementation Complete

    Problem Found: The global model selector state wasn't being persisted - it reset to the default model on app refresh/restart.

    Solution: Added localStorage persistence to LocalStateContext.tsx:

    • getInitialModel(): Loads last used model from localStorage with proper fallback logic (dev override → localStorage → default)
    • saveModelToStorage(): Saves model selection to localStorage with error handling
    • Enhanced setModel(): Now saves to localStorage when model changes
    • Preserved chat-specific logic: Individual chats continue to remember their own model as before

    Key Features:

    • ✅ Global model selector now persists across app restarts
    • ✅ Chat-specific model behavior unchanged
    • ✅ Proper fallback hierarchy with error handling
    • ✅ All existing functionality maintained
  3. added a commit that references this issue on Aug 15, 2025
    7e697d7
  4. AnthonyRonning commented on Aug 15, 2025

    @AnthonyRonning
    ContributorAuthor

    @claude - try this again. except do NOT make any new methods or change the existing behavior. I already have methods that set/retrieve the model based on various conditions. Respect those existing methods but store/retrieve from local storage instead.

  5. claude commented on Aug 15, 2025

    @claude
    Contributor

    Claude finished @AnthonyRonning's task —— View job • claude/issue-194-20250815-0348 • Create PR ➔


    Todo List

    • Analyze current model selector implementation to find existing methods
    • Locate sessionStorage usage for model persistence
    • Replace sessionStorage with localStorage without changing existing method behavior
    • Verify chat-specific model logic is preserved
    • Run format, lint, and build commands
    • Commit and push changes

    ✅ Implementation Complete

    Problem: Model selection was only stored in memory - refreshing the app would reset to default model.

    Solution: Added localStorage persistence to existing methods in LocalStateContext.tsx:

    1. Initialization (line 31-39): Load model from localStorage with fallback hierarchy:

      • VITE_DEV_MODEL_OVERRIDE (dev environment)
      • localStorage.getItem("selectedModel") (user's last selection)
      • DEFAULT_MODEL_ID (fallback)
    2. setModel function (lines 271-282): Save to localStorage whenever model changes, with error handling

    Chat-specific logic preserved: Individual chats still load their specific model via setModel(localChat.model) in the chat route (line 314).

    Key Features:

    • ✅ Global model selector persists across app restarts
    • ✅ Existing methods and behavior unchanged
    • ✅ Chat-specific model logic preserved
    • ✅ Error handling for localStorage failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions