@electerm/electerm-react 5.5.25 → 5.5.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +5 -5
  2. package/client/common/bookmark-schemas.js +4 -0
  3. package/client/common/constants.js +3 -0
  4. package/client/common/create-title.jsx +5 -1
  5. package/client/common/default-setting.js +2 -0
  6. package/client/common/parse-quick-connect.js +1 -0
  7. package/client/common/parse-vv.js +119 -25
  8. package/client/common/parse-widget-log.js +57 -0
  9. package/client/common/vv-to-tab.js +120 -0
  10. package/client/components/ai/agent-tool-call-card.jsx +26 -7
  11. package/client/components/ai/agent.js +205 -45
  12. package/client/components/ai/ai-auto-compress.js +119 -0
  13. package/client/components/ai/ai-chat-history-item.jsx +133 -84
  14. package/client/components/ai/ai-chat.jsx +135 -30
  15. package/client/components/ai/ai-compress.js +95 -0
  16. package/client/components/ai/ai-config-props.js +12 -1
  17. package/client/components/ai/ai-config.jsx +43 -16
  18. package/client/components/ai/ai-config.styl +20 -0
  19. package/client/components/ai/ai-context-indicator.jsx +83 -0
  20. package/client/components/ai/ai-context.js +272 -0
  21. package/client/components/ai/ai-output.jsx +5 -6
  22. package/client/components/ai/ai-presets.js +1 -16
  23. package/client/components/ai/ai.styl +105 -6
  24. package/client/components/ai/copy-icon.jsx +31 -0
  25. package/client/components/batch-op/batch-op-runner.jsx +1 -0
  26. package/client/components/bookmark-form/bookmark-schema.js +1 -0
  27. package/client/components/bookmark-form/common/ssh-agent.jsx +31 -21
  28. package/client/components/bookmark-form/common/vv-file-field.jsx +3 -2
  29. package/client/components/bookmark-form/config/spice.js +21 -0
  30. package/client/components/bookmark-form/config/ssh.js +1 -0
  31. package/client/components/bookmark-form/fix-bookmark-default.js +1 -0
  32. package/client/components/file-transfer/transfer.jsx +3 -119
  33. package/client/components/footer/cmd-history.jsx +279 -65
  34. package/client/components/footer/cmd-history.styl +68 -1
  35. package/client/components/footer/footer-entry.jsx +7 -1
  36. package/client/components/layout/layout.jsx +12 -19
  37. package/client/components/main/main.jsx +15 -1
  38. package/client/components/quick-commands/qm.styl +58 -0
  39. package/client/components/quick-commands/quick-commands-box.jsx +180 -83
  40. package/client/components/quick-commands/quick-commands-select.jsx +11 -0
  41. package/client/components/session/session-control.jsx +35 -2
  42. package/client/components/session/session-control.styl +5 -0
  43. package/client/components/session/session.jsx +13 -0
  44. package/client/components/setting-panel/setting-common.jsx +2 -0
  45. package/client/components/setting-panel/tab-widgets.jsx +27 -7
  46. package/client/components/sftp/file-item.jsx +0 -13
  47. package/client/components/side-panel-r/side-panel-r.jsx +11 -4
  48. package/client/components/sidebar/bookmark-select.jsx +14 -2
  49. package/client/components/sidebar/history-item.jsx +20 -4
  50. package/client/components/sidebar/history.jsx +7 -0
  51. package/client/components/terminal/mixins/term-touch.js +18 -0
  52. package/client/components/tree-list/tree-list.jsx +31 -3
  53. package/client/components/widgets/widget-control.jsx +4 -2
  54. package/client/components/widgets/widget-instance-detail.jsx +370 -0
  55. package/client/components/widgets/widget-instance.jsx +30 -13
  56. package/client/components/widgets/widget-instances.jsx +3 -1
  57. package/client/components/widgets/widgets-list.jsx +8 -0
  58. package/client/components/widgets/widgets.styl +100 -0
  59. package/client/store/common.js +200 -54
  60. package/client/store/init-state.js +15 -0
  61. package/client/store/load-data.js +73 -0
  62. package/client/store/store.js +6 -0
  63. package/client/store/watch.js +3 -1
  64. package/client/store/widgets.js +23 -5
  65. package/package.json +1 -1
  66. package/client/components/file-transfer/zip.js +0 -42
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  Form,
3
3
  Input,
