nanocoder
nanocoder copied to clipboard
[Feature] Unified Session Service for key generation and session infrastructure
Summary
Create a unified Session Service that consolidates React key generation and lays
foundation for issue #51 (/resume command).
Problems Solved
- Duplicate keys:
Date.now()can collide within same millisecond - Fragmentation: Separate counters in
useAppState,message-queue, andSessionTracker - No session infrastructure: No foundation for session persistence/resume
- Prop drilling:
componentKeyCounterthreaded through entire component tree
Solution
Create source/session/ service:
- Unified session identity (UUID-based ID + human-readable metadata)
- Single
generateKey(prefix)function for all React keys SessionTracker(usage) uses shared session ID- Foundation for issue #51 session persistence
Session Object
interface Session {
id: string; // "f7a2b3c1" (UUID, internal)
createdAt: number; // Timestamp (sorting, display)
name: string; // "Fix auth bug" (human-readable)
workingDirectory: string;
}
Key Format
{sessionId}-{prefix}-{counter} → f7a2b3c1-error-42
Scope
- ~50 key generation instances across 18+ files
- Removes prop drilling of
componentKeyCounter - Unifies with
SessionTracker(usage tracking) - Standalone service - no React dependency
Related Issues
- Foundation for #51 (
/resumecommand) - Supersedes approach in PR #217
Acceptance Criteria
- [ ]
source/session/service created with tests - [ ] Session initialized on app start
- [ ] All
Date.now()keys replaced withgenerateKey() - [ ] All
componentKeyCounterusages migrated - [ ]
message-queue.tsxuses sharedgenerateKey() - [ ]
SessionTrackeruses shared session ID - [ ] Prop interfaces cleaned up (remove
componentKeyCounter) - [ ] Tests updated and passing
- [ ] Build succeeds