Skip to content

Commit e9c7c20

Browse files
committed
improvement: chat and terminal
1 parent cd05584 commit e9c7c20

File tree

6 files changed

+37
-93
lines changed

6 files changed

+37
-93
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,8 @@ export function MothershipView({
9191
previewMode={isActivePreviewable ? previewMode : undefined}
9292
/>
9393
) : (
94-
<div className='flex h-full flex-col items-center justify-center gap-[4px] px-[24px]'>
95-
<h2 className='font-semibold text-[20px] text-[var(--text-primary)]'>
96-
No resources open
97-
</h2>
98-
<p className='text-[12px] text-[var(--text-body)]'>
99-
Click the <span className='font-medium text-[var(--text-primary)]'>+</span> button
100-
above to add a resource to this task
101-
</p>
94+
<div className='flex h-full items-center justify-center text-[14px] text-[var(--text-muted)]'>
95+
Click "+" above to add a resource
10296
</div>
10397
)}
10498
</div>

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useCallback, useEffect, useRef, useState } from 'react'
3+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
44
import { createLogger } from '@sim/logger'
55
import { useParams, useRouter } from 'next/navigation'
66
import { Skeleton } from '@/components/emcn'
@@ -272,9 +272,22 @@ export function Home({ chatId }: HomeProps = {}) {
272272
[addResource, handleResourceEvent]
273273
)
274274

275-
const scrollContainerRef = useAutoScroll(isSending)
275+
const { ref: scrollContainerRef, scrollToBottom } = useAutoScroll(isSending)
276276

277277
const hasMessages = messages.length > 0
278+
const initialScrollDoneRef = useRef(false)
279+
280+
useLayoutEffect(() => {
281+
if (!hasMessages) {
282+
initialScrollDoneRef.current = false
283+
return
284+
}
285+
if (initialScrollDoneRef.current) return
286+
if (resources.length > 0 && isResourceCollapsed) return
287+
288+
initialScrollDoneRef.current = true
289+
scrollToBottom()
290+
}, [hasMessages, resources.length, isResourceCollapsed, scrollToBottom])
278291

279292
useEffect(() => {
280293
if (hasMessages) return

apps/sim/app/workspace/[workspaceId]/home/hooks/use-auto-scroll.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const REATTACH_THRESHOLD = 5
1212
* on any upward user gesture (wheel, touch, scrollbar drag). Once detached,
1313
* the user must scroll back to within {@link REATTACH_THRESHOLD} of the
1414
* bottom to re-engage.
15+
*
16+
* Returns `ref` (callback ref for the scroll container) and `scrollToBottom`
17+
* for imperative use after layout-changing events like panel expansion.
1518
*/
1619
export function useAutoScroll(isStreaming: boolean) {
1720
const containerRef = useRef<HTMLDivElement>(null)
@@ -110,5 +113,5 @@ export function useAutoScroll(isStreaming: boolean) {
110113
}
111114
}, [isStreaming, scrollToBottom])
112115

113-
return callbackRef
116+
return { ref: callbackRef, scrollToBottom }
114117
}

apps/sim/app/workspace/[workspaceId]/home/types.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ export type SSEEventType =
1616
| 'chat_id'
1717
| 'title_updated'
1818
| 'content'
19-
| 'reasoning'
20-
| 'tool_call'
21-
| 'tool_call_delta'
22-
| 'tool_generating'
23-
| 'tool_result'
24-
| 'tool_error'
25-
| 'resource_added'
26-
| 'resource_deleted'
27-
| 'subagent_start'
28-
| 'subagent_end'
29-
| 'structured_result'
30-
| 'subagent_result'
31-
| 'done'
32-
| 'error'
33-
| 'start'
19+
| 'reasoning' // openai reasoning - render as thinking text
20+
| 'tool_call' // tool call name
21+
| 'tool_call_delta' // chunk of tool call
22+
| 'tool_generating' // start a tool call
23+
| 'tool_result' // tool call result
24+
| 'tool_error' // tool call error
25+
| 'resource_added' // add a resource to the chat
26+
| 'resource_deleted' // delete a resource from the chat
27+
| 'subagent_start' // start a subagent
28+
| 'subagent_end' // end a subagent
29+
| 'structured_result' // structured result from a tool call
30+
| 'subagent_result' // result from a subagent
31+
| 'done' // end of the chat
32+
| 'error' // error in the chat
33+
| 'start' // start of the chat
3434

