Skip to content

Commit 9953fda

Browse files
committed
clamp logs panel
1 parent ed7ac93 commit 9953fda

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/log-details.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { usePermissionConfig } from '@/hooks/use-permission-config'
4040
import { formatCost } from '@/providers/utils'
4141
import type { WorkflowLog } from '@/stores/logs/filters/types'
4242
import { useLogDetailsUIStore } from '@/stores/logs/store'
43+
import { MAX_LOG_DETAILS_WIDTH_RATIO, MIN_LOG_DETAILS_WIDTH } from '@/stores/logs/utils'
4344

4445
/**
4546
* Workflow Output section with code viewer, copy, search, and context menu functionality
@@ -286,6 +287,9 @@ export const LogDetails = memo(function LogDetails({
286287
const { handleMouseDown } = useLogDetailsResize()
287288
const { config: permissionConfig } = usePermissionConfig()
288289

290+
const maxVw = `${MAX_LOG_DETAILS_WIDTH_RATIO * 100}vw`
291+
const effectiveWidth = `clamp(${MIN_LOG_DETAILS_WIDTH}px, ${panelWidth}px, ${maxVw})`
292+
289293
useEffect(() => {
290294
if (scrollAreaRef.current) {
291295
scrollAreaRef.current.scrollTop = 0
@@ -346,7 +350,7 @@ export const LogDetails = memo(function LogDetails({
346350
{isOpen && (
347351
<div
348352
className='absolute top-0 bottom-0 z-[60] w-[8px] cursor-ew-resize'
349-
style={{ right: `${panelWidth - 4}px` }}
353+
style={{ right: `calc(${effectiveWidth} - 4px)` }}
350354
onMouseDown={handleMouseDown}
351355
role='separator'
352356
aria-label='Resize log details panel'
@@ -358,7 +362,7 @@ export const LogDetails = memo(function LogDetails({
358362
className={`absolute top-[0px] right-0 bottom-0 z-50 transform overflow-hidden border-l bg-[var(--bg)] shadow-md transition-transform duration-200 ease-out ${
359363
isOpen ? 'translate-x-0' : 'translate-x-full'
360364
}`}
361-
style={{ width: `${panelWidth}px` }}
365+
style={{ width: effectiveWidth }}
362366
aria-label='Log details sidebar'
363367
>
364368
{log && (

apps/sim/app/workspace/[workspaceId]/logs/hooks/use-log-details-resize.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useCallback, useEffect, useState } from 'react'
22
import { useLogDetailsUIStore } from '@/stores/logs/store'
3-
import { MAX_LOG_DETAILS_WIDTH_RATIO, MIN_LOG_DETAILS_WIDTH } from '@/stores/logs/utils'
43

54
/**
65
* Hook for handling log details panel resize via mouse drag.
@@ -24,12 +23,8 @@ export function useLogDetailsResize() {
2423
if (!isResizing) return
2524

2625
const handleMouseMove = (e: MouseEvent) => {
27-
// Calculate new width from right edge of window
2826
const newWidth = window.innerWidth - e.clientX
29-
const maxWidth = window.innerWidth * MAX_LOG_DETAILS_WIDTH_RATIO
30-
const clampedWidth = Math.max(MIN_LOG_DETAILS_WIDTH, Math.min(newWidth, maxWidth))
31-
32-
setPanelWidth(clampedWidth)
27+
setPanelWidth(newWidth)
3328
}
3429

3530
const handleMouseUp = () => {

apps/sim/app/workspace/[workspaceId]/settings/components/recently-deleted/recently-deleted.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export function RecentlyDeleted() {
247247
</div>
248248

249249
<SModalTabs value={activeTab} onValueChange={(v) => setActiveTab(v as ResourceType)}>
250-
<SModalTabsList activeValue={activeTab} className='border-b border-[var(--border)]'>
250+
<SModalTabsList activeValue={activeTab} className='border-[var(--border)] border-b'>
251251
{TABS.map((tab) => (
252252
<SModalTabsTrigger key={tab.id} value={tab.id}>
253253
{tab.label}
@@ -259,7 +259,7 @@ export function RecentlyDeleted() {
259259
<div className='min-h-0 flex-1 overflow-y-auto'>
260260
{error ? (
261261
<div className='flex h-full flex-col items-center justify-center gap-[8px]'>
262-
<p className='text-[11px] leading-tight text-[#DC2626] dark:text-[#F87171]'>
262+
<p className='text-[#DC2626] text-[11px] leading-tight dark:text-[#F87171]'>
263263
{error instanceof Error ? error.message : 'Failed to load deleted items'}
264264
</p>
265265
</div>
@@ -288,8 +288,8 @@ export function RecentlyDeleted() {
288288
>
289289
<ResourceIcon resource={resource} />
290290

291-
<div className='flex flex-col min-w-0 flex-1'>
292-
<span className='text-[13px] font-medium text-[var(--text-primary)] truncate'>
291+
<div className='flex min-w-0 flex-1 flex-col'>
292+
<span className='truncate font-medium text-[13px] text-[var(--text-primary)]'>
293293
{resource.name}
294294
</span>
295295
<span className='text-[12px] text-[var(--text-tertiary)]'>
@@ -300,7 +300,7 @@ export function RecentlyDeleted() {
300300
</div>
301301

302302
{isRestored ? (
303-
<div className='flex items-center gap-[8px] shrink-0'>
303+
<div className='flex shrink-0 items-center gap-[8px]'>
304304
<span className='text-[13px] text-[var(--text-tertiary)]'>Restored</span>
305305
<Button
306306
variant='default'

apps/sim/stores/logs/store.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { create } from 'zustand'
22
import { persist } from 'zustand/middleware'
33
import type { LogDetailsUIState } from './types'
4-
import { DEFAULT_LOG_DETAILS_WIDTH, getMaxLogDetailsWidth, MIN_LOG_DETAILS_WIDTH } from './utils'
4+
import { clampPanelWidth, DEFAULT_LOG_DETAILS_WIDTH } from './utils'
55

66
export const useLogDetailsUIStore = create<LogDetailsUIState>()(
77
persist(
@@ -12,9 +12,7 @@ export const useLogDetailsUIStore = create<LogDetailsUIState>()(
1212
* @param width - Desired width in pixels for the panel.
1313
*/
1414
setPanelWidth: (width) => {
15-
const maxWidth = getMaxLogDetailsWidth()
16-
const clampedWidth = Math.max(MIN_LOG_DETAILS_WIDTH, Math.min(width, maxWidth))
17-
set({ panelWidth: clampedWidth })
15+
set({ panelWidth: clampPanelWidth(width) })
1816
},
1917
isResizing: false,
2018
/**

apps/sim/stores/logs/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ export const MAX_LOG_DETAILS_WIDTH_RATIO = 0.65
1111
*/
1212
export const getMaxLogDetailsWidth = () =>
1313
typeof window !== 'undefined' ? window.innerWidth * MAX_LOG_DETAILS_WIDTH_RATIO : 1040
14+
15+
/**
16+
* Clamps a width value to the valid panel range for the current viewport.
17+
*/
18+
export const clampPanelWidth = (width: number) =>
19+
Math.max(MIN_LOG_DETAILS_WIDTH, Math.min(width, getMaxLogDetailsWidth()))

0 commit comments

Comments
 (0)