|
| 1 | +# Workflows |
| 2 | + |
| 3 | +This page is the fastest path from zero context to a useful `rdt` session. |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install -g react-devtool-cli |
| 9 | +``` |
| 10 | + |
| 11 | +`rdt` resolves Playwright from the local project first, then falls back through `playwright-core`, `RDT_PLAYWRIGHT_PATH`, and global installs. |
| 12 | + |
| 13 | +## Choose the right session mode |
| 14 | + |
| 15 | +| Command | Use when | Notes | |
| 16 | +| --- | --- | --- | |
| 17 | +| `rdt session open` | You want `rdt` to launch and own the browser locally | Recommended default path | |
| 18 | +| `rdt session connect` | You already have a Playwright `wsEndpoint` | Remote-friendly, keeps Playwright fidelity | |
| 19 | +| `rdt session attach` | You only have Chromium CDP access | Compatibility path, lower fidelity than Playwright protocol | |
| 20 | + |
| 21 | +## Quick start |
| 22 | + |
| 23 | +```bash |
| 24 | +rdt session open --url http://localhost:3000 --browser chromium --engine auto --session demo |
| 25 | +rdt tree get --session demo |
| 26 | +rdt node search App --session demo --snapshot <snapshotId> |
| 27 | +rdt node inspect <nodeId> --session demo --snapshot <snapshotId> |
| 28 | +``` |
| 29 | + |
| 30 | +If you only remember one rule, remember this one: `tree get` starts the inspection cycle, and the returned `snapshotId` should follow later lookup commands. |
| 31 | + |
| 32 | +## Snapshot-aware inspection |
| 33 | + |
| 34 | +- `tree get` returns a `snapshotId`. |
| 35 | +- Node ids are only guaranteed to be meaningful inside that snapshot. |
| 36 | +- If you omit `--snapshot`, `rdt` falls back to the latest collected snapshot. |
| 37 | +- If a requested snapshot has been evicted from the in-memory cache, the command fails with `snapshot-expired`. |
| 38 | + |
| 39 | +Recommended flow: |
| 40 | + |
| 41 | +```bash |
| 42 | +rdt tree get --session demo |
| 43 | +rdt node search App --session demo --snapshot <snapshotId> |
| 44 | +rdt node highlight <nodeId> --session demo --snapshot <snapshotId> |
| 45 | +rdt source reveal <nodeId> --session demo --snapshot <snapshotId> |
| 46 | +``` |
| 47 | + |
| 48 | +Recovery flow: |
| 49 | + |
| 50 | +```bash |
| 51 | +rdt tree get --session demo |
| 52 | +# save the new snapshotId |
| 53 | +rdt node search App --session demo --snapshot <newSnapshotId> |
| 54 | +``` |
| 55 | + |
| 56 | +## Run `doctor` before deeper investigation |
| 57 | + |
| 58 | +```bash |
| 59 | +rdt session doctor --session demo |
| 60 | +``` |
| 61 | + |
| 62 | +Use it to confirm: |
| 63 | + |
| 64 | +- React was detected |
| 65 | +- which engine was selected |
| 66 | +- whether built-in `interact` helpers are supported |
| 67 | +- whether profiler and source-reveal capabilities are trustworthy for the current runtime |
| 68 | + |
| 69 | +## Interact before profiling |
| 70 | + |
| 71 | +Built-in interactions keep the investigation inside the same session instead of forcing separate helper scripts. |
| 72 | + |
| 73 | +```bash |
| 74 | +rdt interact click --session demo --selector 'button.save' |
| 75 | +rdt interact type --session demo --selector 'input[name="query"]' --text hello |
| 76 | +rdt interact wait --session demo --ms 500 |
| 77 | +``` |
| 78 | + |
| 79 | +After interaction, verify the app settled by collecting a fresh tree or reading profiler output instead of assuming the UI state changed correctly. |
| 80 | + |
| 81 | +## Profile a real update |
| 82 | + |
| 83 | +```bash |
| 84 | +rdt profiler start --session demo |
| 85 | +rdt interact type --session demo --selector 'input[name="query"]' --text hello |
| 86 | +rdt profiler stop --session demo |
| 87 | +rdt profiler summary --session demo |
| 88 | +rdt profiler ranked <commitId> --session demo --limit 10 |
| 89 | +rdt profiler export --session demo --compress |
| 90 | +``` |
| 91 | + |
| 92 | +Read profiler output literally: |
| 93 | + |
| 94 | +- `commitCount` tells you how many commits were captured |
| 95 | +- `nodeCount` fields describe live tree size at commit time, not exact rerender counts |
| 96 | +- `primaryUpdateCommitId` and `recommendedCommitIds` are better drill-down targets than blindly reading the first commit |
| 97 | + |
| 98 | +## Close the loop cleanly |
| 99 | + |
| 100 | +```bash |
| 101 | +rdt session close --session demo |
| 102 | +``` |
| 103 | + |
| 104 | +Treat sessions as explicit resources. Close them when the investigation is over so later runs start from a known state. |
0 commit comments