Commit 3e65479
committed
refactor(chat): clean up the deployed chat surface
Eight-angle cleanup pass over the full contents of the chat surface and
the speech code that survived the voice-mode removal.
Dead code
- enforceChatRateLimit: added for the TTS relay in #6212, orphaned when
#6215 deleted that route. Zero consumers.
- ChatToolCallStatus, ChatErrorType, and six unused CHAT_ERROR_MESSAGES
keys (only GENERIC_ERROR and CHAT_UNAVAILABLE are read).
- scrollToMessage was declared and destructured by ChatMessageContainer
but never used in its body; removing the prop also made the
scrollToShowOnlyMessage branch unreachable, since the sole caller
passed true.
- permissionState and the language prop on useSpeechToText: both
write-only across the repo.
- The image branch in ChatFileDownload's renderIcon returned the same
DefaultFileIcon at the same size as the fallback.
- chatKeys.status/detail: aliases of deploymentKeys nothing imported,
and misleading since they root under a different key namespace.
Redundant state
- password-auth and email-auth each kept a boolean in lockstep with
`errors.length > 0`; email-auth also validated on every keystroke and
then immediately hid the result.
- file-download tracked hover in state to drive one opacity class; now
group-hover. Verified emcn Button sets no `group` class of its own.
Memoization
- ChatMessageContainer's memo() could never bail: chat.tsx passes an
inline arrow for scrollToBottom and displayMessages is a fresh array.
Four of the five things that re-render ChatClient are its props
anyway, so the memo is dropped rather than propped up.
- ClientChatMessage keeps its memo — it blocks markdown re-parsing —
but loses the custom comparator, which compared proxies (a
key:status fingerprint, files by length) and ignored attachments and
type entirely. Default shallow compare on its single prop is both
simpler and stricter.
- Six useCallbacks whose consumers are native DOM handlers or inline
arrows, so nothing observed their identity.
Effects
- The scroll listener attached in an effect keyed on [chatConfig,
authRequired] — values it never reads, standing in for "the container
has mounted". It now attaches via a ref callback, so it no longer
re-attaches on every config refetch.
Design system and a11y
- z-[100] -> z-[var(--z-dropdown)] (same value), shadow-lg ->
shadow-medium, list styles from inline style to Tailwind classes,
hover: -> hover-hover: on touch-reachable targets, Check sourced from
emcn alongside its Duplicate pair.
- Accessible names on the remove-attachment, stop, and send buttons,
which announced only as "button".
- Dropped a keyboard handler on a role='group' div with no tabIndex,
where target === currentTarget was unreachable, and the Tooltip
Provider wrappers and delayDuration, which emcn documents as
no-op passthroughs.1 parent 83988c1 commit 3e65479
16 files changed
Lines changed: 395 additions & 523 deletions
File tree
- apps/sim
- app
- (interfaces)/chat
- [identifier]
- components
- auth
- email
- password
- header
- input
- loading-state
- message-container
- message
- components
- api/speech/token
- hooks
- queries
- lib/core/rate-limiter
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
90 | | - | |
91 | | - | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
144 | 120 | | |
145 | | - | |
146 | 121 | | |
147 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
148 | 139 | | |
149 | 140 | | |
150 | 141 | | |
151 | | - | |
| 142 | + | |
152 | 143 | | |
153 | 144 | | |
154 | 145 | | |
155 | 146 | | |
156 | 147 | | |
157 | 148 | | |
158 | | - | |
159 | | - | |
160 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
161 | 155 | | |
162 | 156 | | |
163 | 157 | | |
| |||
199 | 193 | | |
200 | 194 | | |
201 | 195 | | |
202 | | - | |
| 196 | + | |
203 | 197 | | |
204 | 198 | | |
205 | 199 | | |
| |||
314 | 308 | | |
315 | 309 | | |
316 | 310 | | |
317 | | - | |
| 311 | + | |
318 | 312 | | |
319 | 313 | | |
320 | 314 | | |
321 | 315 | | |
322 | 316 | | |
323 | 317 | | |
324 | 318 | | |
325 | | - | |
| 319 | + | |
326 | 320 | | |
327 | 321 | | |
328 | | - | |
329 | 322 | | |
330 | 323 | | |
331 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
Lines changed: 4 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
| 56 | + | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
64 | | - | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
| |||
75 | 72 | | |
76 | 73 | | |
77 | 74 | | |
78 | | - | |
79 | 75 | | |
80 | 76 | | |
81 | 77 | | |
| |||
149 | 145 | | |
150 | 146 | | |
151 | 147 | | |
152 | | - | |
153 | | - | |
154 | | - | |
| 148 | + | |
155 | 149 | | |
156 | 150 | | |
157 | | - | |
| 151 | + | |
158 | 152 | | |
159 | 153 | | |
160 | 154 | | |
| |||
Lines changed: 4 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
| |||
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | | - | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
| |||
84 | 81 | | |
85 | 82 | | |
86 | 83 | | |
87 | | - | |
88 | | - | |
| 84 | + | |
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
93 | 89 | | |
94 | 90 | | |
95 | | - | |
| 91 | + | |
96 | 92 | | |
97 | 93 | | |
98 | 94 | | |
| |||
101 | 97 | | |
102 | 98 | | |
103 | 99 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 100 | + | |
107 | 101 | | |
108 | 102 | | |
109 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
0 commit comments