From f5d2293a53fd41e45c4ac2d64b8056e8af93d782 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 30 Sep 2026 18:14:00 -0700 Subject: [PATCH 1/2] fix(dashboards): carry dashboard chat context ids, label the chart readout, isolate repository tests - User message contexts keep a dashboard mention's dashboardId, both in the optimistic message and when a persisted message is reopened, matching the context the server stores. - The time-series readout row has role="group", so its aria-label is exposed to assistive technology. - The revision test in the dashboard repository suite seeds its own workspace instead of depending on the previous test's row. --- .../workspace/[workspaceId]/home/hooks/use-chat.ts | 1 + apps/sim/components/charts/time-series-chart.tsx | 1 + apps/sim/lib/dashboards/repository.integration.ts | 4 ++-- .../lib/mothership/chat/display-message.test.ts | 14 ++++++++++++++ apps/sim/lib/mothership/chat/display-message.ts | 1 + 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts b/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts index 0f506f151b8..e7fa3a1db62 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts +++ b/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts @@ -3423,6 +3423,7 @@ export function useChat( ? { viewId: (c.currentView ? c.currentView.viewId : c.viewId) ?? undefined } : {}), ...('fileId' in c && c.fileId ? { fileId: c.fileId } : {}), + ...(c.kind === 'dashboard' ? { dashboardId: c.dashboardId } : {}), ...('folderId' in c && c.folderId ? { folderId: c.folderId } : {}), ...(c.kind === 'skill' && 'skillId' in c ? { skillId: c.skillId } : {}), ...(c.kind === 'integration' && 'blockType' in c ? { blockType: c.blockType } : {}), diff --git a/apps/sim/components/charts/time-series-chart.tsx b/apps/sim/components/charts/time-series-chart.tsx index 0417ba1677d..350aef3abbc 100644 --- a/apps/sim/components/charts/time-series-chart.tsx +++ b/apps/sim/components/charts/time-series-chart.tsx @@ -22,6 +22,7 @@ export function TimeSeriesChart({ label, option, ...config }: TimeSeriesChartPro return (
diff --git a/apps/sim/lib/dashboards/repository.integration.ts b/apps/sim/lib/dashboards/repository.integration.ts index 8ce12717de6..6c965dfcdb2 100644 --- a/apps/sim/lib/dashboards/repository.integration.ts +++ b/apps/sim/lib/dashboards/repository.integration.ts @@ -53,7 +53,7 @@ describe('dashboard repository in PostgreSQL', () => { }) it('updates only at the expected revision and advances it', async () => { - const current = (await getWorkspaceDashboard('ws-a'))! + const current = (await insertWorkspaceDashboard('ws-c', 'first', 'user-1'))! const updated = await updateDashboardContent(current.id, 'edited', 'user-2', current.revision) expect(updated).toMatchObject({ content: 'edited', @@ -61,6 +61,6 @@ describe('dashboard repository in PostgreSQL', () => { updatedBy: 'user-2', }) expect(await updateDashboardContent(current.id, 'stale', 'user-3', current.revision)).toBeNull() - expect((await getWorkspaceDashboard('ws-a'))?.content).toBe('edited') + expect((await getWorkspaceDashboard('ws-c'))?.content).toBe('edited') }) }) diff --git a/apps/sim/lib/mothership/chat/display-message.test.ts b/apps/sim/lib/mothership/chat/display-message.test.ts index efd2f9d9ba9..a630b019053 100644 --- a/apps/sim/lib/mothership/chat/display-message.test.ts +++ b/apps/sim/lib/mothership/chat/display-message.test.ts @@ -208,6 +208,20 @@ describe('display-message', () => { ]) }) + it('keeps the dashboard id of a reopened dashboard mention', () => { + const display = toDisplayMessage({ + id: 'msg-dashboard', + role: 'user', + content: '@Dashboard', + timestamp: '2024-01-01T00:00:00.000Z', + contexts: [{ kind: 'dashboard', label: 'Dashboard', dashboardId: 'dashboard-1' }], + }) + + expect(display.contexts).toEqual([ + { kind: 'dashboard', label: 'Dashboard', dashboardId: 'dashboard-1' }, + ]) + }) + it.each(['pending', 'executing', 'awaiting_approval'])( 'shows a %s row of a stored message as interrupted, not running', (state) => { diff --git a/apps/sim/lib/mothership/chat/display-message.ts b/apps/sim/lib/mothership/chat/display-message.ts index c2710d16cdc..3c445ffcb34 100644 --- a/apps/sim/lib/mothership/chat/display-message.ts +++ b/apps/sim/lib/mothership/chat/display-message.ts @@ -149,6 +149,7 @@ function toDisplayContexts( ...(c.tableId ? { tableId: c.tableId } : {}), ...(c.viewId ? { viewId: c.viewId } : {}), ...(c.fileId ? { fileId: c.fileId } : {}), + ...(c.dashboardId ? { dashboardId: c.dashboardId } : {}), ...(c.folderId ? { folderId: c.folderId } : {}), ...(c.chatId ? { chatId: c.chatId } : {}), ...(c.blockType ? { blockType: c.blockType } : {}), From baef45a19215043fb76749f319e1f6cdee173fa3 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 30 Sep 2026 18:36:40 -0700 Subject: [PATCH 2/2] fix(dashboards): name the chart readout group only when it has values --- apps/sim/components/charts/time-series-chart.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/sim/components/charts/time-series-chart.tsx b/apps/sim/components/charts/time-series-chart.tsx index 350aef3abbc..8554a8f4df0 100644 --- a/apps/sim/components/charts/time-series-chart.tsx +++ b/apps/sim/components/charts/time-series-chart.tsx @@ -19,12 +19,13 @@ export function TimeSeriesChart({ label, option, ...config }: TimeSeriesChartPro const valuesRef = useRef(null) const edges = useScrollEdges(valuesRef, { axis: 'x' }) const [readout, setReadout] = useState(null) + const hasValues = Boolean(readout?.values.length) return (