Commit 37d2ff0
feat: dark mode matching Databricks workspace theme (#16)
* feat: dark mode matching Databricks workspace theme
Closes #14
## What changed
### Theme system
- `tailwind.config.js`: add `darkMode: 'class'` + convert all `dbx.*`
color tokens to reference CSS custom properties
- `index.css`: define `--dbx-*` variables for both `:root` (light) and
`html.dark` (dark), matching the Databricks workspace dark palette
- `ThemeContext.jsx` (new): React context with three modes:
- `light` / `dark` — always-on
- `system` — queries backend for the user's Databricks workspace
theme (User Settings → Preferences → Appearance) via OAuth token,
falls back to `prefers-color-scheme` if unavailable
- `main.jsx`: wrap app with `ThemeProvider`
### Backend
- `routes.py`: new `GET /api/workspace-appearance` endpoint that uses
`X-Forwarded-Access-Token` (user's OAuth token injected by Databricks
Apps) to query the workspace Settings API for the user's appearance
preference; returns `{ theme: "light"|"dark"|null }`
### UI
- `App.jsx`: remove Moon/Sun toggle from TopBar; settings gear only
- `SettingsPage.jsx`: new **Appearance** section (first in sidebar) with
a compact Theme dropdown — Light / Dark / Follow Databricks workspace
- 22 components: replace every hardcoded hex color (`#161616`,
`#F7F7F7`, `#EBEBEB`, …) with semantic `dbx-*` Tailwind tokens so the
entire UI switches theme via CSS variables with no re-render
Co-authored-by: Isaac
* fix: address dark-mode review — hover flash and focus ring
- ApiReferencePage: replace 4x `hover:bg-[#FAFAFA]` with
`hover:bg-dbx-neutral-hover` — near-white was flashing over
dark backgrounds on accordion button hovers
- PlaygroundPage: replace `focus:ring-[#2272B4]/20` with
`focus:ring-[rgba(34,114,180,0.2)]` — Tailwind v3 opacity
modifiers (/20) require RGB-channel format to work with CSS
variable tokens; explicit rgba() achieves the same result
Co-authored-by: Isaac
* fix: address auth model violation and race condition in workspace-appearance
- Backend: drop DATABRICKS_TOKEN fallback in /workspace-appearance — per auth
model, only the user's OBO token (X-Forwarded-Access-Token) should be used;
substituting the SP token would return the SP's appearance, not the user's.
Now returns {"theme": null} when no user token is present.
- Frontend ThemeContext: distinguish "not yet fetched" (undefined) from
"API returned no answer" (null) in workspaceThemeRef. Previously both states
shared the null sentinel, so an OS theme-change event during the async window
could be applied and then overwritten by the API response. Now the OS listener
only fires when ref === null (API responded with no preference), leaving
ref === undefined (in-flight) and 'light'/'dark' (definitive) untouched.
Co-authored-by: Isaac
* fix: review fixes — stale docstring, hover flash, theme cleanup, i18n
- routes.py: remove misleading SP-token fallback from docstring
- GatewayOverviewTab: replace hardcoded hover:bg-[#EBEBEB] with dbx token
- ThemeContext: add .catch() and reset workspaceThemeRef on cleanup
- PlaygroundPage: translate remaining Portuguese string to English
Co-authored-by: Isaac
* fix: theme cleanup race condition and dark-mode contrast on MCP required labels
Reset workspaceThemeRef to undefined (not null) on effect cleanup to
match the three-state contract and prevent OS listener from firing
during async window. Migrate hardcoded #B91C1C to a new dbx-text-danger
token with proper dark-mode contrast.
Co-authored-by: Isaac
* fix: hoist imports, restore default settings section, and improve dark-mode token coverage
Move os/httpx imports to module level, restore Settings default to 'general',
replace remaining hardcoded Tailwind colors with dbx-* tokens, and add
useTheme guard for missing provider.
Co-authored-by: Isaac
* fix: add 10s overall deadline to workspace-appearance and tokenize red/danger colors
Add deadline guard to get_workspace_appearance so sequential HTTP probes
cannot exceed 10s total. Remove unrelated personal_compute endpoint from
probe list. Add dbx-status-red-bg and dbx-danger-border CSS tokens and
migrate all hardcoded bg-red-50/text-red-600 to theme-aware tokens.
Co-authored-by: Isaac
* fix: use get_running_loop, bound _extract_theme recursion, tokenize cache-hit color
Replace deprecated asyncio.get_event_loop() with get_running_loop() for
Python 3.12+ compatibility. Add depth limit to _extract_theme to prevent
unbounded recursion. Replace hardcoded #FF3621 with db-lava token on
cache-hit badge.
Co-authored-by: Isaac
---------
Co-authored-by: Luiz Carrossoni <carrossoni@gmail.com>
Co-authored-by: lucas-rampimdesouza <lucas.rampim@outlook.com>1 parent 2ac5115 commit 37d2ff0
File tree
27 files changed
+775
-483
lines changed- backend/app/api
- frontend
- src
- components
- api
- debug
- gateways
- layout
- mcp
- playground
- settings
- context
- services
27 files changed
+775
-483
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
249 | | - | |
250 | | - | |
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
| |||
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
0 commit comments