Skip to content

feat: glass box SQL console, tooltips, interpretations, UI polish#51

Merged
gamaware merged 1 commit into
mainfrom
fix/ui-polish-tooltips-glasbox
Apr 15, 2026
Merged

feat: glass box SQL console, tooltips, interpretations, UI polish#51
gamaware merged 1 commit into
mainfrom
fix/ui-polish-tooltips-glasbox

Conversation

@gamaware
Copy link
Copy Markdown
Owner

@gamaware gamaware commented Apr 15, 2026

Glass box SQL queries, contextual interpretations, JS tooltips, event log card, VS Code-style resize, fresh screenshots.

Summary by CodeRabbit

  • New Features
    • Added SQL Glass Box feature to visualize executed SQL queries in real-time console output with auto-scrolling.
    • Added interactive tooltips on action buttons for enhanced guidance and descriptions.
    • Made the console panel resizable with a draggable handle for better workspace flexibility.
    • Included AI-generated interpretations displayed alongside operation results for easier understanding.

- Show actual SQL queries in console for every button click (glass box)
- Add contextual interpretation below JSON results explaining
  scalability implications
- Fix tooltips: JS-driven fixed positioning instead of CSS pseudo-
  elements (no clipping by overflow:hidden parents)
- Event log: distinct dark card container with visible border and
  empty state placeholder
- Animations: smoother arrow glow, tab hover transform
- Draggable resize: VS Code-style split pane (main area shrinks
  as bottom panel grows)
- Fresh Playwright screenshots for all 9 tasks
Copilot AI review requested due to automatic review settings April 15, 2026 06:27
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 933946b7-935b-455d-95a5-b0dff8ed2c25

📥 Commits

Reviewing files that changed from the base of the PR and between 10d979b and a7c63f9.

⛔ Files ignored due to path filters (12)
  • 10-databases/visualizer/screenshots/01-replication-tab.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/02-sidebar-state.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/03-replication-result.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/04-consistency-committed.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/05-schema-no-index.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/06-schema-with-index.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/07-sql-console.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/08-cap-diverged.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/09-cap-consistent.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/10-views-join.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/11-views-view.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
  • 10-databases/visualizer/screenshots/12-vertical-benchmark.png is excluded by !**/*.png, !**/screenshots/**, !**/*.png
📒 Files selected for processing (4)
  • 10-databases/visualizer/app.js
  • 10-databases/visualizer/index.html
  • 10-databases/visualizer/server.py
  • 10-databases/visualizer/style.css

📝 Walkthrough

Walkthrough

The PR adds a SQL Glass Box feature to log query steps with SQL statements, introduces result interpretation messages, and enhances the visualizer UI with interactive tooltips and a draggable console resize handle. Changes span backend SQL collection and frontend display across app.js, index.html, server.py, and style.css.

Changes

