Skip to content

Commit 7e8d3ff

Browse files
authored
fix(dashboards): carry dashboard chat context ids, label the chart readout, isolate repository tests (#8499)
* 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. * fix(dashboards): name the chart readout group only when it has values
1 parent 51f793b commit 7e8d3ff

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,6 +3423,7 @@ export function useChat(
34233423
? { viewId: (c.currentView ? c.currentView.viewId : c.viewId) ?? undefined }
34243424
: {}),
34253425
...('fileId' in c && c.fileId ? { fileId: c.fileId } : {}),
3426+
...(c.kind === 'dashboard' ? { dashboardId: c.dashboardId } : {}),
34263427
...('folderId' in c && c.folderId ? { folderId: c.folderId } : {}),
34273428
...(c.kind === 'skill' && 'skillId' in c ? { skillId: c.skillId } : {}),
34283429
...(c.kind === 'integration' && 'blockType' in c ? { blockType: c.blockType } : {}),

‎apps/sim/components/charts/time-series-chart.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ export function TimeSeriesChart({ label, option, ...config }: TimeSeriesChartPro
1919
const valuesRef = useRef<HTMLDivElement>(null)
2020
const edges = useScrollEdges(valuesRef, { axis: 'x' })
2121
const [readout, setReadout] = useState<ChartReadout | null>(null)
22+
const hasValues = Boolean(readout?.values.length)
2223
return (
2324
<div className='h-full min-w-0'>
2425
<div
26+
role={hasValues ? 'group' : undefined}
2527
className='mb-2 flex h-8 min-w-0 items-center justify-between gap-4 text-sm tabular-nums'
26-
aria-label={`${label} values`}
28+
aria-label={hasValues ? `${label} values` : undefined}
2729
>
2830
<div
2931
ref={valuesRef}

‎apps/sim/lib/dashboards/repository.integration.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ describe('dashboard repository in PostgreSQL', () => {
5353
})
5454

5555
it('updates only at the expected revision and advances it', async () => {
56-
const current = (await getWorkspaceDashboard('ws-a'))!
56+
const current = (await insertWorkspaceDashboard('ws-c', 'first', 'user-1'))!
5757
const updated = await updateDashboardContent(current.id, 'edited', 'user-2', current.revision)
5858
expect(updated).toMatchObject({
5959
content: 'edited',
6060
revision: current.revision + 1,
6161
updatedBy: 'user-2',
6262
})
6363
expect(await updateDashboardContent(current.id, 'stale', 'user-3', current.revision)).toBeNull()
64-
expect((await getWorkspaceDashboard('ws-a'))?.content).toBe('edited')
64+
expect((await getWorkspaceDashboard('ws-c'))?.content).toBe('edited')
6565
})
6666
})

‎apps/sim/lib/mothership/chat/display-message.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ describe('display-message', () => {
208208
])
209209
})
210210

211+
it('keeps the dashboard id of a reopened dashboard mention', () => {
212+
const display = toDisplayMessage({
213+
id: 'msg-dashboard',
214+
role: 'user',
215+
content: '@Dashboard',
216+
timestamp: '2024-01-01T00:00:00.000Z',
217+
contexts: [{ kind: 'dashboard', label: 'Dashboard', dashboardId: 'dashboard-1' }],
218+
})
219+
220+
expect(display.contexts).toEqual([
221+
{ kind: 'dashboard', label: 'Dashboard', dashboardId: 'dashboard-1' },
222+
])
223+
})
224+
211225
it.each(['pending', 'executing', 'awaiting_approval'])(
212226
'shows a %s row of a stored message as interrupted, not running',
213227
(state) => {

‎apps/sim/lib/mothership/chat/display-message.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function toDisplayContexts(
149149
...(c.tableId ? { tableId: c.tableId } : {}),
150150
...(c.viewId ? { viewId: c.viewId } : {}),
151151
...(c.fileId ? { fileId: c.fileId } : {}),
152+
...(c.dashboardId ? { dashboardId: c.dashboardId } : {}),
152153
...(c.folderId ? { folderId: c.folderId } : {}),
153154
...(c.chatId ? { chatId: c.chatId } : {}),
154155
...(c.blockType ? { blockType: c.blockType } : {}),

0 commit comments

Comments
 (0)