Skip to content

Commit 3a32c9d

Browse files
fix(dashboards): accept dashboard chat contexts and bound revisions
The chat request schema now admits dashboard contexts, revisions outside the integer column range are rejected as validation errors, resource tabs only fetch the dashboard when one is open, and the authoring guide notes that range-pinned panels do not drag-zoom.
1 parent 34c633d commit 3a32c9d

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function useResourceNameLookup(
166166
const dashboardsEnabled = useFeatureFlag('dashboards')
167167
const enabled = resources.length > 0
168168
const { data: dashboardData } = useWorkspaceDashboard(workspaceId ?? '', {
169-
enabled: enabled && dashboardsEnabled,
169+
enabled: dashboardsEnabled && resources.some((resource) => resource.type === 'dashboard'),
170170
})
171171
const owners = [
172172
...new Set(

‎apps/sim/lib/dashboards/application/dashboards.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ function validateContent(content: string) {
3333
if (parsed.error) throw new OrchestrationError('validation', parsed.error)
3434
}
3535

36+
/** Revisions are PostgreSQL integers; anything else cannot be a revision from a read. */
37+
const MAX_REVISION = 2_147_483_647
38+
3639
function parseRevision(revision: string): number {
37-
if (!/^\d+$/.test(revision))
40+
const parsed = /^\d+$/.test(revision) ? Number(revision) : Number.NaN
41+
if (!(parsed >= 1 && parsed <= MAX_REVISION))
3842
throw new OrchestrationError('validation', 'expectedRevision must be the revision from a read')
39-
return Number(revision)
43+
return parsed
4044
}
4145

4246
/** Reads the workspace dashboard; a workspace without one returns nulls, not an error. */

‎apps/sim/lib/dashboards/authoring.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Top-level keys: title, time, source, blocks. Blocks stack; row places up to 12 s
3939
- columns (instead of aggregate) for detail rows, with optional sort (≤3). limit 1–500; on aggregates it's top-N after grouping.
4040
4141
## Charts
42-
option is a plain ECharts option; results arrive as dataset 0, referenced via series.encode by groupBy field or aggregate alias. No functions, HTML tooltips, toolbox, or links. Bars: type bar with a category axis (swap axes for horizontal). Pie: encode {itemName, value}, radius pair for donut. Stack/area via standard ECharts. Time-axis charts get hover readout, synced crosshair, and drag-zoom for free — name series, set yAxis.axisLabel.formatter "{value}%" for percentages, and leave xAxis label formatters unset.
42+
option is a plain ECharts option; results arrive as dataset 0, referenced via series.encode by groupBy field or aggregate alias. No functions, HTML tooltips, toolbox, or links. Bars: type bar with a category axis (swap axes for horizontal). Pie: encode {itemName, value}, radius pair for donut. Stack/area via standard ECharts. Time-axis charts get hover readout, synced crosshair, and drag-zoom (except panels that pin their own range) for free — name series, set yAxis.axisLabel.formatter "{value}%" for percentages, and leave xAxis label formatters unset.
4343
4444
## Formatting
4545
The renderer applies default formatting — colors, typography, spacing, bar thickness, axis labels, grids and tooltips — so leave those options out. Add colors, styles, label or grid layout, or other formatting only when the person asks for it. The percentage formatter above sets units, not styling; keep it.

‎apps/sim/lib/mothership/chat/post.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ const ChatContextSchema = z
215215
'table_selection',
216216
'file',
217217
'file_selection',
218+
'dashboard',
218219
'folder',
219220
'filefolder',
220221
'integration',

0 commit comments

Comments
 (0)