Skip to content

TUI integration - #5

Merged
frap129 merged 31 commits into
mainfrom
feat/tui
Mar 31, 2026
Merged

frap129 merged 31 commits into
mainfrom
feat/tui

Conversation

@frap129

@frap129 frap129 commented Mar 31, 2026 •

Copy link
Copy Markdown
Owner

Add a "Rules" section to the TUI sidebar listing discovered rules by scope, indicating which are currently active, and what the matching criteria are. Ordered between LSP and Todo
image

frap129 added 29 commits March 31, 2026 02:37
Remove card styling (background, border, padding) and palette abstraction.
Add collapsible Project/Global sections with collapse-by-default behavior,
bold 'Rules' header, and arrow toggle indicators matching MCP/LSP sections.
Filesystem-based IPC for TUI sidebar to know which rules are active.
Provides atomic writes with per-session serialization and fire-and-forget API.
- Validate sessionId against /^[A-Za-z0-9_-]+$/ to prevent path traversal
- Add proper type guard for ActiveRulesState with full type checks
- Reject invalid sessionIds early with debug logging
- Change readAndFormatRules() return from string to FilterResult object
- Add matchedPaths array tracking which rule files were included
- Update runtime.ts to call writeActiveRulesState before early return
- Re-export FilterResult from utils.ts
- Update all test call sites to destructure new return type
- Add tests verifying matchedPaths behavior
…fect

- Test that matching rules populate matchedRulePaths in state file
- Test that no-match case writes empty matchedPaths array
- Test that missing sessionID skips state write
- Use _setStateDirForTesting for test isolation
Use readdirSync to assert state directory has no .json files instead
of only checking readActiveRulesState for a specific key.
- Add isActive (boolean | null) to SidebarRuleEntry for UI state display
- Add hasEvaluationState to LoadSidebarRulesResult
- Update loadSidebarRules() with optional sessionId parameter to read state
- Extend TuiPluginApi type shim with TuiEventBus interface and event property
- Add comprehensive tests for isActive behavior with/without state file
- Subscribe to message.updated and session.status events via TuiEventBus
- Debounce 150ms before re-reading rules on events
- Verify sessionId/projectDir match before committing async results
- Separate initial-load effect (resets UI state) from refresh effect
- Add hasEvaluationState prop to RuleSection for header count format
- Green bullet for isActive === true, grey for false/null
- Header count shows (active/total) when hasEvaluationState, else (total)
- Unsubscribe from events on cleanup via onCleanup
Check event payload for sessionId property at receipt time. If the
event has a sessionId that doesn't match the current session, skip
it immediately rather than waiting for the post-load staleness check.
- Add monotonic requestId counter to detect out-of-order async completions
- Call setStatus('loaded') in loadRulesRefresh to recover from error state
- Clear debounceTimer on session/directory change to prevent stale events
- Guard loadRulesRefresh() to skip when status is 'loading', preventing
  refresh from invalidating an in-flight initial load
- Update bullet green color from 'green' to '#02a25a' for better visibility
OpenCode SDK events nest sessionID inside properties object with
capital D (event.properties.sessionID), not event.sessionId. Also
improves vendored TuiEventBus type to match real event structure.
…h, and state persistence

- Add TUI sidebar to Features list
- Add active-rules-state.ts to Project Structure and Key Module Responsibilities
- Update rule-filter.ts description to mention FilterResult return type
- Replace inaccurate [P]/[G] prefix claim with collapsible section groups
- Document active/inactive indicators, sort-to-top, and event-driven refresh
- Add State Persistence step to How It Works flow
@frap129
frap129 marked this pull request as ready for review March 31, 2026 19:08
@frap129
frap129 merged commit 5a2d272 into main Mar 31, 2026
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