refactor(ui): isolate view preference quit flow - #863
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThe PR extracts view-preference dirty tracking, persistence, prompting, and delayed shutdown from App into a dedicated controller hook while preserving the mounted baseline across soft reloads.
Confidence Score: 4/5The PR appears safe to merge, with one non-blocking environment-access convention issue in the new controller. The refactored flow preserves the existing prompt and persistence behavior, but the new reusable hook directly reads HOME from process.env instead of using the repository's validated environment boundary. Files Needing Attention: src/ui/hooks/useViewPreferenceQuitController.ts Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Q[Quit requested] --> D{Persistent view preferences changed?}
D -->|No or prompting disabled| X[Quit immediately]
D -->|Yes| P[Open save prompt]
P -->|Save| S[Persist preferences]
P -->|Never ask| N[Persist prompt policy]
P -->|Discard| X
P -->|Cancel| R[Return to review]
S --> L[Close and lock prompt actions]
N --> L
L --> T[Show notice and schedule delayed quit]
T --> X
Prompt To Fix All With AI### Issue 1
src/ui/hooks/useViewPreferenceQuitController.ts:84
**Direct environment access**
The new reusable controller reads `HOME` directly from `process.env` whenever App omits `homeDirectory`, bypassing the repository's type-safe, validated environment-variable boundary and establishing an unsupported environment-access path.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "refactor(ui): isolate view preference qu..." | Re-trigger Greptile |
| quitScheduler = DEFAULT_QUIT_SCHEDULER, | ||
| }: UseViewPreferenceQuitControllerOptions): ViewPreferenceQuitController { | ||
| const [savedPreferences, setSavedPreferences] = useState(currentPreferences); | ||
| const [saveConfigPromptOpen, setSaveConfigPromptOpen] = useState(false); |
There was a problem hiding this comment.
The new reusable controller reads HOME directly from process.env whenever App omits homeDirectory, bypassing the repository's type-safe, validated environment-variable boundary and establishing an unsupported environment-access path.
Context Used: guidelines.mdc Cursor rule (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ui/hooks/useViewPreferenceQuitController.ts
Line: 84
Comment:
**Direct environment access**
The new reusable controller reads `HOME` directly from `process.env` whenever App omits `homeDirectory`, bypassing the repository's type-safe, validated environment-variable boundary and establishing an unsupported environment-access path.
**Context Used:** guidelines.mdc Cursor rule ([source](https://github.com/modem-dev/modem/blob/main/.cursor/rules/guidelines.mdc))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Appinto a focused controller hookTesting
bun test src/ui/hooks/useViewPreferenceQuitController.test.tsxbun test src/ui/AppHost.interactions.test.tsxbun run typecheckbun run deps:checkbun run format:checkbun run lintThis PR description was generated by Pi using GPT-5.6 Sol