sync-pending-approvals
Skill11 starsChanged 20 days agoMITView on GitHub
Code recipes and explanation for synchronizing Rust backend pending tool approvals (YOLO mode/manual approval) to the frontend React UI when a user resumes or opens an existing agent session. Use this skill when modifying the AgentSession state to maintain approval channels or when fixing UI bugs related to missing pending tool executions upon page reload/session switch.
In this repository48 other files it gives its agents.
- agents.mdAGENTS.md
- .agents/skills/react-best-practices/AGENTS.mdAGENTS.md
- .agents/skills/react-native-skills/AGENTS.mdAGENTS.md
- .agents/skills/react-view-transitions/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- agent-initSkill
- agy-delegateSkill
- audit-docsSkill
- code-audit-expertSkill
- computer-diagnosisSkill
- create-builtin-toolSkill
- create-prSkill
- critique-builtin-toolSkill
- doc-auditorSkill
- docxSkill
- extract-log-debugSkill
- feature-refactor-proposalSkill
- gatekeeper-loopSkill
- harbor-harness-improvement-loopSkill
- i18n-language-standardsSkill
- jobs-trace-analyzerSkill
- lean-builtin-tool-auditorSkill
- libragent-qualitySkill
- libr-delegateSkill
- libr-tool-e2e-harness-loopSkill
- modular-large-file-refactorSkill
- performance-auditSkill
- pptxSkill
- vercel-react-best-practicesSkill
- vercel-react-native-skillsSkill
- vercel-react-view-transitionsSkill
- readme-showcase-syncSkill
- refactor-builtin-toolSkill
- release-managerSkill
- review-local-changesSkill
- review-pr-commentsSkill
- science-searchSkill
- setup-wizardSkill
- skill-creatorSkill
- soul-awakeningSkill
- sqlite-analyzerSkill
- tool-creatorSkill
- trace-analyzerSkill
- trace-eval-loopSkill
- vitepress-doc-syncSkill
- worker-loopSkill
- x-cliSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
When subagent sessions (or inactive sessions) require tool approval:
- Very specific: line 30
When the frontend explicitly opens a session, it calls agent_resume_session.
- Very specific: line 45
Update the tool execution loop (src-tauri/src/agent/llm/tool_execution.rs) to store the struct instead of just the sender.
- Very specific: line 46
Update src-tauri/src/commands/agent_commands.rs (specifically the agent_resume_session handler) to re-emit the events.
- Very specific: line 47
Update src/context/AgentSessionContext.tsx to handle deduplicate insertions into the pending array.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Sync Pending Approvals
This skill is designed to solve a synchronization issue where an agent spawns a tool requiring user approval, but the user switches away from the session in the UI, or the UI is reloaded. Because the approval request was sent while the session was not active in the UI, the frontend misses the event, and the backend blocks indefinitely waiting for the oneshot::channel response.
Problem Context
When subagent sessions (or inactive sessions) require tool approval:
- Rust backend emits a
ToolExecutionRequiresApprovalevent and awaits aoneshotchannel response. - The UI (
AgentSessionContext.tsx) filters out events for inactive sessions. - The background task deadlocks.
The Solution
To solve this, we must cache the approval details in the Rust session state and re-emit the event when the frontend resumes the session.
1. Update AgentSession State
Currently, pending_approvals only stores the Sender<bool>. It needs the context (tool_name and arguments) to recreate the event.
See rust-state-changes.md for the exact code modifications required for AgentSession and ToolExecutionStarted.
2. Re-emit Events on Session Resume
When the frontend explicitly opens a session, it calls agent_resume_session. We must hook into this phase to read the pending_approvals map and fire the events again.
See rust-resume-logic.md for the exact code modifications.
3. Frontend Deduplication
The frontend needs to ensure that if these events fire again, they don't create duplicate entries in the pending list.
See frontend-dedup.md for the required changes.
Instructions for the Agent applying this skill
- Locate
AgentSessionstruct definition (usually insrc-tauri/src/agent/state.rsor similar). Apply the new struct and update all initialization sites. - Update the tool execution loop (
src-tauri/src/agent/llm/tool_execution.rs) to store the struct instead of just the sender. - Update
src-tauri/src/commands/agent_commands.rs(specifically theagent_resume_sessionhandler) to re-emit the events. - Update
src/context/AgentSessionContext.tsxto handle deduplicate insertions into the pending array. - Compile and test that the tool approval modal correctly appears when switching back to a session that was waiting for approval.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

