plans/2025-09-14-explicit-conversation-id-generation-v1.md
Implement explicit conversation ID generation to enable multiple terminal sessions to maintain separate conversation contexts. This approach eliminates output parsing challenges by requiring users to explicitly generate and manage conversation IDs.
Based on codebase analysis, I found:
--resume flag exists in crates/forge_main/src/cli.rs:64 and automatically loads the most recent conversationConversationId is a UUID-based type in crates/forge_domain/src/conversation.rs:15 with generate() and parse() methodshandle_resume() in crates/forge_main/src/ui.rs:265 uses api.last_conversation() to find the most recent conversationshell-plugin/forge.plugin.zsh:18 uses --resume without parametersget_conversation() method for retrieving specific conversations by IDTopLevelCommand::Term in crates/forge_main/src/cli.rs:100 handles terminal-related operationsTask 1.1: Add conversation ID generation parameter
--generate-conversation-id flag to CLI structureTask 1.2: Modify --resume to require conversation ID
--resume parameter to require --conversation-id argumentTask 1.3: Add --conversation-id parameter
--conversation-id parameter for specifying conversation IDConversationId::parse()Task 2.1: Implement conversation ID generation logic
handle_generate_conversation_id() method in UI layerConversationId::generate() method for ID creationTask 2.2: Update resume logic for explicit conversation loading
handle_resume() to use api.get_conversation() instead of api.last_conversation()Task 2.3: Update conversation creation to accept explicit IDs
Task 3.1: Create forge-term command for conversation ID generation
forge-term function to shell plugin for ID generationTask 3.2: Update command transformation for explicit conversation IDs
?? commands to use --resume --conversation-id $FORGE_CONVERSATION_ID? commands to use --conversation-id $FORGE_CONVERSATION_ID when availableTask 3.3: Add conversation ID lifecycle management
Task 4.1: Update API layer to support conversation ID parameters
Task 4.2: Update service layer for conversation ID operations
Task 5.1: Create unit tests for conversation ID generation
ConversationId::generate() produces valid unique IDsTask 5.2: Create integration tests for resume functionality
Task 5.3: Create end-to-end tests for shell plugin integration
Task 6.1: Implement deprecation warnings for old resume behavior
--resume is used without --conversation-idTask 6.2: Create migration documentation
forge --generate-conversation-id produces valid, unique conversation IDsforge --resume --conversation-id <id> successfully resumes the specified conversationforge-term generate-conversation-id properly stores ID in shell environment?? text transforms to forge --resume --conversation-id <id> <<< text when ID is available--resume behavior works with deprecation warnings during transitionBreaking Changes to Existing Workflows Mitigation: Implement deprecation warnings and fallback behavior; provide clear migration documentation; maintain backward compatibility during transition period
Conversation ID Collisions Mitigation: Use UUID-based generation which has extremely low collision probability; implement uniqueness validation when creating conversations
Shell Environment Variable Conflicts
Mitigation: Use unique variable names (FORGE_CONVERSATION_ID); implement proper variable scoping; add validation for stored IDs
User Confusion with New Workflow Mitigation: Provide clear documentation and examples; implement helpful error messages; add interactive guidance when possible
Database Performance Impact Mitigation: Leverage existing conversation retrieval methods; ensure proper indexing on conversation_id column; monitor query performance
Migration Complexity Mitigation: Implement gradual migration approach; provide automated migration tools; offer support during transition period
Optional Session ID Parameter: Keep existing --resume behavior and add optional --session-id parameter
Trade-offs: Less breaking changes, but more complex implementation with two parallel behaviors
Environment Variable Only: Use only environment variables without CLI parameter changes Trade-offs: Simpler CLI changes, but less explicit control and harder to debug
Configuration File Based: Store conversation IDs in configuration files instead of environment variables Trade-offs: More persistent across shell sessions, but adds file management complexity
Hybrid Approach: Support both explicit conversation IDs and automatic session management Trade-offs: More flexible, but significantly more complex implementation and maintenance
Separate Command Set: Create new commands (forge-resume, forge-new) alongside existing ones
Trade-offs: No breaking changes, but confusing user experience with multiple ways to do the same thing