-
Couldn't load subscription status.
- Fork 0
feat: Snapshots (without snapshot renaming) #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things to address, but headed the right direction
app/screens/StateScreen.tsx
Outdated
| if (!activeTab) { | ||
| console.log("No active client to create snapshot from") | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer one-liner guards if possible.
| if (!activeTab) { | |
| console.log("No active client to create snapshot from") | |
| return | |
| } | |
| if (!activeTab) return console.log("No active client to create snapshot from") |
app/screens/StateScreen.tsx
Outdated
|
|
||
| const copySnapshotToClipboard = (snapshot: Snapshot) => { | ||
| try { | ||
| IRClipboard.setString(JSON.stringify(snapshot.state, null, 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be formatting the JSON string like this, or just stringifying without formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be exported to a utility function in another file rather than putting it inline in the component body. It doesn't depend on any state except what's passed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be formatting the JSON string like this, or just stringifying without formatting?
Is your concern here about performance and/or storage usage?
app/screens/StateScreen.tsx
Outdated
| } catch (error) { | ||
| console.error("Failed to copy snapshots to clipboard:", error) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be extracted to a utility function as well. You can either pass in the snapshots to the function or just get them on-demand with withGlobal (or if @SeanBarker182 has renamed that function, whatever he landed on).
app/screens/StateScreen.tsx
Outdated
| > | ||
| <Text>Clear State</Text> | ||
| </Pressable> | ||
| <> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the ScrollView wrapped in a Fragment, here? Looks like it's just one element.
app/screens/StateScreen.tsx
Outdated
| <Tab id="snapshots" label="Snapshots" tabgroup="activeStateTab" /> | ||
| </View> | ||
| <View style={$stateContainer()}> | ||
| {activeStateTab === "Subscriptions" ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're at the point where this should be refactored into two sub components. Likely something like StateSubscriptions and StateSnapshots.
|
Add screenshots of the feature too, please |
What does this PR do?
This PR implements the state snapshots feature for Reactotron, allowing developers to capture, store, and restore application state snapshots.
The feature adds a new "Snapshots" tab to the existing State screen, enabling users to take snapshots of their Redux or MobX-State-Tree store state with a single click, view them in an expandable card layout, and restore any captured state back to the connected client.
"Snapshots" enhances the debugging experience by providing state persistence across sessions, enabling developers to capture state at specific points in time and restore it later for testing scenarios or bug reproduction. The implementation includes proper error handling, type safety, and integrates seamlessly with Reactotron's existing WebSocket communication system.
Key Features:
patchesfolder are making. These patches modify TextInput behavior in React Native macOS, causing issues with text input functionality. This feature will be addressed in a separate PR once the TextInput issues are resolved.What GitHub issues does this PR fix?
#41
How to verify this code works?
reactotron-macos setup for this PR
gh pr checkout <PR_NUMBER>npm installnpm run podnpm run startnpm run macosreactotron example app setup for this PR
yarn installAdd Reactotron standalone server port to example app configuration
yarn workspace example-app startito launch in iOS simulatorCmd + Shift + Rto reload reactotron-macos to get connectionStep by step of how to test this PR
Prerequisites
Testing Steps
📸 Snapshot Creation
🔍 Snapshot Interaction
🔄 State Restoration
🎨 UI/UX Testing
🧪 Edge Cases
🔧 Technical Validation
Expected Results
✅ Snapshots are created with proper timestamps
✅ State restoration works correctly
✅ Copy operations work (check clipboard)
✅ UI is responsive and intuitive
✅ Error handling works for edge cases
✅ No memory leaks with repeated operations
Screenshot/Video of "How to test this PR?"
CleanShot.2025-10-23.at.20.20.30.mp4