feat(logs): add SQL view and editor to LogsScene#57410
Conversation
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
products/logs/frontend/components/LogsSqlEditor/LogsSqlEditor.tsx:6-19
**SQL editor query state lost on tab switch**
`useState` is local to the component instance, so when the user navigates away from the SQL tab the component unmounts (see `{activeTab === 'sql' && showSqlView && <LogsSqlEditor />}`) and the query resets to `SELECT * FROM logs LIMIT 10` on return. For an SQL editor where users compose longer queries this is a noticeable UX regression. Moving the query into a kea logic (similar to how the rest of the Logs scene state is managed) would preserve it across tab switches.
Reviews (1): Last reviewed commit: "feat(logs): add SQL view and editor to L..." | Re-trigger Greptile |
|
Size Change: +3.02 kB (0%) Total Size: 141 MB 📦 View Changed
ℹ️ View Unchanged
|
There was a problem hiding this comment.
The new LogsSqlEditor uses useState for query state in a component that unmounts on tab switch, causing the SQL query to reset every time the user navigates away. An unresolved bot comment flags this as a valid UX concern. Additionally, the project's coding conventions (AGENTS.md) explicitly say to avoid React hooks and use kea logic instead when a kea logic file exists — which it does here (logsSceneLogic). The concern is unaddressed in the current diff.
b4f5f68 to
6d25b38
Compare
There was a problem hiding this comment.
The bot reviews flagged a useState concern from an older commit, but the current code uses kea logic throughout and correctly preserves SQL editor state across tab switches via the keepSqlEditorMounted/cache pattern in logsSceneLogic. The feature is behind a flag and the author is on the owning team — no showstoppers.
6d25b38 to
5d2c557
Compare
New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.
…c, preserving state across navigation
5d2c557 to
762ebf9
Compare
There was a problem hiding this comment.
The useState concern from older-commit bot reviews is not present in the current code — state is managed through kea's sqlEditorLogic, and the keepSqlEditorMounted cache pattern in logsSceneLogic correctly preserves query state across tab switches. The feature is entirely behind a feature flag, no API contracts or data models are changed, and the author is on the owning team.
Merge activity
|

Problem
Users working with logs need a way to run custom SQL queries directly against log data without leaving the Logs scene. This provides a more flexible, power-user interface for exploring logs beyond the standard viewer.
Changes
Adds a new SQL tab to the Logs scene, gated behind the
LOGS_SQL_VIEWfeature flag. The tab renders an embedded SQL editor pre-populated withSELECT * FROM logs LIMIT 10, giving users a full HogQL editor experience.LOGS_SQL_VIEWfeature flag constant'sql'as a validLogsSceneActiveTabLogsSqlEditorcomponent that initializes asqlEditorLogicinstance in embedded mode, pre-fills the query against thelogstable, and keeps the editor mounted vialogsSceneLogiccache to avoid re-initialization on tab switchesLogsSceneTabbedContentbehind the feature flagkeepSqlEditorMountedaction and correspondingbeforeUnmountcleanup to properly manage the lifecycle of the embedded SQL editor logic"Logs"scene to query tagging so queries from this scene are correctly attributed to the logs productHow did you test this code?
Enable the
logs-sql-viewfeature flag and navigate to the Logs scene — a new SQL tab should appear. Clicking it renders the HogQL editor pre-filled with a query against thelogstable.Publish to changelog?
Yes
Docs update
Yes — explain that logs can be queried via SQL using the new SQL tab in the Logs scene.