Skip to content

feat: add session metadata linking to establish foreign key relationship#249

Merged
mrsimpson merged 1 commit into
mainfrom
fix/opencode-tui-session-linking
Apr 1, 2026
Merged

feat: add session metadata linking to establish foreign key relationship#249
mrsimpson merged 1 commit into
mainfrom
fix/opencode-tui-session-linking

Conversation

@mrsimpson
Copy link
Copy Markdown
Collaborator

Establish a proper foreign key relationship between OpenCode sessions and workflow state instead of relying on file modification times.

Changes:

  • Add SessionMetadata interface to core types with referenceId and createdAt
  • Extend ConversationState with optional sessionMetadata field
  • Extend ServerContext to include sessionMetadata property
  • Add setSessionMetadata/getSessionMetadata methods to ConversationManager
  • Update ConversationManager to store sessionMetadata when creating new conversation states
  • Pass sessionMetadata from OpenCode plugin to ServerContext at initialization
  • Capture OpenCode sessionID in chat.message hook for use in subsequent operations
  • Implement sessionId-based lookup in TUI plugin (readStateBySessionId)
  • Keep mtime-based fallback in TUI plugin for backward compatibility
  • Export SessionMetadata type from mcp-server for external use

This enables the TUI plugin to correctly display the active phase of the current OpenCode session instead of always showing the most recently modified workflow's phase.

Establish a proper foreign key relationship between OpenCode sessions and workflow state instead of relying on file modification times.

Changes:
- Add SessionMetadata interface to core types with referenceId and createdAt
- Extend ConversationState with optional sessionMetadata field
- Extend ServerContext to include sessionMetadata property
- Add setSessionMetadata/getSessionMetadata methods to ConversationManager
- Update ConversationManager to store sessionMetadata when creating new conversation states
- Pass sessionMetadata from OpenCode plugin to ServerContext at initialization
- Capture OpenCode sessionID in chat.message hook for use in subsequent operations
- Implement sessionId-based lookup in TUI plugin (readStateBySessionId)
- Keep mtime-based fallback in TUI plugin for backward compatibility
- Export SessionMetadata type from mcp-server for external use

This enables the TUI plugin to correctly display the active phase of the current OpenCode session instead of always showing the most recently modified workflow's phase.
@mrsimpson mrsimpson merged commit 6fbb56e into main Apr 1, 2026
3 checks passed
@mrsimpson mrsimpson deleted the fix/opencode-tui-session-linking branch April 1, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant