@electerm/electerm-react 3.11.12 → 3.15.0

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 (36) hide show
  1. package/client/common/bookmark-schemas.js +2 -1
  2. package/client/common/constants.js +11 -2
  3. package/client/common/is-absolute-path.js +1 -1
  4. package/client/common/normalize-remote-path.js +20 -0
  5. package/client/common/resolve.js +16 -0
  6. package/client/components/ai/agent-tools.js +204 -0
  7. package/client/components/ai/agent.js +12 -10
  8. package/client/components/ai/ai-chat-history-item.jsx +15 -25
  9. package/client/components/ai/ai-chat.jsx +24 -9
  10. package/client/components/bookmark-form/bookmark-schema.js +2 -1
  11. package/client/components/bookmark-form/config/serial.js +3 -2
  12. package/client/components/footer/cmd-history.jsx +20 -11
  13. package/client/components/main/main.jsx +1 -1
  14. package/client/components/sftp/address-bar.jsx +22 -6
  15. package/client/components/sftp/file-item.jsx +31 -1
  16. package/client/components/sftp/file-read.js +11 -2
  17. package/client/components/sftp/sftp-entry.jsx +38 -3
  18. package/client/components/shortcuts/shortcut-handler.js +7 -0
  19. package/client/components/sidebar/history.jsx +16 -8
  20. package/client/components/sys-menu/icons-map.jsx +10 -2
  21. package/client/components/terminal/attach-addon-custom.js +1 -1
  22. package/client/components/terminal/drop-file-modal.jsx +53 -22
  23. package/client/components/terminal/terminal-apis.js +9 -0
  24. package/client/components/terminal/terminal.jsx +179 -3
  25. package/client/components/terminal/xmodem-client.js +244 -0
  26. package/client/components/terminal-info/base.jsx +41 -38
  27. package/client/components/terminal-info/data-cols-parser.jsx +2 -1
  28. package/client/components/terminal-info/disk.jsx +4 -2
  29. package/client/components/terminal-info/log-path-edit.jsx +3 -2
  30. package/client/components/terminal-info/network.jsx +3 -1
  31. package/client/components/terminal-info/resource.jsx +3 -3
  32. package/client/components/tree-list/tree-list.styl +7 -1
  33. package/client/store/mcp-handler.js +41 -9
  34. package/client/store/quick-command.js +3 -2
  35. package/client/store/watch.js +1 -1
  36. package/package.json +1 -1
@@ -34,6 +34,7 @@ export default function TerminalInfoDisk (props) {
34
34
  const p = network[k]
35
35
  const pv = net[k]
36
36
  if (
37
+ diff > 0 &&
37
38
  p &&
38
39
  pv &&
39
40
  p.download &&
@@ -43,6 +44,7 @@ export default function TerminalInfoDisk (props) {
43
44
  p.down = Math.floor((p.download - pv.download) / diff)
44
45
  }
45
46
  if (
47
+ diff > 0 &&
46
48
  p &&
47
49
  pv &&
48
50
  p.upload &&
@@ -92,7 +94,7 @@ export default function TerminalInfoDisk (props) {
92
94
  },
93
95
  render: (v) => {
94
96
  if (k === 'up' || k === 'down') {
95
- return filesize(v || 0)
97
+ return filesize(Number.isFinite(v) ? v : 0)
96
98
  }
97
99
  return v
98
100
  }
@@ -2,7 +2,7 @@
2
2
  * cpu/swap/mem general usage
3
3
  */
4
4
 
5
- import { isEmpty, isUndefined } from 'lodash-es'
5
+ import { isEmpty } from 'lodash-es'
6
6
  import { Progress } from 'antd'
7
7
  import parseInt10 from '../../common/parse-int10'
8
8
 
@@ -51,7 +51,7 @@ export default function TerminalInfoResource (props) {
51
51
  percent,
52
52
  name
53
53
  } = obj
54
- const hasPercent = !isUndefined(percent)
54
+ const hasPercent = Number.isFinite(percent)
55
55
  const p = hasPercent
56
56
  ? percent
57
57
  : computePercent(used, total) || 0
@@ -74,7 +74,7 @@ export default function TerminalInfoResource (props) {
74
74
  if (terminalInfos.includes('cpu')) {
75
75
  data.push({
76
76
  name: 'cpu',
77
- percent: parseInt10(cpu)
77
+ percent: parseInt10(cpu) || 0
78
78
  })
79
79
  }
80
80
  if (terminalInfos.includes('mem')) {
@@ -118,10 +118,16 @@
118
118
  visibility hidden
119
119
  &:hover
120
120
  .tree-item-title
121
- padding-right 120px
121
+ padding-right 60px
122
122
  .tree-item-op-wrap
123
123
  opacity 1
124
124
  pointer-events auto
125
+ .add-menu-wrap
126
+ .sidebar-panel
127
+ .tree-list-row
128
+ &:hover
129
+ .tree-item-title
130
+ padding-right 20px
125
131
 
126
132
  .tree-list-row-group
127
133
  position relative
@@ -11,6 +11,11 @@ import {
11
11
  getLocalFileInfo,
12
12
  getRemoteFileInfo
13
13
  } from '../components/sftp/file-read'
14
+ import {
15
+ fixBookmarkData,
16
+ validateBookmarkData
17
+ } from '../components/bookmark-form/fix-bookmark-default'
18
+ import newTerm from '../common/new-terminal'
14
19
 
15
20
  export default Store => {
16
21
  // Initialize MCP handler - called when MCP widget is started
@@ -96,6 +101,9 @@ export default Store => {
96
101
  case 'open_local_terminal':
97
102
  result = store.mcpOpenLocalTerminal()
98
103
  break
104
+ case 'open_tab':
105
+ result = store.mcpOpenTab(args)
106
+ break
99
107
 
100
108
  // Terminal operations
101
109
  case 'send_terminal_command':
@@ -207,16 +215,14 @@ export default Store => {
207
215
 
208
216
  Store.prototype.mcpAddBookmark = async function (args) {
209
217
  const { store } = window
210
- const bookmark = {
218
+ const bookmark = fixBookmarkData({
211
219
  id: uid(),
212
- title: args.title,
213
- host: args.host || '',
214
- port: args.port || 22,
215
- username: args.username || '',
216
- password: args.password || '',
217
- type: args.type || 'local',
218
- term: 'xterm-256color',
219
220
  ...args
221
+ })
222
+
223
+ const { valid, errors } = validateBookmarkData(bookmark)
224
+ if (!valid) {
225
+ throw new Error(errors.join(', '))
220
226
  }
221
227
 
222
228
  store.addItem(bookmark, settingMap.bookmarks)
@@ -462,6 +468,32 @@ export default Store => {
462
468
  }
463
469
  }
464
470
 
471
+ Store.prototype.mcpOpenTab = function (args) {
472
+ const { store } = window
473
+ const data = fixBookmarkData({ ...args })
474
+
475
+ const { valid, errors } = validateBookmarkData(data)
476
+ if (!valid) {
477
+ throw new Error(errors.join(', '))
478
+ }
479
+
480
+ const tab = {
481
+ ...data,
482
+ from: 'mcp',
483
+ ...newTerm(true, true)
484
+ }
485
+
486
+ store.addTab(tab)
487
+ const newTabId = store.activeTabId
488
+
489
+ return {
490
+ success: true,
491
+ tabId: newTabId,
492
+ type: data.type,
493
+ message: `Opened ${data.type || 'local'} tab`
494
+ }
495
+ }
496
+
465
497
  // ==================== Terminal APIs ====================
466
498
 
467
499
  Store.prototype.mcpSendTerminalCommand = function (args) {
@@ -477,7 +509,7 @@ export default Store => {
477
509
  throw new Error('No command provided')
478
510
  }
479
511
 
480
- store.runQuickCommand(command, args.inputOnly || false)
512
+ store.runQuickCommand(command, args.inputOnly || false, tabId)
481
513
 
482
514
  return {
483
515
  success: true,
@@ -57,8 +57,9 @@ export default Store => {
57
57
  window.store.delItem({ id }, settingMap.quickCommands)
58
58
  }
59
59
 
60
- Store.prototype.runQuickCommand = function (cmd, inputOnly = false) {
61
- refs.get('term-' + window.store.activeTabId)?.runQuickCommand(cmd, inputOnly)
60
+ Store.prototype.runQuickCommand = function (cmd, inputOnly = false, tabId) {
61
+ const tid = tabId || window.store.activeTabId
62
+ refs.get('term-' + tid)?.runQuickCommand(cmd, inputOnly)
62
63
  }
63
64
 
64
65
  Store.prototype.runQuickCommandItem = debounce(async (id) => {
@@ -23,13 +23,13 @@ export default store => {
23
23
  for (const name of dbNamesForWatch) {
24
24
  window[`watch${name}Running`] = false
25
25
  window[`watch${name}`] = autoRun(async () => {
26
+ const n = store.getItems(name)
26
27
  if (window.migrating || window[`watch${name}Running`]) {
27
28
  return
28
29
  }
29
30
  window[`watch${name}Running`] = true
30
31
  try {
31
32
  const old = refsStatic.get('oldState-' + name)
32
- const n = store.getItems(name)
33
33
  const { updated, added, removed } = dataCompare(
34
34
  old,
35
35
  n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "3.11.12",
3
+ "version": "3.15.0",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",