nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Unified Session Service for key generation and session infrastructure

Open JimStenstrom opened this issue 11 months ago • 0 comments

Summary

Create a unified Session Service that consolidates React key generation and lays foundation for issue #51 (/resume command).

Problems Solved

  1. Duplicate keys: Date.now() can collide within same millisecond
  2. Fragmentation: Separate counters in useAppState, message-queue, and SessionTracker
  3. No session infrastructure: No foundation for session persistence/resume
  4. Prop drilling: componentKeyCounter threaded 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 (/resume command)
  • Supersedes approach in PR #217

Acceptance Criteria

  • [ ] source/session/ service created with tests
  • [ ] Session initialized on app start
  • [ ] All Date.now() keys replaced with generateKey()
  • [ ] All componentKeyCounter usages migrated
  • [ ] message-queue.tsx uses shared generateKey()
  • [ ] SessionTracker uses shared session ID
  • [ ] Prop interfaces cleaned up (remove componentKeyCounter)
  • [ ] Tests updated and passing
  • [ ] Build succeeds

JimStenstrom avatar Dec 27 '25 13:12 JimStenstrom