Audit UI Thread Safety
Testing & Qualityaudit-ui-thread-safetyAudit UI Thread Safety is an Agent Skill for testing & quality published in the flutter/flutter-intellij repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Prevent UI freezes and ensure a responsive user experience by validating threading rules and migrating blocking calls off the Event Dispatch Thread (EDT).
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/flutter/flutter-intellij/blob/HEAD/.agents/skills/audit-ui-thread-safety/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/audit-ui-thread-safety, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Skill: UI Thread Safety & Responsiveness
You are tasked with preventing UI freezes and ensuring a responsive user experience by validating threading rules.
Objective
Prevent UI freezes and ensure a responsive user experience by validating threading rules.
Workflow Instructions
1. Baseline
- Run
./gradlew testand./gradlew verifyPluginto ensure the project is in a good state before refactoring.
2. Audit EDT Usage
- Search for usages of
runInEdt,invokeLater, andinvokeAndWait.
3. Identify Blocking Calls
- Ensure no I/O operations (file access, network calls) or heavy computations occur within these UI blocks.
4. Migrate to Background
- Refactor heavy tasks to run on background threads using
Task.BackgroundableorReadAction.nonBlocking.
5. Check Modality
- Verify that modal dialogs do not block the UI thread unnecessarily.
6. Verify
- Run
./gradlew testClassesto ensure safe refactoring. - Run
./gradlew testand./gradlew verifyPluginto ensure no regressions. - Run the plugin in a sandbox (
./gradlew runIde) and perform key actions while monitoring for UI freezes. - Suggest manual test steps: Check the code changes made and write test steps for a user to execute that will trigger the code paths that have changed. If needed, add logging statements to verify that the code paths have successfully run.
7. Report & Review
- Summarize the threading fixes.
- Test Location: Explicitly state where in the IDE the user should go to test the changed functionality (e.g., "Go to Preferences > Languages & Frameworks > Flutter").
- Action: Ask the user to review the changes closely to ensure no deadlocks or UI freezes are introduced.
- Do not commit or push.
- Provide a suggested Git commit message (e.g., "Fix UI freeze: Move heavy computation to background task").