Cohort / File(s) Summary
SQL Glass Box - Backend
10-databases/visualizer/server.py
Extended step_entry() to accept optional sql parameter; constructed and attached SQL strings for INSERT, SELECT, SHOW, BEGIN/COMMIT/ROLLBACK, DELETE/UPDATE, EXPLAIN, CREATE/DROP INDEX, REPLICA commands, and view/bench queries; added top-level interpretation strings to response objects based on operation outcomes and metrics.
SQL Glass Box - Frontend Display
10-databases/visualizer/app.js, 10-databases/visualizer/index.html
Added logSqlToConsole(result) function to iterate result steps and log SQL queries with metadata to console output with auto-scroll; updated HTML with console output container.
Result Interpretation Display
10-databases/visualizer/app.js, 10-databases/visualizer/index.html, 10-databases/visualizer/style.css
Extended showResult() signature to accept apiResult parameter; removes existing interpretation element and appends new interpretation if present; added .result-interpretation CSS styling for interpretation panel display.
Tooltip System
10-databases/visualizer/app.js, 10-databases/visualizer/index.html, 10-databases/visualizer/style.css
Added initTooltips() function for mouseover/mouseout tooltip popups positioned relative to elements with [data-tooltip] attributes; wired into DOMContentLoaded; added data-tooltip attributes to buttons across tabs; added .tooltip-popup CSS with position/visibility styling.
Console Resize Handle
10-databases/visualizer/app.js, 10-databases/visualizer/index.html, 10-databases/visualizer/style.css
Enabled draggable resize handle (#resize-handle) in initConsole() to adjust .bottom-bar height within bounds during mouse drag; added <div id="resize-handle"> element and .resize-handle CSS with hover styling.
Layout & Styling Updates
10-databases/visualizer/style.css
Changed body sizing from min-height: 100vh to height: 100vh with overflow: hidden; added min-height: 0 to flex containers for improved scrolling; updated .bottom-bar padding, flex properties, and positioning; added hover animation to .tab; introduced @keyframes arrow-glow and .dot-pulse animations; added empty-state messaging for event log and console output.

Sequence Diagram

sequenceDiagram
    participant User
    participant Frontend as Client (app.js)
    participant Backend as Server (server.py)
    participant Display as Display Layer

    User->>Frontend: Trigger action (e.g., INSERT, SELECT)
    Frontend->>Backend: Send request with query parameters
    Backend->>Backend: Process query, collect steps with SQL
    Backend-->>Frontend: Return result {steps[{sql, action, ...}], interpretation}
    Frontend->>Display: showResult(status, latency, data, cls, apiResult)
    Display->>Display: Remove old interpretation element
    Display->>Display: Append new interpretation (if present)
    Frontend->>Frontend: logSqlToConsole(apiResult)
    Frontend->>Frontend: Iterate steps, extract sql field
    Frontend->>Display: Append SQL/metadata lines to console output
    Display->>Display: Auto-scroll console to bottom
    User->>User: View SQL steps and interpretation in UI
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 Hops through queries with glee,
SQL steps logged for all to see,
Tooltips dance, resize with care,
Glass box shines with transparency there!
Database mysteries, revealed so bright,
The visualizer's dancing light!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ui-polish-tooltips-glasbox

Comment @coderabbitai help to get the list of available commands and usage tips.

@gamaware gamaware merged commit 2660b40 into main Apr 15, 2026
12 of 16 checks passed
@gamaware gamaware deleted the fix/ui-polish-tooltips-glasbox branch April 15, 2026 06:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds “glass box” visibility and UI polish to the Lab 10 database visualizer by surfacing executed SQL per step, adding contextual explanations, and improving interaction affordances (tooltips, event log, resizable panels).

Changes:

  • Extend API step traces to include sql and add interpretation strings for multiple patterns.
  • Update frontend to auto-log step SQL to the console, render interpretations in the result panel, add JS-driven tooltips, and add a draggable bottom-bar resize handle.
  • Update styling/layout for the new UI elements and add refreshed screenshots.

Reviewed changes

Copilot reviewed 4 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
10-databases/visualizer/style.css Layout tweaks (full-height app), tooltip styling, bottom bar/event log styling, resize handle visuals
10-databases/visualizer/server.py Adds sql fields to step traces and interpretation fields to responses; adds logged SQL strings for multiple operations
10-databases/visualizer/index.html Adds data-tooltip attributes, resize handle element, tooltip popup container, and event log header text
10-databases/visualizer/app.js Implements SQL console auto-logging, interpretation rendering, draggable resize, and JS-driven tooltips
10-databases/visualizer/screenshots/01-replication-tab.png Updated screenshot asset
10-databases/visualizer/screenshots/02-sidebar-state.png Updated screenshot asset

Comment on lines +822 to +823
bench_sql = ("SELECT * FROM access_log WHERE student_id = ? "
f"AND resource = ? (x{count})")
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bench_sql uses ? placeholders and appends (x{count}), which isn’t valid MySQL syntax and doesn’t match the actual executed query format (%s placeholders). Since this is shown to users as the “glass box” query, consider logging a syntactically correct MySQL statement and representing the loop count separately (e.g., in metadata).

Copilot uses AI. Check for mistakes.
Comment on lines +1008 to +1016
document.addEventListener('mouseover', (e) => {
const el = e.target.closest('[data-tooltip]');
if (!el) {
popup.classList.remove('visible');
return;
}
popup.textContent = el.dataset.tooltip;
popup.classList.add('visible');

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooltips are only wired to mouseover/mouseout, so keyboard users (tabbing) won’t see them, and touch devices may not trigger them consistently. Consider adding focusin/focusout handling (and possibly aria-describedby or title fallback) so tooltips are accessible beyond mouse hover.

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +42
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body { height: 100vh; overflow: hidden; } can prevent the page from scrolling when content exceeds the viewport (especially on small screens/mobile), potentially cutting off UI. Consider keeping min-height: 100vh (or using dynamic viewport units like 100dvh) and avoiding global overflow: hidden unless all content is guaranteed to fit with internal scroll regions.

Suggested change
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
min-height: 100vh;
min-height: 100dvh;
display: flex;
flex-direction: column;
overflow-y: auto;

Copilot uses AI. Check for mistakes.
pointer-events: none;
opacity: 0;
transition: opacity 0.15s ease;
white-space: nowrap;
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In .tooltip-popup, white-space: nowrap effectively disables wrapping, so max-width: 300px won’t prevent long tooltips from overflowing the viewport. Consider allowing wrapping (white-space: normal/pre-wrap) and adding overflow-wrap: anywhere (or similar) so long tooltip text stays on-screen.

Suggested change
white-space: nowrap;
white-space: normal;
overflow-wrap: anywhere;

Copilot uses AI. Check for mistakes.
Comment on lines +190 to +193
.travel-dot {
transition: opacity 0.15s ease;
}

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are now two .travel-dot rules (this new one and another later in the file), which can make the actual transition behavior hard to reason about (later rules will override earlier ones). Consider consolidating into a single .travel-dot declaration to avoid accidental overrides.

Suggested change
.travel-dot {
transition: opacity 0.15s ease;
}

Copilot uses AI. Check for mistakes.
seq = 1

# Write to primary
insert_sql = f"INSERT INTO students (name, email, major) VALUES ('{name}', '{email}', '{major}')"
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert_sql is built via string interpolation with raw name/email/major. Even though the executed query is parameterized, the displayed SQL will become syntactically invalid (and misleading for students) if inputs contain quotes/newlines. Consider logging a parameterized form (e.g., VALUES (%s, %s, %s)) and/or escaping values for display.

Suggested change
insert_sql = f"INSERT INTO students (name, email, major) VALUES ('{name}', '{email}', '{major}')"
insert_sql = "INSERT INTO students (name, email, major) VALUES (%s, %s, %s)"

Copilot uses AI. Check for mistakes.
Comment on lines +270 to +273
explain_sql = (f"EXPLAIN SELECT * FROM access_log WHERE student_id = {student_id} "
f"AND resource = '{resource}'")
count_sql = (f"SELECT COUNT(*) AS cnt FROM access_log WHERE student_id = {student_id} "
f"AND resource = '{resource}'")
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain_sql / count_sql embed resource directly into a quoted SQL string for display. If resource contains a quote, the logged SQL becomes invalid and can look like injection despite the actual query being parameterized. Consider logging the parameterized query text (with placeholders) and/or escaping the value for display.

Suggested change
explain_sql = (f"EXPLAIN SELECT * FROM access_log WHERE student_id = {student_id} "
f"AND resource = '{resource}'")
count_sql = (f"SELECT COUNT(*) AS cnt FROM access_log WHERE student_id = {student_id} "
f"AND resource = '{resource}'")
explain_sql = "EXPLAIN SELECT * FROM access_log WHERE student_id = %s AND resource = %s"
count_sql = "SELECT COUNT(*) AS cnt FROM access_log WHERE student_id = %s AND resource = %s"

Copilot uses AI. Check for mistakes.
Comment on lines 767 to +772
cur.execute(f"SET GLOBAL innodb_buffer_pool_size = {size}")
t1 = time.perf_counter()
return {"action": "SET BUFFER POOL", "size": size,
"latency_ms": round((t1 - t0) * 1000, 2)}
"latency_ms": round((t1 - t0) * 1000, 2),
"sql": f"SET GLOBAL innodb_buffer_pool_size = {size}",
"interpretation": (
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vertical_set_buffer executes SET GLOBAL innodb_buffer_pool_size = {size} using direct string interpolation from the request body. This allows SQL injection if the endpoint is called with crafted input (e.g., size containing ; ...). Consider validating/whitelisting allowed sizes and constructing the statement safely (e.g., enforce size as an integer and append a fixed unit).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants