Add bulk thread naming command and automatic naming for new threads#150
Merged
Conversation
Add a constant MAX_HISTORY (20) to cap the number of stored history items, both when loading from file and after appending new submissions.
This commit also fixes a bug in the TUI where updating a non-active thread could incorrectly switch the active chat view.
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.
Overview
This change introduces a new
/thread name-allcommand that allows users to retroactively generate names for existing unnamed threads, and adds automatic thread naming for new chat threads. The implementation uses the existinglow_cost_searchmodel profile with a dedicated thread-naming prompt, keeping the cost and latency low while ensuring consistent naming across threads. Additionally, the change includes a bug fix in the TUI thread update event handling and introduces a cap on the input command history size.What This Means for Users
/thread name-allcommand: Users with multiple existing unnamed threads (threads created before automatic naming was available) can now retroactively assign meaningful names to all of them in a single operation. The command reports progress and a summary of how many threads were named, skipped, or failed.thread_a1b2c3d4) and makes it easier to find past conversations.docs/threads.mdnow document the new command, including example output.A Closer Look at the Changes
New Functionality: Thread Naming
/thread name-allsubcommand: Added a new subcommand to the/threadcommand family that iterates over all threads, identifies those with messages but no name, and invokes the LLM to generate a name based on the first user message. The command is registered in the argparse setup, the help text (both formatted and plain variants), and the command catalog shown to users.src/jrdev/prompts/conversation/thread_name.md): Defines the system prompt used to instruct the model to produce a concise thread name (15 letters or fewer) with a structuredThread name: <name>suffix for easy extraction.src/jrdev/services/message_service.py): Extracted two reusable pieces of functionality so that both the existing automatic-naming path and the new bulk command consume the same logic:THREAD_NAME_PATTERN: A regex that captures theThread name: <name>line from model output._sanitize_thread_name: Cleans the model output by stripping unsupported characters, collapsing whitespace, and enforcing a maximum length of 15 characters.src/jrdev/commands/thread.py:_thread_needs_name: Filters out the router thread and threads that already have a name._first_user_message: Returns the first user-authored message in a format safe to send to the LLM, stripping the internalUSER_INPUT_PREFIXmarker._extract_thread_name: Robustly extracts a thread name from model output by trying the canonical pattern, an XML-style tag, a "Thread name:" line, or a single-line response as fallbacks.Bug Fix: TUI Thread Update Event Handling
src/jrdev/ui/tui/textual_ui.py: Theon_chat_thread_updatehandler previously assumed the event always referenced the active thread, which caused the chat list to incorrectly mark a non-active thread as active and triggered a chat view reload. The handler now resolves the thread referenced by the event, preserves the user's actual active thread, and only refreshes the chat view when the updated thread is the currently active one.Code Refinements & Improvements
src/jrdev/ui/tui/terminal/input_widget.py): Introduced aMAX_HISTORY = 20constant applied both when loading history from disk and after each submit, preventing unbounded growth of the persisted history file.docs/threads.md): Added a "Naming Existing Threads" section describing the new command along with example output, and noted that the same model and prompt power both automatic and bulk naming.Generated by JrDev AI using minimax/minimax-m3