4
+ InputNumber,
4
5
  Button,
5
6
  AutoComplete,
6
7
  Alert,
7
- Space,
8
- Dropdown
8
+ Select,
9
+ Space
9
10
  } from 'antd'
10
11
  import { useEffect, useMemo, useState } from 'react'
11
- import { DownOutlined, ReloadOutlined } from '@ant-design/icons'
12
+ import { ReloadOutlined } from '@ant-design/icons'
12
13
  import Link from '../common/external-link'
13
14
  import AiCache from './ai-cache'
14
15
  import {
@@ -19,6 +20,7 @@ import AiHistory, { addHistoryItem } from './ai-history'
19
20
  import message from '../common/message'
20
21
  import { getAIPresets } from './ai-presets'
21
22
  import { appendMandatoryGuardrails } from './ai-guardrails'
23
+ import './ai-config.styl'
22
24
 
23
25
  const STORAGE_KEY_CONFIG = 'ai_config_history'
24
26
  const EVENT_NAME_CONFIG = 'ai-config-history-update'
@@ -210,18 +212,32 @@ export default function AIConfigForm ({ initialValues, onSubmit, showAIConfig })
210
212
  form.setFieldsValue(values)
211
213
  }
212
214
 
213
- function renderPresetMenu () {
214
- const items = presets.map(p => ({
215
- key: p.id,
216
- label: p.nameAI,
217
- onClick: () => handleSelectPreset(p)
215
+ // A plain antd Select, on purpose: it already scrolls its list inside the
216
+ // viewport (a Dropdown menu grows past the bottom of a phone screen, so the
217
+ // tail of the 18 presets is unreachable there) and `showSearch` filters it.
218
+ // `optionFilterProp` is load-bearing: without it rc-select filters on the
219
+ // option *value* (our id), so "gemini" or "llama" match nothing. The label
220
+ // carries name and model, so filtering on it finds either.
221
+ // The label/select sizing lives in `.ai-preset-row` (ai-config.styl), because
222
+ // Space's `.ant-space-item` wrapper is the flex item, not the child.
223
+ function renderPresetSelect () {
224
+ const options = presets.map(p => ({
225
+ value: p.id,
226
+ label: p.modelAI ? `${p.nameAI} · ${p.modelAI}` : p.nameAI
218
227
  }))
219
228
  return (
220
- <Dropdown menu={{ items }} trigger={['click']}>
221
- <Button>
222
- {e('presets')} <DownOutlined />
223
- </Button>
224
- </Dropdown>
229
+ <div className='alignright'>
230
+ <Space className='mg1b width-100 ai-preset-row'>
231
+ <span>{e('presets')}</span>
232
+ <Select
233
+ showSearch
234
+ optionFilterProp='label'
235
+ options={options}
236
+ value={currentPreset?.id}
237
+ onSelect={id => handleSelectPreset(presets.find(p => p.id === id))}
238
+ />
239
+ </Space>
240
+ </div>
225
241
  )
226
242
  }
227
243
 
@@ -293,9 +309,7 @@ export default function AIConfigForm ({ initialValues, onSubmit, showAIConfig })
293
309
  type='warning'
294
310
  className='mg2b'
295
311
  />
296
- <div className='mg1b alignright'>
297
- {renderPresetMenu()}
298
- </div>
312
+ {renderPresetSelect()}
299
313
  <p>
300
314
  Full Url: {initialValues?.baseURLAI}{initialValues?.apiPathAI}
301
315
  </p>
@@ -356,6 +370,19 @@ export default function AIConfigForm ({ initialValues, onSubmit, showAIConfig })
356
370
  {renderModelInput()}
357
371
  </Form.Item>
358
372
 
373
+ <Form.Item
374
+ label='Context length'
375
+ name='contextLengthAI'
376
+ tooltip='How many tokens this model can hold in one request. Leave empty to guess from the model name; the chat panel uses it to show how full the context is.'
377
+ >
378
+ <InputNumber
379
+ placeholder='auto (detect from model name)'
380
+ min={1000}
381
+ step={1000}
382
+ style={{ width: '100%' }}
383
+ />
384
+ </Form.Item>
385
+
359
386
  <Form.Item
360
387
  label={renderApiKeyLabel()}
361
388
  name='apiKeyAI'
@@ -0,0 +1,20 @@
1
+ // Preset row: the "Presets" label and the provider select share one line.
2
+ // antd's Space wraps every child in a `.ant-space-item`, and that wrapper — not
3
+ // the child — is the flex item, so the flex behaviour has to be set on the
4
+ // wrappers. Put `flex` on the Select itself and it is silently ignored, which
5
+ // makes the row's overflow land on the label: at 480px wide the label is
6
+ // squeezed into a 17px column and wraps onto four lines.
7
+ .ai-preset-row
8
+ max-width 400px
9
+ .ant-space-item:first-child
10
+ // the label keeps its full text width and never wraps or shrinks
11
+ flex none
12
+ white-space nowrap
13
+
14
+ .ant-space-item:last-child
15
+ // the select takes the rest of the line, shrinking to nothing if it must
16
+ flex 1
17
+ min-width 0
18
+
19
+ .ant-select
20
+ width 100%
@@ -0,0 +1,83 @@
1
+ import { Tooltip } from 'antd'
2
+ import {
3
+ formatTokens,
4
+ formatPercent,
5
+ getUsageLevel,
6
+ CONTEXT_WARN_PERCENT
7
+ } from './ai-context'
8
+
9
+ // How full the context window is, as a small bar + count, with the breakdown
10
+ // in the tooltip. The number is what the next request will carry, so it is
11
+ // the one to watch before pressing Compress.
12
+ export default function AiContextIndicator ({ info }) {
13
+ if (!info || !info.tokens) {
14
+ return null
15
+ }
16
+ const {
17
+ tokens,
18
+ messagesTokens,
19
+ toolsTokens,
20
+ windowSize,
21
+ windowSource,
22
+ percent,
23
+ measuredTokens
24
+ } = info
25
+ const level = getUsageLevel(percent)
26
+ const width = Math.min(100, Math.max(2, percent || 0))
27
+
28
+ function renderWindowSource () {
29
+ if (windowSource === 'config') {
30
+ return `window ${formatTokens(windowSize)}, set in AI config`
31
+ }
32
+ if (windowSource === 'model') {
33
+ return `window ${formatTokens(windowSize)}, from the model name`
34
+ }
35
+ return `window assumed to be ${formatTokens(windowSize)} — set "Context length" in AI config if your model differs`
36
+ }
37
+
38
+ const tip = (
39
+ <div className='ai-context-tip'>
40
+ <div className='ai-context-tip-title'>Context of the next message</div>
41
+ <div className='ai-context-tip-row'>
42
+ <span>system + history</span>
43
+ <span>~{formatTokens(messagesTokens)}</span>
44
+ </div>
45
+ {toolsTokens > 0 && (
46
+ <div className='ai-context-tip-row'>
47
+ <span>agent tools</span>
48
+ <span>~{formatTokens(toolsTokens)}</span>
49
+ </div>
50
+ )}
51
+ <div className='ai-context-tip-row ai-context-tip-total'>
52
+ <span>total</span>
53
+ <span>~{formatTokens(tokens)} ({formatPercent(percent)})</span>
54
+ </div>
55
+ {measuredTokens > 0 && (
56
+ <div className='ai-context-tip-row'>
57
+ <span>last request, measured</span>
58
+ <span>{measuredTokens.toLocaleString()}</span>
59
+ </div>
60
+ )}
61
+ <div className='ai-context-tip-note'>{renderWindowSource()}</div>
62
+ {(level === 'warn' || level === 'danger') && (
63
+ <div className='ai-context-tip-warn'>
64
+ Over {CONTEXT_WARN_PERCENT}% — use Compress to summarize the session.
65
+ </div>
66
+ )}
67
+ </div>
68
+ )
69
+
70
+ return (
71
+ <Tooltip title={tip}>
72
+ <span className={`ai-context-indicator ai-context-${level}`}>
73
+ <span className='ai-context-bar'>
74
+ <span className='ai-context-bar-fill' style={{ width: width + '%' }} />
75
+ </span>
76
+ <span className='ai-context-count'>
77
+ {formatTokens(tokens)}/{formatTokens(windowSize)}
78
+ </span>
79
+ <span className='ai-context-percent'>{formatPercent(percent)}</span>
80
+ </span>
81
+ </Tooltip>
82
+ )
83
+ }
@@ -0,0 +1,272 @@
1
+ // Context accounting for the AI panel: how big is the conversation we are
2
+ // about to send, and how much of the model's context window does it fill.
3
+ //
4
+ // There is deliberately no tokenizer here. A real one needs the model's
5
+ // vocabulary (tiktoken & friends) and would pull a dependency into the
6
+ // renderer for a number that only has to be good enough to answer "should I
7
+ // compress?". The heuristic below is CJK aware and deliberately pessimistic,
8
+ // so the warning arrives a little early rather than too late. Where the
9
+ // provider reports real usage we show that number alongside the estimate.
10
+ //
11
+ // Pure module -- no window / store access -- so it can be unit tested and so
12
+ // the sender and the indicator cannot drift apart.
13
+
14
+ // Latin text and code average ~4 chars per token; 3.5 is the safe side.
15
+ const CHARS_PER_TOKEN = 3.5
16
+ // CJK is roughly one token per character (a little under for Chinese).
17
+ const TOKENS_PER_CJK_CHAR = 0.8
18
+ // Per message role/delimiter overhead, as counted by the OpenAI tokenizer.
19
+ const PER_MESSAGE_OVERHEAD = 4
20
+
21
+ // BMP ranges that tokenize densely: CJK ideographs, kana, full width forms.
22
+ const CJK_RE = /[\u2e80-\u2eff\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff00-\uffef]/g
23
+
24
+ export const DEFAULT_CONTEXT_WINDOW = 128000
25
+ export const CONTEXT_WARN_PERCENT = 70
26
+ export const CONTEXT_DANGER_PERCENT = 80
27
+
28
+ // Rough token count of a string. Never exact, never wildly wrong. Called on
29
+ // the whole conversation every time it changes, so it stays a single pass
30
+ // with one regex sweep rather than a per character test.
31
+ export function estimateTokens (text) {
32
+ if (!text) {
33
+ return 0
34
+ }
35
+ const str = typeof text === 'string' ? text : String(text)
36
+ const cjkChars = str.match(CJK_RE)
37
+ const cjk = cjkChars ? cjkChars.length : 0
38
+ const other = str.length - cjk
39
+ return Math.ceil(cjk * TOKENS_PER_CJK_CHAR + other / CHARS_PER_TOKEN)
40
+ }
41
+
42
+ // Tokens for a message array in the OpenAI chat shape (which is also what the
43
+ // anthropic / responses builders are fed before they re-shape it).
44
+ export function estimateMessagesTokens (messages) {
45
+ if (!Array.isArray(messages)) {
46
+ return 0
47
+ }
48
+ let total = 0
49
+ for (const m of messages) {
50
+ if (!m) {
51
+ continue
52
+ }
53
+ total += PER_MESSAGE_OVERHEAD
54
+ total += estimateTokens(m.content)
55
+ if (m.role) {
56
+ total += estimateTokens(m.role)
57
+ }
58
+ if (Array.isArray(m.tool_calls)) {
59
+ for (const tc of m.tool_calls) {
60
+ total += estimateTokens(tc && tc.id)
61
+ total += estimateTokens(tc && tc.function && tc.function.name)
62
+ total += estimateTokens(tc && tc.function && tc.function.arguments)
63
+ }
64
+ }
65
+ }
66
+ return total
67
+ }
68
+
69
+ // Tool schemas are re-sent with every agent request and are far from free --
70
+ // ignoring them would understate agent mode by a few thousand tokens.
71
+ export function estimateToolsTokens (tools) {
72
+ if (!Array.isArray(tools) || !tools.length) {
73
+ return 0
74
+ }
75
+ try {
76
+ return estimateTokens(JSON.stringify(tools))
77
+ } catch (e) {
78
+ return 0
79
+ }
80
+ }
81
+
82
+ // Best effort hints, checked 2026-09. No provider publishes the window over
83
+ // the API, and relays rename models freely, so this is only a starting point:
84
+ // the "Context length" field in the AI config always wins over it.
85
+ // Longest / most specific pattern first -- the list is scanned in order.
86
+ const MODEL_CONTEXT_WINDOWS = [
87
+ [/qwen-?long/, 10000000],
88
+
89
+ // 1M class
90
+ [/gpt-6|gpt-5\.6|gpt-5-6/, 1050000],
91
+ [/gemini/, 1048576],
92
+ [/claude-(opus|sonnet|fable)-5/, 1000000],
93
+ [/deepseek-v4/, 1000000],
94
+ [/qwen3\.(7|8)|qwen3-max|qwen3\.5-max/, 1000000],
95
+ [/kimi-?k3/, 1048576],
96
+
97
+ // 500k / 400k / 256k class
98
+ [/grok-4\.6/, 500000],
99
+ [/gpt-5/, 400000],
100
+ [/kimi-?k2\.7/, 262144],
101
+ [/grok-4/, 256000],
102
+
103
+ // 200k class
104
+ [/claude/, 200000],
105
+ [/\bo[134]\b/, 200000],
106
+
107
+ // 128k class
108
+ [/gpt-4\.1|gpt-4o|gpt-4-turbo|gpt-4-1106|gpt-4-0125/, 128000],
109
+ [/llama-?[34]/, 131072],
110
+ [/qwen/, 131072],
111
+ [/kimi|moonshot/, 131072],
112
+ [/glm|zhipu|chatglm/, 131072],
113
+ [/ernie|wenxin/, 131072],
114
+ [/grok/, 131072],
115
+ [/mistral-large/, 131072],
116
+
117
+ // older / smaller
118
+ [/deepseek/, 65536],
119
+ [/gpt-4-32k/, 32768],
120
+ [/mixtral|mistral/, 32768],
121
+ [/gpt-3\.5/, 16385],
122
+ [/gpt-4/, 8192],
123
+ [/llama-?2/, 4096]
124
+ ]
125
+
126
+ // Returns { size, source } where source is 'config' | 'model' | 'default'.
127
+ export function getContextWindow (model, override) {
128
+ const declared = Number(override)
129
+ if (declared > 0) {
130
+ return { size: declared, source: 'config' }
131
+ }
132
+ const id = String(model || '').toLowerCase()
133
+ for (const [re, size] of MODEL_CONTEXT_WINDOWS) {
134
+ if (re.test(id)) {
135
+ return { size, source: 'model' }
136
+ }
137
+ }
138
+ return { size: DEFAULT_CONTEXT_WINDOW, source: 'default' }
139
+ }
140
+
141
+ // The single source of truth for "what gets sent": both the request in
142
+ // ai-chat-history-item.jsx and the indicator in ai-chat.jsx go through here,
143
+ // so the number on screen is the number that leaves the machine.
144
+ //
145
+ // Returns null when there is no session to build from -- the sender reads
146
+ // that as "no history", and the main process then falls back to a plain
147
+ // prompt + role request.
148
+ //
149
+ // `upto` limits the window to entries at or before a timestamp (the entry
150
+ // being sent); `excludeId` drops one entry's response, which is what the
151
+ // sender does for its own turn. The indicator omits both to describe the
152
+ // *next* request, which will include every response so far.
153
+ export function buildSessionMessages ({
154
+ history,
155
+ chatSessionId,
156
+ upto = Infinity,
157
+ role = '',
158
+ excludeId = null
159
+ }) {
160
+ if (!chatSessionId) {
161
+ return null
162
+ }
163
+ const entries = (history || [])
164
+ .filter(h => h.chatSessionId === chatSessionId && h.timestamp <= upto)
165
+ .sort((a, b) => a.timestamp - b.timestamp)
166
+
167
+ // A compressed entry replaces everything before it.
168
+ let lastCompressIndex = -1
169
+ for (let i = entries.length - 1; i >= 0; i--) {
170
+ if (entries[i].compressed) {
171
+ lastCompressIndex = i
172
+ break
173
+ }
174
+ }
175
+
176
+ const messages = [
177
+ { role: 'system', content: role }
178
+ ]
179
+
180
+ const startIndex = lastCompressIndex >= 0 ? lastCompressIndex : 0
181
+ for (let i = startIndex; i < entries.length; i++) {
182
+ const entry = entries[i]
183
+ if (entry.compressed) {
184
+ messages.push({
185
+ role: 'user',
186
+ content: `Here is a summary of our previous conversation for context:\n\n${entry.response}`
187
+ })
188
+ messages.push({
189
+ role: 'assistant',
190
+ content: 'Understood. I will use this context as we continue.'
191
+ })
192
+ } else {
193
+ messages.push({
194
+ role: 'user',
195
+ // promptWithAttachments carries the inlined file blocks;
196
+ // falls back to the plain prompt for legacy entries
197
+ content: entry.promptWithAttachments || entry.prompt
198
+ })
199
+ if (entry.response && entry.id !== excludeId) {
200
+ messages.push({ role: 'assistant', content: entry.response })
201
+ }
202
+ }
203
+ }
204
+ return messages
205
+ }
206
+
207
+ // Agent mode keeps the session history but swaps in its own system prompt.
208
+ export function buildAgentMessages ({ systemPrompt, conversationMessages, prompt }) {
209
+ if (conversationMessages && conversationMessages.length > 1) {
210
+ return [
211
+ { role: 'system', content: systemPrompt },
212
+ ...conversationMessages.filter(m => m.role !== 'system')
213
+ ]
214
+ }
215
+ return [
216
+ { role: 'system', content: systemPrompt },
217
+ { role: 'user', content: prompt }
218
+ ]
219
+ }
220
+
221
+ // Everything the indicator needs, from the messages that will be sent.
222
+ export function summarizeContext (messages, { model, contextLength, tools } = {}) {
223
+ const messagesTokens = estimateMessagesTokens(messages)
224
+ const toolsTokens = estimateToolsTokens(tools)
225
+ const tokens = messagesTokens + toolsTokens
226
+ const win = getContextWindow(model, contextLength)
227
+ return {
228
+ tokens,
229
+ messagesTokens,
230
+ toolsTokens,
231
+ windowSize: win.size,
232
+ windowSource: win.source,
233
+ percent: win.size ? (tokens / win.size) * 100 : null,
234
+ model: model || '',
235
+ measuredTokens: null
236
+ }
237
+ }
238
+
239
+ export function formatTokens (n) {
240
+ const v = Number(n) || 0
241
+ if (v < 1000) {
242
+ return String(Math.round(v))
243
+ }
244
+ if (v < 10000) {
245
+ return (v / 1000).toFixed(1) + 'k'
246
+ }
247
+ if (v < 1000000) {
248
+ return Math.round(v / 1000) + 'k'
249
+ }
250
+ return (v / 1000000).toFixed(1) + 'M'
251
+ }
252
+
253
+ export function formatPercent (p) {
254
+ if (p === null || p === undefined || !isFinite(p)) {
255
+ return ''
256
+ }
257
+ // below 10% a whole number would just read as 0%
258
+ return (p > 0 && p < 10 ? p.toFixed(1) : String(Math.round(p))) + '%'
259
+ }
260
+
261
+ export function getUsageLevel (percent) {
262
+ if (percent === null || percent === undefined || !isFinite(percent)) {
263
+ return 'unknown'
264
+ }
265
+ if (percent >= CONTEXT_DANGER_PERCENT) {
266
+ return 'danger'
267
+ }
268
+ if (percent >= CONTEXT_WARN_PERCENT) {
269
+ return 'warn'
270
+ }
271
+ return 'ok'
272
+ }
@@ -10,6 +10,7 @@ import {
10
10
  FlagFilled
11
11
  } from '@ant-design/icons'
12
12
  import getBrand from './get-brand'
13
+ import CopyIcon from './copy-icon'
13
14
 
14
15
  const e = window.translate
15
16
 
@@ -97,12 +98,7 @@ export default function AIOutput ({ item }) {
97
98
  }
98
99
 
99
100
  function handleToggleFlag () {
100
- const index = window.store.aiChatHistory.findIndex(i => i.id === item.id)
101
- if (index === -1) {
102
- return
103
- }
104
- window.store.aiChatHistory[index].flagged = !window.store.aiChatHistory[index].flagged
105
- window.store.aiChatHistory = [...window.store.aiChatHistory]
101
+ window.store.updateAiHistoryEntry(item.id, { flagged: !item.flagged })
106
102
  }
107
103
 
108
104
  function renderFlag () {
@@ -160,6 +156,9 @@ export default function AIOutput ({ item }) {
160
156
  <>
161
157
  {renderBrand()}
162
158
  <ReactMarkdown {...mdProps} />
159
+ <div className='ai-output-actions'>
160
+ <CopyIcon text={response} />
161
+ </div>
163
162
  </>
164
163
  )}
165
164
  </div>
@@ -6,7 +6,7 @@ export const defaultAIPresets = [
6
6
  apiPathAI: '/chat/completions',
7
7
  modelAI: 'deepseek-v4-flash-0731',
8
8
  authHeaderNameAI: 'Authorization: Bearer',
9
- siteUrl: 'https://fluxionai.world/register?aff=7H7DERHU3GFF&utm_source=github&utm_medium=link&utm_campaign=electerm'
9
+ siteUrl: 'https://fluxionai.world/register?source=github&campaign=electerm-20260923&promo=ELECTERM&aff=7H7DERHU3GFF'
10
10
  },
11
11
  {
12
12
  id: 'atlascloud',
@@ -67,21 +67,6 @@ export const defaultAIPresets = [
67
67
  authHeaderNameAI: 'Authorization: Bearer',
68
68
  siteUrl: 'https://platform.openai.com/api-keys?utm_source=electerm_app&utm_medium=link&utm_campaign=electerm'
69
69
  },
70
- {
71
- id: 'openai-responses',
72
- nameAI: 'OpenAI (Responses API)',
73
- baseURLAI: 'https://api.openai.com/v1',
74
- apiPathAI: '/responses',
75
- modelAI: 'gpt-4o',
76
- authHeaderNameAI: 'Authorization: Bearer',
77
- modelAIs: [
78
- { value: 'gpt-4o' },
79
- { value: 'gpt-4o-mini' },
80
- { value: 'gpt-4.1' },
81
- { value: 'o4-mini' }
82
- ],
83
- siteUrl: 'https://platform.openai.com/api-keys?utm_source=electerm_app&utm_medium=link&utm_campaign=electerm'
84
- },
85
70
  {
86
71
  id: 'anthropic',
87
72
  nameAI: 'Anthropic Claude',
@@ -26,11 +26,26 @@
26
26
  border-radius 3px
27
27
  pre
28
28
  margin-bottom 0
29
- // .code-block-actions
30
- // display block
31
- // &:hover
32
- // .code-block-actions
33
- // display block
29
+
30
+ // copy icons stay visible all the time, never hover only
31
+ .copy-icon,
32
+ .code-action-icon
33
+ color var(--text-dark)
34
+ font-size 14px
35
+ &:hover
36
+ color var(--primary)
37
+
38
+ .code-block-actions
39
+ display flex
40
+ justify-content flex-end
41
+
42
+ // left aligned on purpose: the streaming stop/loading icon is pinned to the
43
+ // bottom right of .chat-history-item, so a right aligned copy icon would sit
44
+ // on top of it while a response is streaming
45
+ .ai-output-actions
46
+ display flex
47
+ justify-content flex-start
48
+ margin-top 6px
34
49
 
35
50
  .ai-stream-output
36
51
  position relative
@@ -223,9 +238,18 @@
223
238
  font-size 12px
224
239
  color var(--text-color-2)
225
240
 
241
+ .agent-tool-pre-wrap
242
+ position relative
243
+
244
+ .agent-tool-copy
245
+ position absolute
246
+ top 5px
247
+ right 6px
248
+ z-index 1
249
+
226
250
  .agent-tool-pre
227
251
  background var(--main-dark)
228
- padding 6px 8px
252
+ padding 6px 26px 6px 8px
229
253
  border-radius 3px
230
254
  font-size 12px
231
255
  max-height 200px
@@ -313,3 +337,78 @@
313
337
  &:hover
314
338
  border-color var(--primary)
315
339
  color var(--text)
340
+
341
+ // context size indicator, right hand side of the ai chat toolbar
342
+ .ai-context-indicator
343
+ display inline-flex
344
+ align-items center
345
+ gap 4px
346
+ flex-shrink 0
347
+ font-size 11px
348
+ line-height 1
349
+ color var(--text-color-2)
350
+ cursor default
351
+ user-select none
352
+
353
+ .ai-context-bar
354
+ display inline-block
355
+ width 34px
356
+ height 5px
357
+ border-radius 3px
358
+ background var(--main-darker)
359
+ overflow hidden
360
+ flex-shrink 0
361
+
362
+ .ai-context-bar-fill
363
+ display block
364
+ height 100%
365
+ border-radius 3px
366
+ background var(--primary)
367
+ transition width 0.2s
368
+
369
+ .ai-context-count
370
+ color var(--text-dark)
371
+ font-variant-numeric tabular-nums
372
+
373
+ .ai-context-percent
374
+ font-variant-numeric tabular-nums
375
+
376
+ .ai-context-warn
377
+ .ai-context-bar-fill
378
+ background #faad14
379
+ .ai-context-percent
380
+ color #faad14
381
+
382
+ .ai-context-danger
383
+ .ai-context-bar-fill
384
+ background #ff4d4f
385
+ .ai-context-percent
386
+ color #ff4d4f
387
+ font-weight 500
388
+
389
+ .ai-context-tip
390
+ font-size 12px
391
+ min-width 210px
392
+
393
+ .ai-context-tip-title
394
+ font-weight 500
395
+ margin-bottom 4px
396
+
397
+ .ai-context-tip-row
398
+ display flex
399
+ justify-content space-between
400
+ gap 12px
401
+
402
+ .ai-context-tip-total
403
+ font-weight 500
404
+ border-top 1px solid rgba(128, 128, 128, 0.35)
405
+ margin-top 2px
406
+ padding-top 2px
407
+
408
+ .ai-context-tip-note
409
+ margin-top 4px
410
+ opacity 0.75
411
+
412
+ .ai-context-tip-warn
413
+ margin-top 4px
414
+ color #faad14