Conversation
…tion, agent filter tests
…et until agent known
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Use delete+set pattern in setSessionEnabled and setSessionAgent to refresh insertion order so active sessions are not prematurely evicted - Normalize agent name to lowercase in TUI message.updated handler to match filter comparison in isActiveForAgent
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the OpenCode workflows integration to (1) restrict workflow behavior to a configured set of agents, (2) make /workflow on|off a per-session toggle, and (3) keep the TUI sidebar’s workflow widget visibility in sync across remounts.
Changes:
- Add
WORKFLOW_ACTIVE_AGENTS(comma-separated whitelist) and use it to gate hooks/tools, plus suppress tool usage for inactive agents viaexperimental.chat.system.transform. - Replace the prior global workflow toggle with per-session enable/disable state and propagate
/workflow on|offeffects through the system prompt + UI. - Update TUI sidebar to persist per-session override across remounts and react to command execution events; update docs and tests accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/opencode-tui-plugin/workflows-phase.tsx | Adds agent filtering + per-session overrides (LRU) and listens for command events to keep sidebar visibility in sync. |
| packages/opencode-tui-plugin/README.md | Documents WORKFLOW_ACTIVE_AGENTS configuration for the sidebar widget. |
| packages/opencode-plugin/test/e2e/plugin.test.ts | Replaces WORKFLOW=off tests with WORKFLOW_ACTIVE_AGENTS coverage (hook gating + suppression behavior). |
| packages/opencode-plugin/src/plugin.ts | Implements agent filtering, per-session toggles, session agent tracking, and system prompt suppression for inactive agents. |
| packages/opencode-plugin/README.md | Documents new env var + session override behavior. |
| .opencode/commands/workflow.md | Updates /workflow command docs for per-session behavior and new env var. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ation, clear on off, safe trim
mrsimpson
added a commit
that referenced
this pull request
Apr 2, 2026
Eliminates redundant session-level state caches from PR #257 by implementing pure per-agent filtering based on WORKFLOW_AGENTS environment variable. ## Changes ### Plugin (packages/opencode-plugin/) - Replace WORKFLOW_ACTIVE_AGENTS env var with WORKFLOW_AGENTS for clarity - Remove sessionEnabled, sessionAgents, and pendingActivation maps - Eliminate command.execute.before hook (YAGNI - not needed for pure filtering) - Simplify agent filtering: evaluate on every chat.message hook - Tools throw clear error if agent not in WORKFLOW_AGENTS filter ### TUI Plugin (packages/opencode-tui-plugin/) - Add WORKFLOW_AGENTS env var parsing - Implement reactive isActive() memo based on agent + filter - Widget visibility updates automatically on agent switches - No session-level state map needed ### Tests (packages/opencode-plugin/test/e2e/) - Replace WORKFLOW=off session toggle tests with WORKFLOW_AGENTS filter tests - Add 5 comprehensive tests for agent filtering behavior - All 53 tests passing ### Documentation - Update opencode-plugin README with Configuration section - Update TUI plugin README with agent-based visibility explanation - Delete obsolete .opencode/commands/workflow.md ## Benefits - Simpler architecture: no session state caches or override maps - Clearer semantics: agent filter is single source of truth - Automatic behavior: TUI responds reactively to agent changes - Better UX: clear error messages for non-whitelisted agents Co-authored-by: udondan <udondan@users.noreply.github.com>
Collaborator
|
superseeded by #259 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes three significant changes:
Workflow tools are now suppressed for non-whitelisted agents. Previously the tools were always visible to every agent, causing agents to spontaneously call them when not intended. The plugin now injects a system prompt telling non-whitelisted agents to ignore the tools entirely.
WORKFLOW_ACTIVE_AGENTSreplacesWORKFLOW=off. The old boolean env var is gone. The new one accepts a comma-separated list of agent names that should have workflows active. When unset, workflows are active for all agents (same as before)./workflow on|offis now truly per-session. Previously the toggle was global. It now only affects the current session and correctly syncs the TUI sidebar state across component remounts.Changes
opencode-pluginexperimental.chat.system.transformWORKFLOW=offwithWORKFLOW_ACTIVE_AGENTS(comma-separated agent whitelist)workflowsEnabledflag with per-sessionsessionEnabledmapisActiveForAgent()to evaluate session override + agent filter in order/workflow onby injecting a counter-instruction to rescind any prior suppressionsessionEnabledandsessionAgentsmaps to 50 entries with LRU evictionopencode-tui-plugin/workflow on|offafter remount: move override state toa module-level
sessionOverrideMapso it survives component remountscommand.executedevent to update override signal in real timesessionOverrideMapis a bounded LRU map (500 entries)Docs
/workflowcommand docs to reflect per-session behaviour andWORKFLOW_ACTIVE_AGENTSopencode-pluginREADME with configuration section