Commit 6d2ad22
Fix codespace state refresh and improve setup flow (#214)
## Summary
Fixes two critical UX issues in the Catnip iOS app:
**Issue 1: Stale codespace state after deletion**
- After deleting a codespace in GitHub, the app shows stale "Access My
Codespace" button
- This leads to confusing Setup view with manual devcontainer
instructions when clicked
- **Fix:** Implemented verification caching with rate limiting to
refresh state on reconnect
**Issue 2: Confusing Setup flow**
- Generic Setup view doesn't guide users based on their GitHub state
- **Fix:** Smart routing based on user's repository state:
- Zero repos → friendly "Create Repository" onboarding screen
- Repos without Catnip → "Install Catnip" flow
- Repos with Catnip → "Launch Codespace" flow
## Architecture
**Worker Side:**
- 60-second verification cache for `/v1/user/status` to reduce GitHub
API calls
- 10-second rate limiting on `?refresh=true` requests (dual-layer:
client + server)
- SSE setup events enriched with `next_action` field based on GitHub
repository state
**iOS Side:**
- Call `fetchUserStatus(forceRefresh: true)` on reconnect to get fresh
state
- Route users based on worker's `next_action` determination
- New friendly "Create Repository" guidance screen for zero-repo users
## Test Plan
- [x] Build succeeds (verified with xcodebuild)
- [ ] Manual testing: Delete codespace in GitHub, verify reconnect shows
correct flow
- [ ] Manual testing: Test zero-repo user sees "Create Repository"
screen
- [ ] Manual testing: Verify rate limiting prevents rapid refresh calls
- [ ] Deploy to production and monitor
## Implementation Details
### Worker Changes (Tasks 1-4)
- Added `VerificationCache` interface and helpers for Durable Object
storage
- Implemented cache storage routes (GET/PATCH
`/verification-cache/{username}`)
- Enhanced `/v1/user/status` with caching and rate limiting
- Added GitHub repository state checking to SSE setup events
### iOS Changes (Tasks 5-9)
- Updated `SSEEvent.setup` to include `nextAction` parameter
- Added client-side rate limiting to `CatnipInstaller.fetchUserStatus`
- Created `createRepository` phase and view for zero-repo users
- Updated `handleSSEEvent` to route based on `next_action`
- Updated `WorkspacesView` reconnect flow to refresh state before
navigation
## References
- Design doc: `docs/plans/2025-11-07-codespace-state-refresh-design.md`
- Implementation plan:
`docs/plans/2025-11-07-codespace-state-refresh.md`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>1 parent c6df293 commit 6d2ad22
File tree
106 files changed
+514
-159290
lines changed- catnip-mobile
- .validate-build
- _expo/static
- css
- js
- android
- ios
- web
- assets
- assets
- workspace
- app
- workspace
- assets
- catnip.icon
- Assets
- components
- ui
- hooks
- lib
- theme
- worker
- xcode/catnip
- Services
- Views
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
106 files changed
+514
-159290
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| 55 | + | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
Lines changed: 0 additions & 113 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
0 commit comments