3535
/**
3636
* All tool names observed in the mothership SSE stream, grouped by phase.

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/output-panel/output-panel.tsx

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ import {
2727
PopoverTrigger,
2828
Tooltip,
2929
} from '@/components/emcn'
30-
import { FilterPopover } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/filter-popover'
3130
import { OutputContextMenu } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/output-panel/components/output-context-menu'
3231
import { StructuredOutput } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/output-panel/components/structured-output'
3332
import { ToggleButton } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/toggle-button'
34-
import type {
35-
BlockInfo,
36-
TerminalFilters,
37-
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/types'
3833
import { useContextMenu } from '@/app/workspace/[workspaceId]/w/components/sidebar/hooks'
3934
import { useCodeViewerFeatures } from '@/hooks/use-code-viewer'
4035
import type { ConsoleEntry } from '@/stores/terminal'
@@ -100,16 +95,11 @@ export interface OutputPanelProps {
10095
handleCopy: () => void
10196
filteredEntries: ConsoleEntry[]
10297
handleExportConsole: (e: React.MouseEvent) => void
103-
hasActiveFilters: boolean
10498
handleClearConsole: (e: React.MouseEvent) => void
10599
shouldShowCodeDisplay: boolean
106100
outputDataStringified: string
107101
outputData: unknown
108102
handleClearConsoleFromMenu: () => void
109-
filters: TerminalFilters
110-
toggleBlock: (blockId: string) => void
111-
toggleStatus: (status: 'error' | 'info') => void
112-
uniqueBlocks: BlockInfo[]
113103
}
114104

115105
/**
@@ -133,16 +123,11 @@ export const OutputPanel = React.memo(function OutputPanel({
133123
handleCopy,
134124
filteredEntries,
135125
handleExportConsole,
136-
hasActiveFilters,
137126
handleClearConsole,
138127
shouldShowCodeDisplay,
139128
outputDataStringified,
140129
outputData,
141130
handleClearConsoleFromMenu,
142-
filters,
143-
toggleBlock,
144-
toggleStatus,
145-
uniqueBlocks,
146131
}: OutputPanelProps) {
147132
// Access store-backed settings directly to reduce prop drilling
148133
const outputPanelWidth = useTerminalStore((state) => state.outputPanelWidth)
@@ -154,7 +139,6 @@ export const OutputPanel = React.memo(function OutputPanel({
154139
const setStructuredView = useTerminalStore((state) => state.setStructuredView)
155140

156141
const outputContentRef = useRef<HTMLDivElement>(null)
157-
const [filtersOpen, setFiltersOpen] = useState(false)
158142
const [outputOptionsOpen, setOutputOptionsOpen] = useState(false)
159143
const {
160144
isSearchActive: isOutputSearchActive,
@@ -339,19 +323,6 @@ export const OutputPanel = React.memo(function OutputPanel({
339323
)}
340324
</div>
341325
<div className='flex flex-shrink-0 items-center gap-[8px]'>
342-
{/* Unified filter popover */}
343-
{filteredEntries.length > 0 && (
344-
<FilterPopover
345-
open={filtersOpen}
346-
onOpenChange={setFiltersOpen}
347-
filters={filters}
348-
toggleStatus={toggleStatus}
349-
toggleBlock={toggleBlock}
350-
uniqueBlocks={uniqueBlocks}
351-
hasActiveFilters={hasActiveFilters}
352-
/>
353-
)}
354-
355326
{isOutputSearchActive ? (
356327
<Tooltip.Root>
357328
<Tooltip.Trigger asChild>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { formatDuration } from '@/lib/core/utils/formatting'
2828
import { useRegisterGlobalCommands } from '@/app/workspace/[workspaceId]/providers/global-commands-provider'
2929
import { createCommands } from '@/app/workspace/[workspaceId]/utils/commands-utils'
3030
import {
31-
FilterPopover,
3231
LogRowContextMenu,
3332
OutputPanel,
3433
StatusDisplay,
@@ -603,7 +602,6 @@ export const Terminal = memo(function Terminal() {
603602
const [showCopySuccess, setShowCopySuccess] = useState(false)
604603
const [showInput, setShowInput] = useState(false)
605604
const [autoSelectEnabled, setAutoSelectEnabled] = useState(true)
606-
const [filtersOpen, setFiltersOpen] = useState(false)
607605
const [mainOptionsOpen, setMainOptionsOpen] = useState(false)
608606

609607
const [isTrainingEnvEnabled, setIsTrainingEnvEnabled] = useState(false)
@@ -676,23 +674,6 @@ export const Terminal = memo(function Terminal() {
676674
return result
677675
}, [executionGroups])
678676

679-
/**
680-
* Get unique blocks (by ID) from all workflow entries
681-
*/
682-
const uniqueBlocks = useMemo(() => {
683-
const blocksMap = new Map<string, { blockId: string; blockName: string; blockType: string }>()
684-
allWorkflowEntries.forEach((entry) => {
685-
if (!blocksMap.has(entry.blockId)) {
686-
blocksMap.set(entry.blockId, {
687-
blockId: entry.blockId,
688-
blockName: entry.blockName,
689-
blockType: entry.blockType,
690-
})
691-
}
692-
})
693-
return Array.from(blocksMap.values()).sort((a, b) => a.blockName.localeCompare(b.blockName))
694-
}, [allWorkflowEntries])
695-
696677
/**
697678
* Check if input data exists for selected entry
698679
*/
@@ -1289,22 +1270,9 @@ export const Terminal = memo(function Terminal() {
12891270
{/* Left side - Logs label */}
12901271
<span className={TERMINAL_CONFIG.HEADER_TEXT_CLASS}>Logs</span>
12911272

1292-
{/* Right side - Filters and icons */}
1273+
{/* Right side - Icons and options */}
12931274
{!selectedEntry && (
12941275
<div className='flex items-center gap-[8px]'>
1295-
{/* Unified filter popover */}
1296-
{allWorkflowEntries.length > 0 && (
1297-
<FilterPopover
1298-
open={filtersOpen}
1299-
onOpenChange={setFiltersOpen}
1300-
filters={filters}
1301-
toggleStatus={toggleStatus}
1302-
toggleBlock={toggleBlock}
1303-
uniqueBlocks={uniqueBlocks}
1304-
hasActiveFilters={hasActiveFilters}
1305-
/>
1306-
)}
1307-
13081276
{/* Sort toggle */}
13091277
{allWorkflowEntries.length > 0 && (
13101278
<Tooltip.Root>
@@ -1497,16 +1465,11 @@ export const Terminal = memo(function Terminal() {
14971465
handleCopy={handleCopy}
14981466
filteredEntries={filteredEntries}
14991467
handleExportConsole={handleExportConsole}
1500-
hasActiveFilters={hasActiveFilters}
15011468
handleClearConsole={handleClearConsole}
15021469
shouldShowCodeDisplay={shouldShowCodeDisplay}
15031470
outputDataStringified={outputDataStringified}
15041471
outputData={outputData}
15051472
handleClearConsoleFromMenu={handleClearConsoleFromMenu}
1506-
filters={filters}
1507-
toggleBlock={toggleBlock}
1508-
toggleStatus={toggleStatus}
1509-
uniqueBlocks={uniqueBlocks}
15101473
/>
15111474
)}
15121475
</div>

0 commit comments

Comments
 (0)