Skip to content

Commit 4194237

Browse files
fix(ui): live usage indicator, child trace spans, cancel subscription modal z-index (#2044)
* cleanup * show trace spans for child blocks that error * fix z index for cancel subscription popup * rotating digit live usage indicator * fix * remove unused code * fix type * fix(billing): fix team upgrade * fix * fix tests --------- Co-authored-by: waleed <walif6@gmail.com>
1 parent 591b99e commit 4194237

File tree

31 files changed

+491
-800
lines changed

31 files changed

+491
-800
lines changed

apps/sim/app/api/users/me/subscription/[id]/transfer/route.test.ts

Lines changed: 0 additions & 278 deletions
This file was deleted.

apps/sim/app/api/users/me/subscription/[id]/transfer/route.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
8181
.where(and(eq(member.userId, session.user.id), eq(member.organizationId, organizationId)))
8282
.then((rows) => rows[0])
8383

84-
const isPersonalTransfer = sub.referenceId === session.user.id
85-
86-
if (!isPersonalTransfer && (!mem || (mem.role !== 'owner' && mem.role !== 'admin'))) {
84+
if (!mem || (mem.role !== 'owner' && mem.role !== 'admin')) {
8785
return NextResponse.json(
8886
{ error: 'Unauthorized - user is not admin of organization' },
8987
{ status: 403 }

apps/sim/app/workspace/[workspaceId]/logs/components/trace-spans/trace-spans.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,22 @@ export function TraceSpans({ traceSpans, totalDuration = 0, onExpansionChange }:
135135
.filter(([, v]) => v)
136136
.map(([k]) => k)
137137
)
138-
const filterTree = (spans: TraceSpan[]): TraceSpan[] =>
138+
const filterTree = (spans: TraceSpan[], parentIsWorkflow = false): TraceSpan[] =>
139139
spans
140-
.map((s) => ({ ...s }))
140+
.map((s) => normalizeChildWorkflowSpan(s))
141141
.filter((s) => {
142142
const tl = s.type?.toLowerCase?.() || ''
143143
if (tl === 'workflow') return true
144+
if (parentIsWorkflow) return true
144145
return allowed.has(tl)
145146
})
146-
.map((s) => ({
147-
...s,
148-
children: s.children ? filterTree(s.children) : undefined,
149-
}))
147+
.map((s) => {
148+
const tl = s.type?.toLowerCase?.() || ''
149+
return {
150+
...s,
151+
children: s.children ? filterTree(s.children, tl === 'workflow') : undefined,
152+
}
153+
})
150154
return traceSpans ? filterTree(traceSpans) : []
151155
}, [traceSpans, effectiveTypeFilters])
152156

@@ -181,7 +185,6 @@ export function TraceSpans({ traceSpans, totalDuration = 0, onExpansionChange }:
181185
return () => ro.disconnect()
182186
}, [])
183187

184-
// Early return after all hooks are declared to comply with React's Rules of Hooks
185188
if (!traceSpans || traceSpans.length === 0) {
186189
return <div className='text-muted-foreground text-sm'>No trace data available</div>
187190
}
@@ -217,21 +220,19 @@ export function TraceSpans({ traceSpans, totalDuration = 0, onExpansionChange }:
217220
</div>
218221
<div ref={containerRef} className='relative w-full overflow-hidden border shadow-sm'>
219222
{filtered.map((span, index) => {
220-
const normalizedSpan = normalizeChildWorkflowSpan(span)
221223
const hasSubItems = Boolean(
222-
(normalizedSpan.children && normalizedSpan.children.length > 0) ||
223-
(normalizedSpan.toolCalls && normalizedSpan.toolCalls.length > 0) ||
224-
normalizedSpan.input ||
225-
normalizedSpan.output
224+
(span.children && span.children.length > 0) ||
225+
(span.toolCalls && span.toolCalls.length > 0) ||
226+
span.input ||
227+
span.output
226228
)
227229

228-
// Calculate gap from previous span (for sequential execution visualization)
229230
let gapMs = 0
230231
let gapPercent = 0
231232
if (index > 0) {
232233
const prevSpan = filtered[index - 1]
233234
const prevEndTime = new Date(prevSpan.endTime).getTime()
234-
const currentStartTime = new Date(normalizedSpan.startTime).getTime()
235+
const currentStartTime = new Date(span.startTime).getTime()
235236
gapMs = currentStartTime - prevEndTime
236237
if (gapMs > 0 && actualTotalDuration > 0) {
237238
gapPercent = (gapMs / actualTotalDuration) * 100
@@ -241,13 +242,13 @@ export function TraceSpans({ traceSpans, totalDuration = 0, onExpansionChange }:
241242
return (
242243
<TraceSpanItem
243244
key={index}
244-
span={normalizedSpan}
245+
span={span}
245246
depth={0}
246247
totalDuration={
247248
actualTotalDuration !== undefined ? actualTotalDuration : totalDuration
248249
}
249250
isLast={index === traceSpans.length - 1}
250-
parentStartTime={new Date(normalizedSpan.startTime).getTime()}
251+
parentStartTime={new Date(span.startTime).getTime()}
251252
workflowStartTime={workflowStartTime}
252253
onToggle={handleSpanToggle}
253254
expandedSpans={expandedSpans}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { usePanelResize } from './use-panel-resize'
2-
export { type UsageData, useUsageLimits } from './use-usage-limits'
2+
export { useUsageLimits } from './use-usage-limits'

0 commit comments

Comments
 (0)