Add safer Agent Orchestration and harden ask_user session handling#88
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an “Agent Orchestration” setting to let TaskSync switch between multi-session orchestration and a safer single-session routing mode, while also hardening ask_user session handling and directives so Copilot stays in the tool loop.
Changes:
- Add
tasksync.agentOrchestration(defaulttrue) and wire it through VS Code settings, local webview UI, and remote clients. - Enforce single-session routing when orchestration is disabled (backend + UI), including safer handling of waiting/terminated sessions.
- Harden
ask_usertool results with always-presentsession_idplus structureddirectivepayloads for bootstrap/cancelled/rejected flows.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tasksync-chat/src/webview/webviewUtils.ts | Switch debug logging from console.error to console.info. |
| tasksync-chat/src/webview/webviewTypes.ts | Add AskUserDirective + new settings message fields/types. |
| tasksync-chat/src/webview/webviewProvider.ts | Add orchestration flag, config-change handler, single-session routing helpers. |
| tasksync-chat/src/webview/webviewProvider.test.ts | Add unit tests for single-session helpers + config change handling. |
| tasksync-chat/src/webview/toolCallHandler.ts | Add directives to rejected/cancelled tool results; adjust deleted-ID behavior for single-session mode. |
| tasksync-chat/src/webview/toolCallHandler.test.ts | Expand tests for directive payloads and single-session routing behavior. |
| tasksync-chat/src/webview/settingsHandlers.ts | Load/persist orchestration setting; add safety guard + stop-and-disable handler. |
| tasksync-chat/src/webview/settingsHandlers.comprehensive.test.ts | Comprehensive tests for orchestration setting + stop-and-disable flow. |
| tasksync-chat/src/webview/messageRouter.ts | Route new orchestration messages from webview to handlers. |
| tasksync-chat/src/webview/messageRouter.test.ts | Tests for routing orchestration-related messages. |
| tasksync-chat/src/webview-ui/state.js | Add client-side orchestration state + visible-session helpers + split-view gating. |
| tasksync-chat/src/webview-ui/settings.js | Add orchestration toggle UI logic + stop-and-disable action. |
| tasksync-chat/src/webview-ui/settings.test.ts | Tests for orchestration toggle + modal confirm behavior. |
| tasksync-chat/src/webview-ui/rendering.js | Hide/disable sessions list + split view controls when orchestration is off. |
| tasksync-chat/src/webview-ui/rendering.test.ts | Update rendering harness expectations for orchestration gating. |
| tasksync-chat/src/webview-ui/messageHandler.js | Apply orchestration setting updates and refresh sessions/welcome UI. |
| tasksync-chat/src/webview-ui/init.js | Add disable-orchestration modal creation + settings modal toggle wiring. |
| tasksync-chat/src/webview-ui/events.js | Prevent multi-session UI actions when orchestration is off; wire toggle events. |
| tasksync-chat/src/webview-ui/adapter.js | Prevent remote session switching UI actions when orchestration is off. |
| tasksync-chat/src/tools.ts | Always return session_id; add directive payload mapping for tool output. |
| tasksync-chat/src/tools.test.ts | Tests for session_id always present + bootstrap directive behavior. |
| tasksync-chat/src/server/remoteSettingsHandler.ts | Handle remote updateAgentOrchestrationSetting. |
| tasksync-chat/src/server/remoteSettingsHandler.test.ts | Add test coverage for remote orchestration setting updates. |
| tasksync-chat/src/server/remoteServer.ts | Remote debug logging uses console.info instead of console.error. |
| tasksync-chat/src/constants/remoteConstants.ts | Update superseded ask_user message to stronger tool-loop wording. |
| tasksync-chat/README.md | Document Agent Orchestration setting and behavior. |
| README.md | Mention orchestration toggle as a top-level feature. |
| tasksync-chat/package.json | Bump version; contribute setting; gate split-view command on config. |
| tasksync-chat/package-lock.json | Lockfile version bump to 3.0.10. |
| tasksync-chat/media/webview.js | Update bundled webview JS to include orchestration behavior. |
| tasksync-chat/media/main.css | Replace inline SVG select arrow with CSP-safe CSS arrow. |
| CHANGELOG.md | Add v3.0.10 release notes entry. |
Files not reviewed (1)
- tasksync-chat/package-lock.json: Language not supported
|
@4regab ready for your review now |
|
@4regab Yeah, it is a bit redundant in single-session mode. I left session_id in place so the ask_user contract stays stable across both modes... That way if the user turns Agent Orchestration back on later, we do not change the payload shape or risk breaking the next ask_user call path? |
|
Got it, that clears things up on my end. Curious to see what @n-r-w has in mind for this PR |
|
I'd like to point out that I didn't notice any performance changes at all after implementing multi-session. But I have a MacBook Pro m4 max. |
Same here |
|
Review in progress |
Review Results: PR #88 - Add safer Agent Orchestration and harden ask_user session handlingDiff scope only: SummaryOutcome: 🔄 Request changes
FindingsMajor
Minor
Assumptions
Open Questions
Next Steps
References
|
|
If you want @n-r-w we can use your code-review instructions and add it to this repo so that copilot code review will use it automatically |
|
Ooh, I'm out atm so won't be able to work on this until tomorrow, feel free to pick it up! |
I have a complex review pipeline with a ton of rules and subagents, so I can't transfer it to the repository instructions. |
I can fix this, but I'm not sure if I have the rights, since the branch is in the repository https://github.com/sgaabdu4/TaskSync |
You should be able to add commits in this PR, just git remote his repo and fetch then checkout this PR
|
Would love to try it out if it's public |
Coordination is available at https://github.com/n-r-w/team-mcp. It's important to separate tool permissions between the main agent and subagents, as specified in the README. Symbolic search. I've now created my own lightweight version exclusively for symbolic search and without the need for initialization, but it's currently privately accessible while I'm testing it. |
|
Fix in progress |
|
Another bug: |
… session flow - Implements the fixes identified in the PR 4regab#88 review and resolves several related regressions beyond `pr-88-code-review.md`. - Makes configuration reloads side-effect free before collapsing to single-session mode. - Prevents stale, deleted, or terminated `ask_user` session IDs from reattaching to the live singleton session. - Restores correct `stopCurrentSession` behavior when starting a fresh chat in single-session mode. - Ensures remote clients receive a full state refresh when the active singleton changes. - Removes duplicate remote `settingsChanged` broadcasts for agent orchestration actions. - Improves dialog UX and accessibility by focusing modals on open, restoring focus on close, and handling `Escape` consistently. - Brings the TaskSync view to the foreground before opening dialogs and includes small UI polish updates. - Adds regression tests for stale-session recovery, remote settings broadcasts, modal focus handling, and session action flows.
|
fix(ui,settings,session): improve dialog handling, settings sync, and session flow
|
…g focus tests - Add "stale_session_id" as a directive reason for single-session recovery - Update CSS to clarify focus handling for history modal overlays - Enhance unit tests to verify dialog and overlay focus visibility and directive handling


Summary
This PR adds a new Agent Orchestration setting and makes TaskSync safer when switching between multi-session mode and single-session mode.
When Agent Orchestration is on, TaskSync keeps separate sessions, the sessions list, session switching, and split view.
When Agent Orchestration is off, TaskSync works in one single-session lane for the workspace. It hides the sessions list, turns off split view, and routes every
ask_usercall into the active TaskSync session.What changed
tasksync.agentOrchestrationand defaulted it totruesession_idin theask_userpayloaddirectivepayloads for bootstrap, cancelled, and rejectedask_userresultsask_usermessaging so the model stays in theask_userloopSafety changes
Stop current session(s) and turn off Agent Orchestrationask_usercalls, marks those sessions terminated, and then disables orchestrationDocs and release notes
v3.0.103.0.10Testing
npm run validateValidation passed:
Issues
Closes #87
Closes #86
Closes #85
Closes #84
Screenshots
Turned off:

Turned on:

When 2 sessions are running:
