-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(dashboards): table-backed dashboard files behind a rollout flag #8305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheodoreSpeaks
wants to merge
23
commits into
staging
Choose a base branch
from
codex/research-sim-dashboards
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
56246d8
feat(dashboards): add table-backed dashboard resources behind rollout…
TheodoreSpeaks 90bbd59
refactor(files): separate discovery from storage context
TheodoreSpeaks a6e0941
fix(charts): keep pie labels readable and separate neutral colors
TheodoreSpeaks f894b9e
feat(dashboards): compute percentages from row conditions
TheodoreSpeaks 743b0e3
refactor(dashboards): store dashboards as workspace files
TheodoreSpeaks 0dc3b9d
Merge origin/staging into codex/research-sim-dashboards
TheodoreSpeaks 26a9dd2
fix(dashboards): address review findings on chart layout and precision
TheodoreSpeaks 6c58c01
fix(charts): size grouped bar rows and keep the row highlight through…
TheodoreSpeaks 3d630db
Merge remote-tracking branch 'origin/staging' into codex/research-sim…
TheodoreSpeaks af21484
fix(charts): keep authored tooltip arrays and drop the v2 chat mode o…
TheodoreSpeaks bf3243c
fix(charts): reserve the authored bar gap between grouped bars
TheodoreSpeaks 4f1b0e0
fix(charts): format index-encoded pie tooltips and test dashboard ref…
TheodoreSpeaks d736526
Merge remote-tracking branch 'origin/staging' into codex/research-sim…
TheodoreSpeaks 8e34901
fix(charts): format bar tooltip values with each series' own value axis
TheodoreSpeaks bb59bdf
test(dashboards): drop mock-call and rendered-text assertions
TheodoreSpeaks dd4b207
Merge remote-tracking branch 'origin/staging' into codex/research-sim…
TheodoreSpeaks 0958aab
test(dashboards): drop redundant mock resets and default environment …
TheodoreSpeaks a3e287e
refactor(dashboards): move authoring guidance to Mothership like Sim …
TheodoreSpeaks c2207cf
Merge remote-tracking branch 'origin/staging' into codex/research-sim…
TheodoreSpeaks 54dfd1b
refactor(dashboards): give DashboardFeatureGate a props interface
TheodoreSpeaks 4cc80af
feat(dashboards): report dashboard parse errors on file writes
TheodoreSpeaks 5d0e7e4
fix(dashboards): split diagnostics, switch panel query modes, return …
TheodoreSpeaks 68e8448
fix(dashboards): drop inherited ordering on query-mode switches and c…
TheodoreSpeaks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { authMockFns } from '@sim/testing/mocks/auth.mock' | ||
| import { rateLimiterMock, rateLimiterMockFns } from '@sim/testing/mocks/rate-limiter.mock' | ||
| import { createMockRequest } from '@sim/testing/mocks/request.mock' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { POST } from '@/app/api/table/[tableId]/analytics/route' | ||
|
|
||
| const hoisted = vi.hoisted(() => ({ execute: vi.fn() })) | ||
| vi.mock('@/lib/core/rate-limiter', () => rateLimiterMock) | ||
| vi.mock('@/lib/table/application/analytics', () => ({ | ||
| readTableAnalytics: { operation: { id: 'tables.rows.analytics' }, execute: hoisted.execute }, | ||
| })) | ||
| const mocks = { | ||
| ...hoisted, | ||
| session: authMockFns.mockGetSession, | ||
| limit: rateLimiterMockFns.mockEnforceUserRateLimit, | ||
| } | ||
| const context = { params: Promise.resolve({ tableId: 'tbl_test' }) } | ||
| const body = { | ||
| workspaceId: 'workspace_test', | ||
| query: { | ||
| from: '2026-09-01T00:00:00Z', | ||
| to: '2026-09-02T00:00:00Z', | ||
| aggregate: { n: { op: 'count' } }, | ||
| }, | ||
| } | ||
| const request = (value: unknown) => | ||
| createMockRequest({ method: 'POST', url: '/api/table/tbl_test/analytics', body: value }) | ||
| beforeEach(() => { | ||
| mocks.session.mockResolvedValue({ user: { id: 'viewer' }, session: { id: 'session' } }) | ||
| mocks.limit.mockResolvedValue(null) | ||
| mocks.execute.mockResolvedValue({ | ||
| rows: [{ n: 0 }], | ||
| columns: ['n'], | ||
| columnLabels: { n: 'n' }, | ||
| truncated: false, | ||
| bucket: null, | ||
| }) | ||
| }) | ||
| describe('analytics HTTP adapter', () => { | ||
| it('authenticates before parsing and never uses a file share as authority', async () => { | ||
| mocks.session.mockResolvedValue(null) | ||
| expect((await POST(request({ invalid: true }), context)).status).toBe(401) | ||
| }) | ||
| it('validates the contract before the use case', async () => { | ||
| expect( | ||
| (await POST(request({ ...body, query: { ...body.query, sql: 'select *' } }), context)).status | ||
| ).toBe(400) | ||
| }) | ||
| it('emits a private response', async () => { | ||
| const response = await POST(request(body), context) | ||
| expect(response.status).toBe(200) | ||
| expect(response.headers.get('cache-control')).toBe('private, no-store') | ||
| expect(await response.json()).toMatchObject({ rows: [{ n: 0 }], truncated: false }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { queryTableAnalyticsContract } from '@/lib/api/contracts/table-analytics' | ||
| import { | ||
| defineInternalJsonRoute, | ||
| internalOrchestrationErrorPolicy, | ||
| internalRateLimits, | ||
| internalSessionAuth, | ||
| } from '@/lib/api/server/routes' | ||
| import { readTableAnalytics } from '@/lib/table/application/analytics' | ||
| import { tableOperations } from '@/lib/table/application/operations' | ||
|
|
||
| export const POST = defineInternalJsonRoute({ | ||
| contract: queryTableAnalyticsContract, | ||
| auth: internalSessionAuth, | ||
| operation: tableOperations.analytics, | ||
| rateLimit: internalRateLimits.user({ | ||
| bucketName: 'table-analytics', | ||
| config: { maxTokens: 120, refillRate: 60, refillIntervalMs: 60_000 }, | ||
| }), | ||
| errorPolicy: internalOrchestrationErrorPolicy, | ||
| parseOptions: { maxBodyBytes: 64 * 1024 }, | ||
| mapInput: ({ params, body }) => ({ | ||
| tableId: params.tableId, | ||
| assertedWorkspaceId: body.workspaceId, | ||
| query: body.query, | ||
| }), | ||
| useCase: readTableAnalytics, | ||
| staticResponseHeaders: { 'Cache-Control': 'private, no-store' }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.