--- id: "08e10076-76f7-475b-b230-accebe83a044" name: "simbook_complete()" micro_summary: "Call when you need to complete a SIMnet simbook assignment end-to-end — clicks Open SIMbook, runs the completion script, and verifies all sections." status: "in_progress" see_also: [] scope: "The simbook_complete() helper function in agent_helpers.py. One call does the full flow: navigates to simbook player, runs the smartbook.js completion script, refreshes, opens Table of Contents, and verifies all sections are complete." --- ## simbook_complete() One call does everything. Dead simple. ```python result = simbook_complete() # → {"ok": true, "total": 27, "complete": 27, "sections": [...], "all_complete": true} ``` ### Flow 1. **Detect page** — if on details page (`simbooks/details`), click Open SIMbook; if on player (`/sb/`), skip to step 2 2. **Run script** — execute `/tmp/smartbook.js` (dispatches async API POSTs to mark all tasks complete) 3. **Wait** — 5s for async API dispatches to finish 4. **Refresh** — reload page to confirm remote state 5. **Open TOC** — JS-click `#tocButton` to open Table of Contents modal (must use JS click, not `click_at_xy` — button is at viewport edge) 6. **Verify** — parse TOC modal links, count complete vs total sections ### Returns JSON string with: - `ok`: true if all sections complete - `all_complete`: same as ok - `total`: total section count - `complete`: completed section count - `sections`: list of `{name, complete}` for each section - `error`: present only on failure ### Dependencies - `/tmp/smartbook.js` must exist (the Redux thunk injector script) - Must call from a simbook details page or simbook player page ### Traps - **TOC button requires JS click** — `click_at_xy()` fails because button is at viewport edge (x=23, y=23). Use `js("document.querySelector('#tocButton').click()")` - **Modal backdrop collision** — `.modal.show` matches both the TOC modal AND the dark backdrop. Filter by content: `txt.indexOf("Table of Contents") !== -1`