Skip to content

Commit 59a5edf

Browse files
BillLeoutsakosvl346Bill Leoutsakos
andauthored
refactor(emcn): share filled stop icon across chat controls (#7977)
* refactor(emcn): share filled stop icon across chat controls * test(desktop): wait for terminal writes to finish --------- Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local>
1 parent b5d17aa commit 59a5edf

6 files changed

Lines changed: 24 additions & 29 deletions

File tree

‎apps/desktop/src/main/terminal/selection.test.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { sleep } from '@sim/utils/helpers'
21
import { Terminal } from '@xterm/headless'
32
import { describe, expect, it } from 'vitest'
43
import { findSelectedRow } from '@/main/terminal/session'
@@ -7,14 +6,14 @@ const REVERSE = '\u001b[7m'
76
const RESET = '\u001b[0m'
87

98
/**
10-
* Writes to a real headless emulator and lets it settle, so these exercise the
11-
* same buffer the agent reads rather than a hand-built fake. xterm parses
12-
* asynchronously, hence the flush.
9+
* Writes to a real headless emulator and waits for the queued writes to finish,
10+
* so these exercise the same buffer the agent reads. The trailing empty write's
11+
* callback fires after xterm has parsed every preceding chunk.
1312
*/
1413
async function screen(write: (term: Terminal) => void, rows = 8): Promise<Terminal> {
1514
const term = new Terminal({ cols: 40, rows, allowProposedApi: true })
1615
write(term)
17-
await sleep(30)
16+
await new Promise<void>((resolve) => term.write('', resolve))
1817
return term
1918
}
2019

‎apps/sim/app/(interfaces)/chat/components/input/input.tsx‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import type React from 'react'
44
import { useLayoutEffect, useRef, useState } from 'react'
55
import { Badge, Button, cn, Tooltip } from '@sim/emcn'
6-
import { ArrowUp, Paperclip, X } from '@sim/emcn/icons'
6+
import { ArrowUp, Paperclip, StopFilled, X } from '@sim/emcn/icons'
77
import { createLogger } from '@sim/logger'
88
import { generateId } from '@sim/utils/id'
99
import { CHAT_ACCEPT_ATTRIBUTE } from '@/lib/uploads/utils/validation'
@@ -258,13 +258,7 @@ export const ChatInput: React.FC<{
258258
className='size-[28px] rounded-full p-0'
259259
aria-label='Stop generation'
260260
>
261-
<svg
262-
className='block size-[14px] fill-current'
263-
viewBox='0 0 24 24'
264-
xmlns='http://www.w3.org/2000/svg'
265-
>
266-
<rect x='4' y='4' width='16' height='16' rx='3' ry='3' />
267-
</svg>
261+
<StopFilled className='block size-[14px] fill-current' />
268262
</Button>
269263
) : (
270264
<Button

‎apps/sim/app/o/[organizationId]/home/components/composer/composer.tsx‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useRef } from 'react'
44
import { Button, Chip, cn, Tooltip } from '@sim/emcn'
5-
import { ArrowUp, Plus } from '@sim/emcn/icons'
5+
import { ArrowUp, Plus, StopFilled } from '@sim/emcn/icons'
66
import { ASSISTANT_IMAGE_ACCEPT_ATTRIBUTE } from '@/lib/uploads/shared/assistant-images'
77
import { useOrganizationContext } from '@/app/o/[organizationId]/providers/organization-provider'
88
import { AttachedFilesList } from '@/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list/attached-files-list'
@@ -137,13 +137,7 @@ export function Composer({
137137
aria-label='Stop generation'
138138
className={cn(SEND_BUTTON_BASE, SEND_BUTTON_ACTIVE)}
139139
>
140-
<svg
141-
className='block size-[14px] fill-white dark:fill-black'
142-
viewBox='0 0 24 24'
143-
xmlns='http://www.w3.org/2000/svg'
144-
>
145-
<rect x='4' y='4' width='16' height='16' rx='3' ry='3' />
146-
</svg>
140+
<StopFilled className='block size-[14px] fill-white dark:fill-black' />
147141
</Button>
148142
) : (
149143
<Button

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/send-button/send-button.tsx‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use client'
22

33
import React from 'react'
4-
import { ArrowUp, Button, cn } from '@sim/emcn'
4+
import { Button, cn } from '@sim/emcn'
5+
import { ArrowUp, StopFilled } from '@sim/emcn/icons'
56
import {
67
SEND_BUTTON_ACTIVE,
78
SEND_BUTTON_BASE,
@@ -30,13 +31,7 @@ export const SendButton = React.memo(function SendButton({
3031
title='Stop generation'
3132
aria-label='Stop generation'
3233
>
33-
<svg
34-
className='block h-[14px] w-[14px] fill-white dark:fill-black'
35-
viewBox='0 0 24 24'
36-
xmlns='http://www.w3.org/2000/svg'
37-
>
38-
<rect x='4' y='4' width='16' height='16' rx='3' ry='3' />
39-
</svg>
34+
<StopFilled className='block h-[14px] w-[14px] fill-white dark:fill-black' />
4035
</Button>
4136
)
4237
}

‎packages/emcn/src/icons/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export { Split } from './split'
144144
export { Sprout } from './sprout'
145145
export { Square } from './square'
146146
export { SquareArrowUpRight } from './square-arrow-up-right'
147+
export { StopFilled } from './stop-filled'
147148
export { Strikethrough } from './strikethrough'
148149
export { Sun } from './sun'
149150
export { Table } from './table'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { SVGProps } from 'react'
2+
3+
/**
4+
* Filled stop icon. Callers provide the size and fill through SVG props.
5+
*/
6+
export function StopFilled(props: SVGProps<SVGSVGElement>) {
7+
return (
8+
<svg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' {...props}>
9+
<rect x='4' y='4' width='16' height='16' rx='3' ry='3' />
10+
</svg>
11+
)
12+
}

0 commit comments

Comments
 (0)