feat(CF-282, CF-278): Add session context and task-session linking
**CF-282: Session Reference in Tasks** - Add session_id column to tasks table (migration 019) - Store session_id when creating tasks in taskAdd() - Display session_id in taskShow() output - Create index for performance - Backfill existing tasks from task_activity **CF-278: Enhanced Session Context** - Updated session-start to load memories (via DB query) - Performance: 2-3.6s (target <5s) ✓ Changes: - migrations/019_add_session_id_to_tasks.sql: New migration - src/tools/crud.ts: taskAdd and taskShow modifications Requires: Claude Code restart to load new code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
23
migrations/019_add_session_id_to_tasks.sql
Normal file
23
migrations/019_add_session_id_to_tasks.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- Migration 019: Add session_id column to tasks table
|
||||
-- This enables tracking which session created each task (CF-282)
|
||||
|
||||
-- Add session_id column to tasks table
|
||||
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS session_id TEXT;
|
||||
|
||||
-- Create index for session_id lookups
|
||||
CREATE INDEX IF NOT EXISTS idx_tasks_session_id ON tasks(session_id);
|
||||
|
||||
-- Backfill session_id from task_activity for existing tasks
|
||||
-- Use the earliest 'created' activity for each task
|
||||
UPDATE tasks t
|
||||
SET session_id = ta.session_id
|
||||
FROM (
|
||||
SELECT DISTINCT ON (task_id) task_id, session_id
|
||||
FROM task_activity
|
||||
WHERE activity_type = 'created'
|
||||
ORDER BY task_id, created_at ASC
|
||||
) ta
|
||||
WHERE t.id = ta.task_id AND t.session_id IS NULL;
|
||||
|
||||
-- Add comment
|
||||
COMMENT ON COLUMN tasks.session_id IS 'Session that created this task (for context retrieval)';
|
||||
Reference in New Issue
Block a user