Skip to content

refactor(ui): isolate view preference quit flow - #863

Open
benvinegar wants to merge 1 commit into
mainfrom
refactor/view-preference-quit-controller
Open

refactor(ui): isolate view preference quit flow#863
benvinegar wants to merge 1 commit into
mainfrom
refactor/view-preference-quit-controller

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • extract view-preference dirty tracking, persistence, and quit prompting from App into a focused controller hook
  • preserve soft-reload baselines and persistence behavior while safely owning the delayed quit timer
  • close and lock successful persistence prompts to prevent duplicate actions

Testing

  • bun test src/ui/hooks/useViewPreferenceQuitController.test.tsx
  • bun test src/ui/AppHost.interactions.test.tsx
  • bun run typecheck
  • bun run deps:check
  • bun run format:check
  • bun run lint

This PR description was generated by Pi using GPT-5.6 Sol

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hunk-web Ignored Ignored Aug 26, 2026 2:28pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The 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.

  • Adds a controller for save, discard, never-ask, prompt-closing, and delayed-quit behavior.
  • Rewires App to consume the controller's derived state and actions.
  • Adds focused tests for persistence, errors, duplicate actions, timer cleanup, and soft reloads.

Confidence Score: 4/5

The 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

Filename Overview
src/ui/hooks/useViewPreferenceQuitController.ts Introduces the focused persistence and quit controller; its direct process.env access violates the repository environment-access convention.
src/ui/App.tsx Replaces App-local view-preference quit logic with the new controller while retaining existing UI wiring.
src/ui/hooks/useViewPreferenceQuitController.test.tsx Adds comprehensive controller coverage for dirty tracking, persistence outcomes, action locking, timer cleanup, and soft reload behavior.

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
Loading
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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)

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant