Keep database query typing off result grids - #388
Conversation
Co-authored-by: Jaap Frolich <[email protected]>
🤖 OS review · request changes · quality 3/5 · risk lowSafe once the P1 below is fixed. Database selection can temporarily retain and execute the previous database’s query. 🟢 Risk low · recovery in minutes
1 inline comment below. Reviewed 🔁 Not merge-ready and no live session owns this branch — add the |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| </> | ||
| )} | ||
| <DatabaseQuery | ||
| databaseId={database.id} |
There was a problem hiding this comment.
🔴 P1 — Bind query state to the selected database, not stale detail
When database A is loaded and the user selects B, loadDetail(B) leaves detail pointing at A until its request completes. This component therefore still receives A's ID, so neither reset effect runs. If the user opens Query before B's detail arrives, A's draft and result remain visible and Run posts to /databases/A/query. Previously both resetting and execution used selectedDatabaseId, so they switched to B immediately. Pass the selected ID and key the query component by it, or withhold the query UI until database.id === selectedDatabaseId; keying also prevents an in-flight query for A from publishing into B's state.
User-facing hot path
Typing in the Databases query editor while a large result is visible. The query editor's transient
sqlstate lived in the page-levelDatabasescomponent, so each keystroke rendered the database list, detail chrome, and the full result grid again.This change keeps the editor's
sqlandrunningstate inDatabaseQueryEditor. Query results and errors remain in the adjacentDatabaseQuerycomponent, so typing does not render the existing result grid.Reproduction
.agents/start.shon an isolatedOPENSESSION_DEMO=1state directory.agent-react-devtoolsto a headed CDP browser.Benchmark
Medians across the three measured runs:
DataGridrendersIn the steady baseline runs,
DataGridaveraged 10.5 to 12.0 ms per render and peaked at 49.9 to 50.1 ms. It did not render during typing after the change.Validation
bun test packages/core/opensession-server/src/server/routes/databases.test.ts packages/core/opensession-server/src/frontend/lib/api.test.tsbun run typecheckbun run checkBehavior preservation
The query text, run state, result, error handling, API call, keyboard shortcut, copy, and grid output are unchanged.
DatabaseQuerystays mounted when Rows is selected, so switching tabs still preserves an in-progress query draft. Selecting another database still clears the draft, result, and error as before.Limitations
The benchmark uses React's development build because
agent-react-devtoolsconnects to the local dev server. Production also runs the React Compiler, so absolute timings differ. The fixture is generated locally and does not use production session data.Started by Jaap Frolich in this OS session