tmex-cli 0.12.2 → 0.12.3
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.
- package/CHANGELOG.md +3 -15
- package/dist/runtime/server.js +241 -8
- package/package.json +1 -1
- package/resources/fe-dist/assets/DevicePage-EoPdR0a8.js +15 -0
- package/resources/fe-dist/assets/{DevicesPage-C7THDzTX.js → DevicesPage-DaO7f0iC.js} +2 -2
- package/resources/fe-dist/assets/{FilePage-D8V8P2IA.js → FilePage-BQsLFpIe.js} +2 -2
- package/resources/fe-dist/assets/{SettingsPage-BOTyBhHH.js → SettingsPage-DNq70CL7.js} +5 -10
- package/resources/fe-dist/assets/{arc-DcujnLz7.js → arc-Bw8pvFsh.js} +2 -2
- package/resources/fe-dist/assets/architectureDiagram-3BPJPVTR-ClXPEeos.js +37 -0
- package/resources/fe-dist/assets/{blockDiagram-GPEHLZMM-BFh4xZY2.js → blockDiagram-GPEHLZMM-Sp24bCmA.js} +2 -2
- package/resources/fe-dist/assets/{c4Diagram-AAUBKEIU-nUyGK7Ke.js → c4Diagram-AAUBKEIU-DjyOwpgl.js} +2 -2
- package/resources/fe-dist/assets/{card-BkRqR9zz.js → card-CMyk5OFt.js} +2 -2
- package/resources/fe-dist/assets/channel-B9WrZCGJ.js +2 -0
- package/resources/fe-dist/assets/{chunk-2J33WTMH-z2oMKYMn.js → chunk-2J33WTMH-_i-tgxvN.js} +2 -2
- package/resources/fe-dist/assets/{chunk-4BX2VUAB-CCD_pyAh.js → chunk-4BX2VUAB-CYDjMAJT.js} +2 -2
- package/resources/fe-dist/assets/{chunk-55IACEB6-Dx2_9d-z.js → chunk-55IACEB6-CGcgNWHA.js} +2 -2
- package/resources/fe-dist/assets/{chunk-727SXJPM-DA36poir.js → chunk-727SXJPM-CVF1o51L.js} +2 -2
- package/resources/fe-dist/assets/{chunk-AQP2D5EJ-CQoXkVd4.js → chunk-AQP2D5EJ-BzXiGlmX.js} +2 -2
- package/resources/fe-dist/assets/{chunk-FMBD7UC4-A6Yn7A44.js → chunk-FMBD7UC4-DG7P62CK.js} +2 -2
- package/resources/fe-dist/assets/{chunk-ND2GUHAM-BsNl2EMT.js → chunk-ND2GUHAM-C82kWDQB.js} +2 -2
- package/resources/fe-dist/assets/{chunk-QZHKN3VN-BM_QNxf6.js → chunk-QZHKN3VN-FB0r6Osl.js} +2 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-B1-CPF_4.js +2 -0
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-B1-CPF_4.js +2 -0
- package/resources/fe-dist/assets/cose-bilkent-S5V4N54A--v8cfu0h.js +2 -0
- package/resources/fe-dist/assets/{dagre-BM42HDAG-C9Up3ckQ.js → dagre-BM42HDAG-BTLOD-KX.js} +2 -2
- package/resources/fe-dist/assets/{diagram-2AECGRRQ-CtuDndmY.js → diagram-2AECGRRQ-29BFdqPY.js} +2 -2
- package/resources/fe-dist/assets/{diagram-5GNKFQAL-BQfskK8S.js → diagram-5GNKFQAL-t_wHTq5Q.js} +2 -2
- package/resources/fe-dist/assets/{diagram-KO2AKTUF-CGJi8q81.js → diagram-KO2AKTUF-JNh9Pmt9.js} +2 -2
- package/resources/fe-dist/assets/{diagram-LMA3HP47-DAMQIoLQ.js → diagram-LMA3HP47-DAifhNss.js} +2 -2
- package/resources/fe-dist/assets/{diagram-OG6HWLK6-D2s__dFc.js → diagram-OG6HWLK6-BOqtQL5W.js} +2 -2
- package/resources/fe-dist/assets/{erDiagram-TEJ5UH35-_UJYLIQN.js → erDiagram-TEJ5UH35-W-aJKAOK.js} +2 -2
- package/resources/fe-dist/assets/{flowDiagram-I6XJVG4X-DN-qktDh.js → flowDiagram-I6XJVG4X-DEt1TjbJ.js} +2 -2
- package/resources/fe-dist/assets/ganttDiagram-6RSMTGT7-CrYu9aI_.js +293 -0
- package/resources/fe-dist/assets/{gitGraphDiagram-PVQCEYII-Qar2sVRo.js → gitGraphDiagram-PVQCEYII-BlltYekf.js} +2 -2
- package/resources/fe-dist/assets/index-CXIj7HZi.css +1 -0
- package/resources/fe-dist/assets/{index-Ra6pj0rt.js → index-FNpsxYPN.js} +53 -53
- package/resources/fe-dist/assets/{infoDiagram-5YYISTIA-2e6tU_v9.js → infoDiagram-5YYISTIA-nhdfbNPF.js} +2 -2
- package/resources/fe-dist/assets/{ishikawaDiagram-YF4QCWOH-BghKvoM4.js → ishikawaDiagram-YF4QCWOH-CwluZjLD.js} +2 -2
- package/resources/fe-dist/assets/{journeyDiagram-JHISSGLW-D-cHSGb_.js → journeyDiagram-JHISSGLW-BkvLX_wz.js} +2 -2
- package/resources/fe-dist/assets/{kanban-definition-UN3LZRKU-BE6Cb-OK.js → kanban-definition-UN3LZRKU-DU_bbXWH.js} +2 -2
- package/resources/fe-dist/assets/{linear-CwDBnUH0.js → linear-ByJrBbSQ.js} +2 -2
- package/resources/fe-dist/assets/{markdown-preview-BlQiC8ND.js → markdown-preview-D9O-wO1U.js} +4 -4
- package/resources/fe-dist/assets/{mermaid.core-DDMkLXrp.js → mermaid.core-DR6r9S_a.js} +6 -6
- package/resources/fe-dist/assets/{mindmap-definition-RKZ34NQL-C9xVR7Ut.js → mindmap-definition-RKZ34NQL-BYXsfrSb.js} +2 -2
- package/resources/fe-dist/assets/{pieDiagram-4H26LBE5-DW_4RcBv.js → pieDiagram-4H26LBE5-leRJNTgW.js} +2 -2
- package/resources/fe-dist/assets/{quadrantDiagram-W4KKPZXB-DoIrZmk2.js → quadrantDiagram-W4KKPZXB-BfxS6APJ.js} +2 -2
- package/resources/fe-dist/assets/{requirementDiagram-4Y6WPE33-CYcJSuPe.js → requirementDiagram-4Y6WPE33-D1ViYHCD.js} +2 -2
- package/resources/fe-dist/assets/{sankeyDiagram-5OEKKPKP-CrIkKM6h.js → sankeyDiagram-5OEKKPKP-CFjujjK9.js} +2 -2
- package/resources/fe-dist/assets/{sequenceDiagram-3UESZ5HK-DgzGHhGk.js → sequenceDiagram-3UESZ5HK-DYKl7nA9.js} +2 -2
- package/resources/fe-dist/assets/{stateDiagram-AJRCARHV-C6Dhr3fY.js → stateDiagram-AJRCARHV-C3e0GwoJ.js} +2 -2
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-Bj3cAhsB.js +2 -0
- package/resources/fe-dist/assets/terminal-settings-panel-DLuBkEEZ.js +26 -0
- package/resources/fe-dist/assets/{timeline-definition-PNZ67QCA-jJ1iauQ0.js → timeline-definition-PNZ67QCA-DO38TAIg.js} +2 -2
- package/resources/fe-dist/assets/{vennDiagram-CIIHVFJN-DLRoaoJ9.js → vennDiagram-CIIHVFJN-Co9hBQx5.js} +2 -2
- package/resources/fe-dist/assets/{wardley-L42UT6IY-CykeHWp8.js → wardley-L42UT6IY-lf2QB-Cd.js} +2 -2
- package/resources/fe-dist/assets/{wardleyDiagram-YWT4CUSO-U22jzD8a.js → wardleyDiagram-YWT4CUSO-fJgWAjlp.js} +2 -2
- package/resources/fe-dist/assets/{xychartDiagram-2RQKCTM6-CiXS9PJ2.js → xychartDiagram-2RQKCTM6-DdxhqP-F.js} +2 -2
- package/resources/fe-dist/index.html +2 -2
- package/resources/gateway-drizzle/0009_lying_lethal_legion.sql +9 -0
- package/resources/gateway-drizzle/meta/_journal.json +7 -0
- package/resources/fe-dist/assets/DevicePage-B0fQ6yWB.js +0 -25
- package/resources/fe-dist/assets/architectureDiagram-3BPJPVTR-i8499Wfc.js +0 -37
- package/resources/fe-dist/assets/channel-DqmfsuLY.js +0 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-D3Z9BeOE.js +0 -2
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-D3Z9BeOE.js +0 -2
- package/resources/fe-dist/assets/cose-bilkent-S5V4N54A-1lMO_Dod.js +0 -2
- package/resources/fe-dist/assets/ganttDiagram-6RSMTGT7-CNuuuhXX.js +0 -293
- package/resources/fe-dist/assets/index-BhU3LRKb.css +0 -1
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-BiSh2azE.js +0 -2
- package/resources/fe-dist/assets/terminal-settings-panel-CpnmWQtf.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 0.12.
|
|
1
|
+
# 0.12.3
|
|
2
2
|
|
|
3
3
|
_2026-06-15_
|
|
4
4
|
|
|
@@ -6,13 +6,7 @@ _2026-06-15_
|
|
|
6
6
|
|
|
7
7
|
### New
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
- Mobile keyboard behavior: choose how the page reacts when the on-screen keyboard opens — shift the page up, resize the terminal, or keep the cursor above the keyboard — for smoother typing on phones.
|
|
11
|
-
|
|
12
|
-
### Improvements
|
|
13
|
-
|
|
14
|
-
- Terminal settings are now in one place: a dedicated Settings tab and a quick panel from the terminal, both with a live preview.
|
|
15
|
-
- UI polish and refinements (spacing, dark-mode readability, settings tabs on mobile).
|
|
9
|
+
- Custom terminal shortcuts: build your own quick-action bar for the terminal — add, remove, drag to reorder, rename, and capture key combinations by pressing them. Your shortcuts are saved on the server and shared across all your browsers. Built-in special actions (paste, toggle the text-input keyboard, start a new Agent session, scroll the terminal to the bottom) can be added too, and an optional icon mode shows keys as Apple-style symbols (⌃⇧⏎). A live preview lets you see the bar before you save.
|
|
16
10
|
|
|
17
11
|
---
|
|
18
12
|
|
|
@@ -20,10 +14,4 @@ _2026-06-15_
|
|
|
20
14
|
|
|
21
15
|
### 新增
|
|
22
16
|
|
|
23
|
-
-
|
|
24
|
-
- 手机键盘行为:可选择软键盘弹出时页面的避让方式——整页上移、缩放终端、或让光标始终在键盘上方——手机上输入更顺手。
|
|
25
|
-
|
|
26
|
-
### 改进
|
|
27
|
-
|
|
28
|
-
- 终端设置集中到一处:独立的「终端」设置页,以及终端内的快捷面板,均带实时预览。
|
|
29
|
-
- 界面细节优化(间距、深色模式可读性、移动端设置 tab 等)。
|
|
17
|
+
- 自定义终端快捷键:可以自己定制终端的快捷按钮栏——增删、拖拽排序、重命名,还能直接按下组合键来录入。快捷键保存在服务器、多端共享。内置特殊动作(粘贴、切换文本框键盘、新建 Agent 会话、终端回到最下方)也能一键加入;并可选「图标模式」用苹果风格符号(⌃⇧⏎)显示按键。编辑时提供实时预览,保存后生效。
|
package/dist/runtime/server.js
CHANGED
|
@@ -22771,7 +22771,36 @@ var I18N_RESOURCES = {
|
|
|
22771
22771
|
lineHeight: "Line Height",
|
|
22772
22772
|
fontFamily: "Font",
|
|
22773
22773
|
preview: "Preview",
|
|
22774
|
-
savedInBrowser: "These settings are saved in this browser only."
|
|
22774
|
+
savedInBrowser: "These settings are saved in this browser only.",
|
|
22775
|
+
shortcuts: {
|
|
22776
|
+
title: "Custom Shortcuts",
|
|
22777
|
+
savedOnServer: "Saved on the server and shared across all your browsers \u2014 changes take effect after you click Save.",
|
|
22778
|
+
preview: "Preview",
|
|
22779
|
+
useIcons: "Show keys as icons",
|
|
22780
|
+
useIconsDesc: "Replace key names like Ctrl/Shift/Enter with Apple-style symbols (\u2303\u21E7\u23CE).",
|
|
22781
|
+
dragHandle: "Drag to reorder",
|
|
22782
|
+
delete: "Delete",
|
|
22783
|
+
labelPlaceholder: "Label",
|
|
22784
|
+
payloadPlaceholder: "Sequence, e.g. \\x1b[A",
|
|
22785
|
+
addShortcut: "Add shortcut",
|
|
22786
|
+
capturePrompt: "Press any key combination\u2026",
|
|
22787
|
+
captureHint: "Click here, then press a key to capture",
|
|
22788
|
+
advanced: "Advanced: enter sequence manually",
|
|
22789
|
+
add: "Add",
|
|
22790
|
+
reset: "Reset to default",
|
|
22791
|
+
save: "Save",
|
|
22792
|
+
saved: "Shortcuts saved",
|
|
22793
|
+
saveFailed: "Failed to save shortcuts",
|
|
22794
|
+
loading: "Loading\u2026",
|
|
22795
|
+
action: {
|
|
22796
|
+
paste: "Paste",
|
|
22797
|
+
toggleKeyboard: "Toggle text input / keyboard",
|
|
22798
|
+
newAgentSession: "New Agent session",
|
|
22799
|
+
scrollToBottom: "Scroll terminal to bottom"
|
|
22800
|
+
},
|
|
22801
|
+
loadFailed: "Failed to load shortcuts",
|
|
22802
|
+
retry: "Retry"
|
|
22803
|
+
}
|
|
22775
22804
|
},
|
|
22776
22805
|
deviceManagement: {
|
|
22777
22806
|
title: "Device Management",
|
|
@@ -23083,7 +23112,9 @@ Time: {{time}}`,
|
|
|
23083
23112
|
upgradeNotAllowed: "In-app update is not available for this installation.",
|
|
23084
23113
|
upgradeInProgress: "An upgrade is already in progress.",
|
|
23085
23114
|
upgradeVersionRequired: "Target version is required.",
|
|
23086
|
-
updateCheckFailed: "Failed to query the npm registry."
|
|
23115
|
+
updateCheckFailed: "Failed to query the npm registry.",
|
|
23116
|
+
terminalShortcutsTooMany: "Too many shortcuts",
|
|
23117
|
+
terminalShortcutInvalid: "Invalid shortcut configuration"
|
|
23087
23118
|
},
|
|
23088
23119
|
notification: {
|
|
23089
23120
|
clickToJump: "Click to jump to corresponding pane",
|
|
@@ -23654,7 +23685,36 @@ Time: {{time}}`,
|
|
|
23654
23685
|
lineHeight: "\u884C\u9AD8",
|
|
23655
23686
|
fontFamily: "\u5B57\u4F53",
|
|
23656
23687
|
preview: "\u9884\u89C8",
|
|
23657
|
-
savedInBrowser: "\u8FD9\u4E9B\u8BBE\u7F6E\u4EC5\u4FDD\u5B58\u5728\u5F53\u524D\u6D4F\u89C8\u5668\u4E2D\u3002"
|
|
23688
|
+
savedInBrowser: "\u8FD9\u4E9B\u8BBE\u7F6E\u4EC5\u4FDD\u5B58\u5728\u5F53\u524D\u6D4F\u89C8\u5668\u4E2D\u3002",
|
|
23689
|
+
shortcuts: {
|
|
23690
|
+
title: "\u81EA\u5B9A\u4E49\u5FEB\u6377\u952E",
|
|
23691
|
+
savedOnServer: "\u4FDD\u5B58\u5728\u670D\u52A1\u5668\u3001\u591A\u7AEF\u5171\u4EAB\u2014\u2014\u4FEE\u6539\u540E\u9700\u70B9\u300C\u4FDD\u5B58\u300D\u624D\u751F\u6548\u3002",
|
|
23692
|
+
preview: "\u9884\u89C8",
|
|
23693
|
+
useIcons: "\u7528\u56FE\u6807\u5C55\u793A\u5FEB\u6377\u952E",
|
|
23694
|
+
useIconsDesc: "\u628A Ctrl/Shift/\u56DE\u8F66 \u7B49\u6309\u952E\u540D\u66FF\u6362\u4E3A\u82F9\u679C\u98CE\u683C\u7B26\u53F7\uFF08\u2303\u21E7\u23CE\uFF09\u3002",
|
|
23695
|
+
dragHandle: "\u62D6\u52A8\u6392\u5E8F",
|
|
23696
|
+
delete: "\u5220\u9664",
|
|
23697
|
+
labelPlaceholder: "\u663E\u793A\u6587\u5B57",
|
|
23698
|
+
payloadPlaceholder: "\u5E8F\u5217\uFF0C\u5982 \\x1b[A",
|
|
23699
|
+
addShortcut: "\u6DFB\u52A0\u5FEB\u6377\u952E",
|
|
23700
|
+
capturePrompt: "\u8BF7\u6309\u4E0B\u76EE\u6807\u7EC4\u5408\u952E\u2026\u2026",
|
|
23701
|
+
captureHint: "\u70B9\u6B64\uFF0C\u7136\u540E\u6309\u4E0B\u8981\u5F55\u5236\u7684\u6309\u952E",
|
|
23702
|
+
advanced: "\u9AD8\u7EA7\uFF1A\u624B\u52A8\u8F93\u5165\u5E8F\u5217",
|
|
23703
|
+
add: "\u6DFB\u52A0",
|
|
23704
|
+
reset: "\u91CD\u7F6E\u4E3A\u9ED8\u8BA4",
|
|
23705
|
+
save: "\u4FDD\u5B58",
|
|
23706
|
+
saved: "\u5FEB\u6377\u952E\u5DF2\u4FDD\u5B58",
|
|
23707
|
+
saveFailed: "\u4FDD\u5B58\u5FEB\u6377\u952E\u5931\u8D25",
|
|
23708
|
+
loading: "\u52A0\u8F7D\u4E2D\u2026\u2026",
|
|
23709
|
+
action: {
|
|
23710
|
+
paste: "\u7C98\u8D34",
|
|
23711
|
+
toggleKeyboard: "\u5207\u6362\u6587\u672C\u6846/\u952E\u76D8",
|
|
23712
|
+
newAgentSession: "\u65B0\u5EFA Agent \u4F1A\u8BDD",
|
|
23713
|
+
scrollToBottom: "\u7EC8\u7AEF\u56DE\u5230\u6700\u4E0B\u65B9"
|
|
23714
|
+
},
|
|
23715
|
+
loadFailed: "\u52A0\u8F7D\u5FEB\u6377\u952E\u5931\u8D25",
|
|
23716
|
+
retry: "\u91CD\u8BD5"
|
|
23717
|
+
}
|
|
23658
23718
|
},
|
|
23659
23719
|
deviceManagement: {
|
|
23660
23720
|
title: "\u8BBE\u5907\u7BA1\u7406",
|
|
@@ -23966,7 +24026,9 @@ Bot\uFF1A{{botName}}
|
|
|
23966
24026
|
upgradeNotAllowed: "\u5F53\u524D\u5B89\u88C5\u65B9\u5F0F\u4E0D\u652F\u6301\u7A0B\u5E8F\u5185\u66F4\u65B0\u3002",
|
|
23967
24027
|
upgradeInProgress: "\u5DF2\u6709\u5347\u7EA7\u4EFB\u52A1\u6B63\u5728\u8FDB\u884C\u3002",
|
|
23968
24028
|
upgradeVersionRequired: "\u7F3A\u5C11\u76EE\u6807\u7248\u672C\u53F7\u3002",
|
|
23969
|
-
updateCheckFailed: "\u67E5\u8BE2 npm registry \u5931\u8D25\u3002"
|
|
24029
|
+
updateCheckFailed: "\u67E5\u8BE2 npm registry \u5931\u8D25\u3002",
|
|
24030
|
+
terminalShortcutsTooMany: "\u5FEB\u6377\u952E\u6570\u91CF\u8FC7\u591A",
|
|
24031
|
+
terminalShortcutInvalid: "\u5FEB\u6377\u952E\u914D\u7F6E\u4E0D\u5408\u6CD5"
|
|
23970
24032
|
},
|
|
23971
24033
|
notification: {
|
|
23972
24034
|
clickToJump: "\u70B9\u51FB\u8DF3\u8F6C\u5230\u5BF9\u5E94 Pane",
|
|
@@ -24537,7 +24599,36 @@ Bot\uFF1A{{botName}}
|
|
|
24537
24599
|
lineHeight: "\u884C\u306E\u9AD8\u3055",
|
|
24538
24600
|
fontFamily: "\u30D5\u30A9\u30F3\u30C8",
|
|
24539
24601
|
preview: "\u30D7\u30EC\u30D3\u30E5\u30FC",
|
|
24540
|
-
savedInBrowser: "\u3053\u308C\u3089\u306E\u8A2D\u5B9A\u306F\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u306B\u306E\u307F\u4FDD\u5B58\u3055\u308C\u307E\u3059\u3002"
|
|
24602
|
+
savedInBrowser: "\u3053\u308C\u3089\u306E\u8A2D\u5B9A\u306F\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u306B\u306E\u307F\u4FDD\u5B58\u3055\u308C\u307E\u3059\u3002",
|
|
24603
|
+
shortcuts: {
|
|
24604
|
+
title: "\u30AB\u30B9\u30BF\u30E0\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8",
|
|
24605
|
+
savedOnServer: "\u30B5\u30FC\u30D0\u30FC\u306B\u4FDD\u5B58\u3055\u308C\u3001\u3059\u3079\u3066\u306E\u30D6\u30E9\u30A6\u30B6\u3067\u5171\u6709\u3055\u308C\u307E\u3059\u3002\u5909\u66F4\u306F\u300C\u4FDD\u5B58\u300D\u5F8C\u306B\u53CD\u6620\u3055\u308C\u307E\u3059\u3002",
|
|
24606
|
+
preview: "\u30D7\u30EC\u30D3\u30E5\u30FC",
|
|
24607
|
+
useIcons: "\u30AD\u30FC\u3092\u30A2\u30A4\u30B3\u30F3\u3067\u8868\u793A",
|
|
24608
|
+
useIconsDesc: "Ctrl/Shift/Enter \u306A\u3069\u306E\u30AD\u30FC\u540D\u3092 Apple \u98A8\u306E\u8A18\u53F7\uFF08\u2303\u21E7\u23CE\uFF09\u306B\u7F6E\u304D\u63DB\u3048\u307E\u3059\u3002",
|
|
24609
|
+
dragHandle: "\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u4E26\u3079\u66FF\u3048",
|
|
24610
|
+
delete: "\u524A\u9664",
|
|
24611
|
+
labelPlaceholder: "\u30E9\u30D9\u30EB",
|
|
24612
|
+
payloadPlaceholder: "\u30B7\u30FC\u30B1\u30F3\u30B9\uFF08\u4F8B: \\x1b[A\uFF09",
|
|
24613
|
+
addShortcut: "\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\u3092\u8FFD\u52A0",
|
|
24614
|
+
capturePrompt: "\u4EFB\u610F\u306E\u30AD\u30FC\u306E\u7D44\u307F\u5408\u308F\u305B\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044\u2026",
|
|
24615
|
+
captureHint: "\u3053\u3053\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30AD\u30FC\u3092\u62BC\u3059\u3068\u53D6\u5F97\u3057\u307E\u3059",
|
|
24616
|
+
advanced: "\u8A73\u7D30: \u30B7\u30FC\u30B1\u30F3\u30B9\u3092\u624B\u52D5\u5165\u529B",
|
|
24617
|
+
add: "\u8FFD\u52A0",
|
|
24618
|
+
reset: "\u30C7\u30D5\u30A9\u30EB\u30C8\u306B\u623B\u3059",
|
|
24619
|
+
save: "\u4FDD\u5B58",
|
|
24620
|
+
saved: "\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\u3092\u4FDD\u5B58\u3057\u307E\u3057\u305F",
|
|
24621
|
+
saveFailed: "\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\u306E\u4FDD\u5B58\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
24622
|
+
loading: "\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026",
|
|
24623
|
+
action: {
|
|
24624
|
+
paste: "\u8CBC\u308A\u4ED8\u3051",
|
|
24625
|
+
toggleKeyboard: "\u30C6\u30AD\u30B9\u30C8\u5165\u529B/\u30AD\u30FC\u30DC\u30FC\u30C9\u5207\u66FF",
|
|
24626
|
+
newAgentSession: "\u65B0\u3057\u3044 Agent \u30BB\u30C3\u30B7\u30E7\u30F3",
|
|
24627
|
+
scrollToBottom: "\u30BF\u30FC\u30DF\u30CA\u30EB\u3092\u6700\u4E0B\u90E8\u3078"
|
|
24628
|
+
},
|
|
24629
|
+
loadFailed: "\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
24630
|
+
retry: "\u518D\u8A66\u884C"
|
|
24631
|
+
}
|
|
24541
24632
|
},
|
|
24542
24633
|
deviceManagement: {
|
|
24543
24634
|
title: "\u30C7\u30D0\u30A4\u30B9\u7BA1\u7406",
|
|
@@ -24849,7 +24940,9 @@ Bot\uFF1A{{botName}}
|
|
|
24849
24940
|
upgradeNotAllowed: "\u3053\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3067\u306F\u30A2\u30D7\u30EA\u5185\u66F4\u65B0\u3092\u5229\u7528\u3067\u304D\u307E\u305B\u3093\u3002",
|
|
24850
24941
|
upgradeInProgress: "\u3059\u3067\u306B\u66F4\u65B0\u304C\u9032\u884C\u4E2D\u3067\u3059\u3002",
|
|
24851
24942
|
upgradeVersionRequired: "\u5BFE\u8C61\u30D0\u30FC\u30B8\u30E7\u30F3\u304C\u5FC5\u8981\u3067\u3059\u3002",
|
|
24852
|
-
updateCheckFailed: "npm registry \u306E\u7167\u4F1A\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002"
|
|
24943
|
+
updateCheckFailed: "npm registry \u306E\u7167\u4F1A\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002",
|
|
24944
|
+
terminalShortcutsTooMany: "\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\u304C\u591A\u3059\u304E\u307E\u3059",
|
|
24945
|
+
terminalShortcutInvalid: "\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\u8A2D\u5B9A\u304C\u4E0D\u6B63\u3067\u3059"
|
|
24853
24946
|
},
|
|
24854
24947
|
notification: {
|
|
24855
24948
|
clickToJump: "\u5BFE\u5FDC\u3059\u308B\u30DA\u30A4\u30F3\u306B\u30B8\u30E3\u30F3\u30D7",
|
|
@@ -26329,6 +26422,26 @@ function decodePaneWire(wire) {
|
|
|
26329
26422
|
};
|
|
26330
26423
|
}
|
|
26331
26424
|
// ../shared/src/index.ts
|
|
26425
|
+
var TERMINAL_SHORTCUT_ACTIONS = [
|
|
26426
|
+
"paste",
|
|
26427
|
+
"toggleKeyboard",
|
|
26428
|
+
"newAgentSession",
|
|
26429
|
+
"scrollToBottom"
|
|
26430
|
+
];
|
|
26431
|
+
var DEFAULT_TERMINAL_SHORTCUTS = [
|
|
26432
|
+
{ id: "paste", type: "action", action: "paste", label: "" },
|
|
26433
|
+
{ id: "enter", type: "send", label: "Enter", payload: "\r" },
|
|
26434
|
+
{ id: "shift-tab", type: "send", label: "SHIFT-TAB", payload: "\x1B[Z" },
|
|
26435
|
+
{ id: "esc", type: "send", label: "ESC", payload: "\x1B" },
|
|
26436
|
+
{ id: "ctrl-c", type: "send", label: "CTRL-C", payload: "\x03" },
|
|
26437
|
+
{ id: "ctrl-d", type: "send", label: "CTRL-D", payload: "\x04" },
|
|
26438
|
+
{ id: "arrow-up", type: "send", label: "\u2191", payload: "\x1B[A" },
|
|
26439
|
+
{ id: "arrow-down", type: "send", label: "\u2193", payload: "\x1B[B" },
|
|
26440
|
+
{ id: "arrow-left", type: "send", label: "\u2190", payload: "\x1B[D" },
|
|
26441
|
+
{ id: "arrow-right", type: "send", label: "\u2192", payload: "\x1B[C" },
|
|
26442
|
+
{ id: "shift-enter", type: "send", label: "SHIFT-Enter", payload: "\x1B[13;2u" },
|
|
26443
|
+
{ id: "backspace", type: "send", label: "Backspace", payload: "\b" }
|
|
26444
|
+
];
|
|
26332
26445
|
var DEFAULT_AGENT_SESSION_TITLE = "New Session";
|
|
26333
26446
|
|
|
26334
26447
|
// ../../node_modules/.bun/drizzle-orm@0.45.1+d3720f6f296df04b/node_modules/drizzle-orm/entity.js
|
|
@@ -32745,6 +32858,7 @@ __export(exports_schema2, {
|
|
|
32745
32858
|
webhookEndpoints: () => webhookEndpoints,
|
|
32746
32859
|
watchRules: () => watchRules,
|
|
32747
32860
|
watchRuleState: () => watchRuleState,
|
|
32861
|
+
terminalShortcutSettings: () => terminalShortcutSettings,
|
|
32748
32862
|
telegramBots: () => telegramBots,
|
|
32749
32863
|
telegramBotChats: () => telegramBotChats,
|
|
32750
32864
|
siteSettings: () => siteSettings,
|
|
@@ -32778,6 +32892,12 @@ var siteSettings = sqliteTable("site_settings", {
|
|
|
32778
32892
|
language: text("language").notNull().default("en_US"),
|
|
32779
32893
|
updatedAt: text("updated_at").notNull()
|
|
32780
32894
|
}, (table) => [check("site_settings_singleton_check", sql`${table.id} = 1`)]);
|
|
32895
|
+
var terminalShortcutSettings = sqliteTable("terminal_shortcut_settings", {
|
|
32896
|
+
id: integer("id").primaryKey(),
|
|
32897
|
+
items: text("items", { mode: "json" }).$type().notNull().default(DEFAULT_TERMINAL_SHORTCUTS),
|
|
32898
|
+
useIcons: integer("use_icons", { mode: "boolean" }).notNull().default(false),
|
|
32899
|
+
updatedAt: text("updated_at").notNull()
|
|
32900
|
+
}, (table) => [check("terminal_shortcut_settings_singleton_check", sql`${table.id} = 1`)]);
|
|
32781
32901
|
var devices = sqliteTable("devices", {
|
|
32782
32902
|
id: text("id").primaryKey(),
|
|
32783
32903
|
name: text("name").notNull(),
|
|
@@ -33307,6 +33427,49 @@ function updateSiteSettings(updates) {
|
|
|
33307
33427
|
}
|
|
33308
33428
|
return next;
|
|
33309
33429
|
}
|
|
33430
|
+
function toTerminalShortcutSettings(row) {
|
|
33431
|
+
return {
|
|
33432
|
+
items: Array.isArray(row.items) ? row.items : DEFAULT_TERMINAL_SHORTCUTS,
|
|
33433
|
+
useIcons: row.useIcons,
|
|
33434
|
+
updatedAt: row.updatedAt
|
|
33435
|
+
};
|
|
33436
|
+
}
|
|
33437
|
+
function ensureTerminalShortcutSettingsInitialized() {
|
|
33438
|
+
const orm = getDb();
|
|
33439
|
+
orm.insert(terminalShortcutSettings).values({
|
|
33440
|
+
id: 1,
|
|
33441
|
+
items: DEFAULT_TERMINAL_SHORTCUTS,
|
|
33442
|
+
useIcons: false,
|
|
33443
|
+
updatedAt: new Date().toISOString()
|
|
33444
|
+
}).onConflictDoNothing({ target: terminalShortcutSettings.id }).run();
|
|
33445
|
+
}
|
|
33446
|
+
function getTerminalShortcutSettings() {
|
|
33447
|
+
const orm = getDb();
|
|
33448
|
+
let row = orm.select().from(terminalShortcutSettings).where(eq(terminalShortcutSettings.id, 1)).get();
|
|
33449
|
+
if (!row) {
|
|
33450
|
+
ensureTerminalShortcutSettingsInitialized();
|
|
33451
|
+
row = orm.select().from(terminalShortcutSettings).where(eq(terminalShortcutSettings.id, 1)).get();
|
|
33452
|
+
}
|
|
33453
|
+
if (!row) {
|
|
33454
|
+
throw new Error("terminal_shortcut_settings not initialized");
|
|
33455
|
+
}
|
|
33456
|
+
return toTerminalShortcutSettings(row);
|
|
33457
|
+
}
|
|
33458
|
+
function updateTerminalShortcutSettings(updates) {
|
|
33459
|
+
ensureTerminalShortcutSettingsInitialized();
|
|
33460
|
+
const next = {
|
|
33461
|
+
items: updates.items,
|
|
33462
|
+
useIcons: updates.useIcons,
|
|
33463
|
+
updatedAt: new Date().toISOString()
|
|
33464
|
+
};
|
|
33465
|
+
const orm = getDb();
|
|
33466
|
+
orm.update(terminalShortcutSettings).set({
|
|
33467
|
+
items: next.items,
|
|
33468
|
+
useIcons: next.useIcons,
|
|
33469
|
+
updatedAt: next.updatedAt
|
|
33470
|
+
}).where(eq(terminalShortcutSettings.id, 1)).run();
|
|
33471
|
+
return next;
|
|
33472
|
+
}
|
|
33310
33473
|
function createWebhookEndpoint(endpoint) {
|
|
33311
33474
|
const orm = getDb();
|
|
33312
33475
|
orm.insert(webhookEndpoints).values({
|
|
@@ -104910,8 +105073,8 @@ function getBaseVersion() {
|
|
|
104910
105073
|
if (cachedBase !== undefined)
|
|
104911
105074
|
return cachedBase;
|
|
104912
105075
|
let base = null;
|
|
104913
|
-
if ("0.12.
|
|
104914
|
-
base = "0.12.
|
|
105076
|
+
if ("0.12.3") {
|
|
105077
|
+
base = "0.12.3";
|
|
104915
105078
|
}
|
|
104916
105079
|
if (!base && config.isProd) {
|
|
104917
105080
|
base = readInstallMeta()?.cliVersion ?? null;
|
|
@@ -105171,6 +105334,57 @@ async function handleStartUpgrade(req) {
|
|
|
105171
105334
|
return json6(upgradeController.status());
|
|
105172
105335
|
}
|
|
105173
105336
|
|
|
105337
|
+
// ../../apps/gateway/src/api/terminal-shortcuts.ts
|
|
105338
|
+
var MAX_TERMINAL_SHORTCUTS = 50;
|
|
105339
|
+
var MAX_TERMINAL_SHORTCUT_LABEL_LEN = 32;
|
|
105340
|
+
var MAX_TERMINAL_SHORTCUT_PAYLOAD_LEN = 256;
|
|
105341
|
+
function normalizeTerminalShortcutsInput(body) {
|
|
105342
|
+
if (typeof body !== "object" || body === null) {
|
|
105343
|
+
throw new Error(t2("apiError.invalidRequest"));
|
|
105344
|
+
}
|
|
105345
|
+
if (typeof body.useIcons !== "boolean") {
|
|
105346
|
+
throw new Error(t2("apiError.invalidRequest"));
|
|
105347
|
+
}
|
|
105348
|
+
if (!Array.isArray(body.items)) {
|
|
105349
|
+
throw new Error(t2("apiError.invalidRequest"));
|
|
105350
|
+
}
|
|
105351
|
+
if (body.items.length > MAX_TERMINAL_SHORTCUTS) {
|
|
105352
|
+
throw new Error(t2("apiError.terminalShortcutsTooMany"));
|
|
105353
|
+
}
|
|
105354
|
+
const seenIds = new Set;
|
|
105355
|
+
const items = body.items.map((raw) => {
|
|
105356
|
+
if (typeof raw !== "object" || raw === null) {
|
|
105357
|
+
throw new Error(t2("apiError.terminalShortcutInvalid"));
|
|
105358
|
+
}
|
|
105359
|
+
const item = raw;
|
|
105360
|
+
const id = typeof item.id === "string" ? item.id.trim() : "";
|
|
105361
|
+
if (!id || seenIds.has(id)) {
|
|
105362
|
+
throw new Error(t2("apiError.terminalShortcutInvalid"));
|
|
105363
|
+
}
|
|
105364
|
+
seenIds.add(id);
|
|
105365
|
+
const label = typeof item.label === "string" ? item.label : "";
|
|
105366
|
+
if (label.length > MAX_TERMINAL_SHORTCUT_LABEL_LEN) {
|
|
105367
|
+
throw new Error(t2("apiError.terminalShortcutInvalid"));
|
|
105368
|
+
}
|
|
105369
|
+
if (item.type === "send") {
|
|
105370
|
+
const payload = typeof item.payload === "string" ? item.payload : "";
|
|
105371
|
+
if (!payload || payload.length > MAX_TERMINAL_SHORTCUT_PAYLOAD_LEN) {
|
|
105372
|
+
throw new Error(t2("apiError.terminalShortcutInvalid"));
|
|
105373
|
+
}
|
|
105374
|
+
return { id, type: "send", label, payload };
|
|
105375
|
+
}
|
|
105376
|
+
if (item.type === "action") {
|
|
105377
|
+
const action = item.action;
|
|
105378
|
+
if (!action || !TERMINAL_SHORTCUT_ACTIONS.includes(action)) {
|
|
105379
|
+
throw new Error(t2("apiError.terminalShortcutInvalid"));
|
|
105380
|
+
}
|
|
105381
|
+
return { id, type: "action", label, action };
|
|
105382
|
+
}
|
|
105383
|
+
throw new Error(t2("apiError.terminalShortcutInvalid"));
|
|
105384
|
+
});
|
|
105385
|
+
return { items, useIcons: body.useIcons };
|
|
105386
|
+
}
|
|
105387
|
+
|
|
105174
105388
|
// ../../apps/gateway/src/api/test-connection.ts
|
|
105175
105389
|
function inferFailurePhase(errorType) {
|
|
105176
105390
|
if (errorType === "tmux_unavailable") {
|
|
@@ -106709,6 +106923,12 @@ function handleApiRequest(req, _server) {
|
|
|
106709
106923
|
if (path === "/api/settings/site" && req.method === "PATCH") {
|
|
106710
106924
|
return handleUpdateSiteSettings(req);
|
|
106711
106925
|
}
|
|
106926
|
+
if (path === "/api/settings/terminal-shortcuts" && req.method === "GET") {
|
|
106927
|
+
return handleGetTerminalShortcuts();
|
|
106928
|
+
}
|
|
106929
|
+
if (path === "/api/settings/terminal-shortcuts" && req.method === "PATCH") {
|
|
106930
|
+
return handleUpdateTerminalShortcuts(req);
|
|
106931
|
+
}
|
|
106712
106932
|
if (path === "/api/settings/restart" && req.method === "POST") {
|
|
106713
106933
|
return handleRestartGateway();
|
|
106714
106934
|
}
|
|
@@ -106906,6 +107126,19 @@ async function handleUpdateSiteSettings(req) {
|
|
|
106906
107126
|
return json9({ error: err instanceof Error ? err.message : t2("apiError.invalidRequest") }, 400);
|
|
106907
107127
|
}
|
|
106908
107128
|
}
|
|
107129
|
+
async function handleGetTerminalShortcuts() {
|
|
107130
|
+
return json9({ settings: getTerminalShortcutSettings() });
|
|
107131
|
+
}
|
|
107132
|
+
async function handleUpdateTerminalShortcuts(req) {
|
|
107133
|
+
try {
|
|
107134
|
+
const body = await req.json();
|
|
107135
|
+
const updates = normalizeTerminalShortcutsInput(body);
|
|
107136
|
+
const settings = updateTerminalShortcutSettings(updates);
|
|
107137
|
+
return json9({ settings });
|
|
107138
|
+
} catch (err) {
|
|
107139
|
+
return json9({ error: err instanceof Error ? err.message : t2("apiError.invalidRequest") }, 400);
|
|
107140
|
+
}
|
|
107141
|
+
}
|
|
106909
107142
|
async function handleRestartGateway() {
|
|
106910
107143
|
setTimeout(() => {
|
|
106911
107144
|
runtimeController.requestRestart();
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{_ as We,u as Re,j as o,$ as Ge,a0 as Ve,a1 as Qe,a2 as Je,a3 as Ze,a4 as et,a5 as tt,r,d as K,a6 as ee,a7 as He,a8 as $e,a9 as nt,aa as rt,ab as st,ac as ze,ad as ot,o as he,ae as it,af as Pe,ag as ct,b as Oe,ah as Le,ai as at,c as _e,aj as qe,ak as xe,al as lt,am as ut,an as ke,ao as dt,B as de,T as ft,ap as De,aq as mt,ar as ht,as as wt,A as pt,f as xt,g as vt,i as gt,k as St,l as bt,m as Et,n as Tt,at as Rt,au as yt}from"./index-FNpsxYPN.js";import{T as It,C as Ct,c as jt,F as Nt,a as Ue,R as Mt,A as kt,S as At,f as Pt,t as Lt}from"./terminal-settings-panel-DLuBkEEZ.js";/**
|
|
2
|
+
* @license lucide-react v0.564.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const _t=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],zt=We("settings-2",_t);/**
|
|
7
|
+
* @license lucide-react v0.564.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Dt=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ft=We("smartphone",Dt);function Bt({open:n,onOpenChange:e}){const{t:i}=Re();return o.jsx(Ge,{open:n,onOpenChange:e,children:o.jsxs(Ve,{side:"bottom",className:"max-h-[88dvh] overflow-y-auto pb-[var(--tmex-safe-area-bottom)] sm:mx-auto sm:max-w-md sm:rounded-t-2xl sm:border sm:border-b-0","data-testid":"keyboard-behavior-sheet",children:[o.jsxs(Qe,{children:[o.jsx(Je,{children:i("settings.terminal.title")}),o.jsx(Ze,{children:i("settings.terminal.savedInBrowser")})]}),o.jsx("div",{className:"px-4 pb-4",children:o.jsx(It,{})})]})})}function Wt({visible:n,canPaste:e,onCopy:i,onPaste:c,onDismiss:p}){const{t:R}=Re();if(!n)return null;const N=v=>{v.preventDefault()};return o.jsxs("div",{className:"absolute top-2 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-md backdrop-blur","data-testid":"terminal-selection-toolbar",children:[o.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:N,onClick:i,"data-testid":"terminal-selection-copy",children:[o.jsx(et,{className:"h-4 w-4"}),R("terminal.copy")]}),e&&o.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:N,onClick:c,"data-testid":"terminal-selection-paste",children:[o.jsx(Ct,{className:"h-4 w-4"}),R("terminal.paste")]}),o.jsx("button",{type:"button",className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground",onMouseDown:N,onClick:p,"aria-label":R("terminal.clearSelection"),"data-testid":"terminal-selection-dismiss",children:o.jsx(tt,{className:"h-4 w-4"})})]})}function Ye(n){if(!n)return n;const e=n.replace(/\r\n/g,`
|
|
12
|
+
`);return(e.endsWith(`
|
|
13
|
+
`)?e.slice(0,-1):e).replace(/\n/g,`\r
|
|
14
|
+
`)}const Ht="\x1B[?1049h\x1B[H\x1B[2J";function $t(n){return Ht+Ye(n)}function Fe(n,e){let i=e,c=0;for(const v of n)v===10&&!i&&(c+=1),i=v===13;const p=i;if(c===0)return{normalized:n,endedWithCR:p};const R=new Uint8Array(n.length+c);let N=0;i=e;for(const v of n)v===10&&!i&&(R[N]=13,N+=1),R[N]=v,N+=1,i=v===13;return{normalized:R,endedWithCR:p}}const Ot=1.3,qt=36,Ut=500,Yt=12;function Xt(n,e){const i=r.useRef(!1);return r.useEffect(()=>{const c=n.current;if(!c||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;i.current=!0;let R=0,N=null,v=!1,E=0,G=0,s=0,C=null,F=!1;const V=()=>{C!==null&&(clearTimeout(C),C=null)},O=w=>w?!!(w.closest(".scrollbar")||w.closest(".slider")||w.closest(".xterm-scroll-area")):!1,S=(w,m,b)=>{const M=b instanceof Element?b:null;if(O(M))return!0;const $=document.elementFromPoint(w,m);if(O($))return!0;const h=c.querySelector(".xterm");if(!(h instanceof HTMLElement))return!1;const g=h.getBoundingClientRect(),L=w>=g.left&&w<=g.right,_=m>=g.top&&m<=g.bottom;return!L||!_?!1:w>=g.right-qt},Q=()=>[c.querySelector(".xterm-viewport"),c.querySelector(".xterm-scrollable-element")].filter(m=>m instanceof HTMLElement),f=w=>{if(N===null)return null;for(let m=0;m<w.length;m+=1){const b=w.item(m);if(b&&b.identifier===N)return b}return null},P=w=>{if(V(),w.touches.length!==1)return;const m=w.touches.item(0);m&&(N=m.identifier,R=m.clientY,E=0,v=S(m.clientX,m.clientY,w.target),G=m.clientX,s=m.clientY,F=!1,v||(C=setTimeout(()=>{var M;C=null;const b=(e==null?void 0:e())??null;(M=b==null?void 0:b.startTouchSelection)!=null&&M.call(b,G,s,"word")&&(F=!0)},Ut)))},B=w=>{var L,_,T,q,U,X,se,y,ne;const m=f(w.touches)??w.touches.item(0);if(!m)return;if(F){const A=(e==null?void 0:e())??null;(L=A==null?void 0:A.updateTouchSelection)==null||L.call(A,m.clientX,m.clientY),w.cancelable&&w.preventDefault();return}if(C!==null&&Math.hypot(m.clientX-G,m.clientY-s)>Yt&&V(),v||(v=S(m.clientX,m.clientY,w.target),v&&(E=0)),v)return;const b=m.clientY,M=R-b;if(R=b,M===0)return;let $=!1,h=!1;const g=(e==null?void 0:e())??null;if(g){const A=g==null?void 0:g._core,k=((U=(q=(T=(_=A==null?void 0:A._renderService)==null?void 0:_.dimensions)==null?void 0:T.css)==null?void 0:q.cell)==null?void 0:U.height)??18;E+=M*Ot;const j=E>0?Math.floor(E/k):Math.ceil(E/k);if(typeof g.handleViewportGesture=="function")j!==0&&($=g.handleViewportGesture({source:"touch",deltaY:j*k,clientX:m.clientX,clientY:m.clientY}),E-=j*k);else if(j!==0){const D=((se=(X=g.buffer)==null?void 0:X.active)==null?void 0:se.viewportY)??0;g.scrollLines(j);const re=((ne=(y=g.buffer)==null?void 0:y.active)==null?void 0:ne.viewportY)??0;$=D!==re,h=j<0&&D<=0&&re<=0,E-=j*k}}else{const A=Q();if(A.length===0)return;for(const k of A){const j=k.scrollTop;k.scrollTop+=M;const D=k.scrollTop;Math.abs(D-j)>0&&($=!0),M<0&&D<=0&&(h=!0)}if(!$){const k=c.querySelector(".xterm");if(k instanceof HTMLElement){const j=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:M}),D=k.dispatchEvent(j);$=j.defaultPrevented||!D}}}w.cancelable&&($||h)&&w.preventDefault()},z=w=>{var b;if(V(),!(N===null||!f(w.changedTouches))&&(N=null,E=0,v=!1,F)){F=!1;const M=(e==null?void 0:e())??null;(b=M==null?void 0:M.endTouchSelection)==null||b.call(M)}},H=w=>{F&&w.preventDefault()};return c.addEventListener("touchstart",P,{passive:!0}),c.addEventListener("touchmove",B,{passive:!1}),c.addEventListener("touchend",z,{passive:!0}),c.addEventListener("touchcancel",z,{passive:!0}),c.addEventListener("contextmenu",H),()=>{i.current=!1,V(),c.removeEventListener("touchstart",P),c.removeEventListener("touchmove",B),c.removeEventListener("touchend",z),c.removeEventListener("touchcancel",z),c.removeEventListener("contextmenu",H)}},[n,e]),i}function Kt({now:n,remoteSize:e,pendingLocalSize:i,ttlMs:c=2e3}){return!i||n-i.at>c?!0:i.cols===e.cols&&i.rows===e.rows}function Gt({currentSize:n,containerSize:e,force:i=!1}){return i?!0:n.cols!==e.cols||n.rows!==e.rows}function Vt({deviceId:n,paneId:e,deviceConnected:i,isSelectionInvalid:c,onResize:p,onSync:R,getContainerRect:N}){const v=r.useRef(null),E=r.useRef(null),G=r.useRef(null),s=r.useRef(null),C=r.useRef(0),F=r.useRef([]),V=r.useRef(null),O=r.useRef(null),S=r.useRef(N),Q=r.useRef(!1),f=r.useRef(p),P=r.useRef(R);r.useEffect(()=>{f.current=p},[p]),r.useEffect(()=>{P.current=R},[R]),r.useEffect(()=>{S.current=N},[N]);const B=r.useCallback(()=>{var X,se,y,ne,A,k,j,D,re,ve;const h=O.current,g=V.current;if(!h||!g||!h.element)return null;let L;try{const ae=g.proposeDimensions();if(!ae)throw new Error("fitAddon.proposeDimensions() returned null");L=Math.max(2,ae.cols)}catch{const ae=h._core,ye=((ne=(y=(se=(X=ae==null?void 0:ae._renderService)==null?void 0:X.dimensions)==null?void 0:se.css)==null?void 0:y.cell)==null?void 0:ne.width)??9,a=(A=S.current)==null?void 0:A.call(S);if(!a||a.width===0)return null;L=Math.max(2,Math.floor(a.width/ye))}const _=(k=S.current)==null?void 0:k.call(S);if(!_||_.height===0)return null;const T=h._core,q=((ve=(re=(D=(j=T==null?void 0:T._renderService)==null?void 0:j.dimensions)==null?void 0:D.css)==null?void 0:re.cell)==null?void 0:ve.height)??17,U=Math.max(2,Math.floor(_.height/q));return{cols:L,rows:U}},[]),z=r.useCallback((h,g)=>{const L=O.current;L&&(L.cols===h&&L.rows===g||L.resize(h,g))},[]),H=r.useCallback((h,g=!1)=>{if(!n||!e||!i||c&&h!=="sync"||!g&&Date.now()<C.current||!O.current)return!1;const _=B();if(!_)return!1;const{cols:T,rows:q}=_,U=G.current;return!g&&U&&U.cols===T&&U.rows===q?(z(T,q),!0):(z(T,q),h==="sync"?P.current(T,q):f.current(T,q),G.current={cols:T,rows:q},s.current={cols:T,rows:q,at:Date.now()},!0)},[z,i,n,c,B,e]),w=r.useCallback((h="resize",g={})=>{const{immediate:L=!1,force:_=!1}=g;E.current!==null&&(window.clearTimeout(E.current),E.current=null),v.current!==null&&(cancelAnimationFrame(v.current),v.current=null);const T=()=>{v.current=requestAnimationFrame(()=>{v.current=null,H(h,_)})};if(L){T();return}E.current=window.setTimeout(()=>{E.current=null,T()},150)},[H]),m=r.useCallback(()=>{for(const h of F.current)window.clearTimeout(h);F.current=[]},[]),b=r.useCallback(()=>{var g;m(),w("sync",{immediate:!0,force:!0});const h=window.setTimeout(()=>{w("sync",{immediate:!0,force:!0})},60);F.current.push(h),typeof document<"u"&&"fonts"in document&&((g=document.fonts)!=null&&g.ready)&&document.fonts.ready.then(()=>{w("sync",{immediate:!0,force:!0})}).catch(()=>{})},[m,w]);r.useEffect(()=>{let h=null;const g=()=>{h!==null&&cancelAnimationFrame(h),h=requestAnimationFrame(()=>{h=null,w("resize")})};return window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g),h!==null&&cancelAnimationFrame(h)}},[w]),r.useEffect(()=>{const h=()=>{var X;const T=O.current,q=B();if(!T||!q)return;if(!Gt({currentSize:{cols:Math.max(2,T.cols),rows:Math.max(2,T.rows)},containerSize:q})){(X=T.refresh)==null||X.call(T);return}w("sync",{force:!0})},g=()=>{if(document.visibilityState!=="visible"){Q.current=!0;return}Q.current&&(Q.current=!1,h())},L=()=>{Q.current=!0},_=()=>{Q.current&&(Q.current=!1,h())};return document.addEventListener("visibilitychange",g),window.addEventListener("blur",L),window.addEventListener("focus",_),()=>{document.removeEventListener("visibilitychange",g),window.removeEventListener("blur",L),window.removeEventListener("focus",_)}},[B,w]),r.useEffect(()=>()=>{m(),E.current!==null&&window.clearTimeout(E.current),v.current!==null&&cancelAnimationFrame(v.current)},[m]);const M=r.useCallback(h=>{V.current=h},[]),$=r.useCallback(h=>{O.current=h},[]);return{scheduleResize:w,runPostSelectResize:b,clearPostSelectResizeTimers:m,setFitAddon:M,setTerminal:$,lastReportedSize:G,pendingLocalSize:s,suppressLocalResizeUntil:C}}const Qt=1e4,Ae="tmex:terminal-mode-cache";function Jt(n,e){try{const i=sessionStorage.getItem(Ae);return i?JSON.parse(i)[`${n}:${e}`]??null:null}catch{return null}}function Zt(n,e,i){try{const c=sessionStorage.getItem(Ae),p=c?JSON.parse(c):{},R=`${n}:${e}`;i?p[R]=i:delete p[R],sessionStorage.setItem(Ae,JSON.stringify(p))}catch{}}function en(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function tn(n,e){if(!e)return n?{...n,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const i=en();if(!n)return i;const c=n.mouseNormal||n.mouseButton||n.mouseAny;return{...n,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:c?n.mouseNormal:i.mouseNormal}}function nn(n){var i;const e=globalThis;e.__tmexE2eXterm=n,e.__tmexE2eTerminal=n,e.__tmexE2eTerminalEngine=Ue,e.__tmexE2eTerminalRenderer=((i=n.getRendererKind)==null?void 0:i.call(n))??null}function rn(n){if(!n)return;const e=globalThis;e.__tmexE2eTerminal!==n&&e.__tmexE2eXterm!==n||(e.__tmexE2eXterm=null,e.__tmexE2eTerminal=null,e.__tmexE2eTerminalEngine=null,e.__tmexE2eTerminalRenderer=null,e.__tmexE2eTerminalSelectionText=null)}const Xe=r.forwardRef(({deviceId:n,paneId:e,theme:i,inputMode:c,deviceConnected:p,isSelectionInvalid:R,onResize:N,onSync:v,children:E},G)=>{const[s,C]=r.useState(null),[F,V]=r.useState(!1),O=K(a=>a.sendInput),S=ee(a=>a.terminalFontId),Q=ee(a=>a.terminalFontSize),f=ee(a=>a.terminalLineHeight),{t:P}=Re(),B=r.useMemo(()=>{switch(i){case"light":return $e;default:return He}},[i]),z=r.useRef(null),H=r.useRef(null),w=r.useRef(null),m=r.useRef(n),b=r.useRef(e),M=r.useRef(n),$=r.useRef(e),h=r.useRef(p&&!R),g=r.useRef(c),L=r.useRef(B),_=r.useRef(!1),T=r.useRef(!1),q=r.useRef(null),U=r.useRef(!1),X=r.useCallback((a,l,I)=>{!(a!=null&&a.exportModeSnapshot)||!l||!I||Zt(l,I,a.exportModeSnapshot())},[]),se=r.useCallback(()=>s,[s]);Xt(z,se),r.useEffect(()=>{m.current=n,b.current=e,T.current=!1},[n,e]),r.useEffect(()=>{h.current=p&&!R},[p,R]),r.useEffect(()=>{g.current=c},[c]),r.useEffect(()=>{L.current=B},[B]);const y=r.useCallback(a=>{if(!a||c!=="direct"||!h.current)return;const l=m.current,I=b.current;!l||!I||O(l,I,a,!1)},[c,O]),{pendingLocalSize:ne,scheduleResize:A,runPostSelectResize:k,setFitAddon:j,setTerminal:D}=Vt({deviceId:n,paneId:e,deviceConnected:p,isSelectionInvalid:R,onResize:N,onSync:v,getContainerRect:()=>{const a=z.current;if(!a)return null;const l=a.getBoundingClientRect();return{width:l.width,height:l.height}}});r.useEffect(()=>{let a=!1,l=null;return(async()=>{if(await nt(S,Q),a)return;const I=await jt({fontFamily:rt(S),fontSize:Q,lineHeight:f,scrollback:Qt,theme:L.current,disableStdin:g.current==="editor"});if(a){I.dispose();return}l=I,H.current&&I.open(H.current),nn(I),C(I)})(),()=>{a=!0,C(null),rn(l),l==null||l.dispose()}},[S,Q,f]),r.useEffect(()=>{!s||!("setTheme"in s)||s.setTheme(B)},[s,B]),r.useEffect(()=>{!s||!("setDisableStdin"in s)||s.setDisableStdin(c==="editor")},[s,c]),r.useEffect(()=>{if(!(s!=null&&s.getCursorViewportRect))return;const a=()=>{var l;return((l=s.getCursorViewportRect)==null?void 0:l.call(s))??null};return it(a),()=>st(a)},[s]),r.useEffect(()=>{!s||c!=="direct"||window.innerWidth<768||"ontouchstart"in window||s.focus()},[s,c]);const re=r.useMemo(()=>s?{onResetTerminal:a=>{m.current===a&&(X(s,M.current,$.current),U.current=!0,s.reset(),_.current=!1,k())},onApplyHistory:(a,l,I)=>{var oe;if(m.current!==a)return;const W=tn(Jt(m.current,b.current),I);W&&((oe=s.restoreModeSnapshot)==null||oe.call(s,W));const Z=I?$t(l):Ye(l);T.current=!0,s.write(Z),U.current=!1,M.current=m.current,$.current=b.current,X(s,m.current,b.current)},onFlushBuffer:(a,l)=>{if(m.current===a){for(const I of l){const W=Fe(I,_.current);_.current=W.endedWithCR,s.write(W.normalized)}T.current&&(s.buffer.active.baseY<=1&&s.scrollToTop(),T.current=!1),M.current=m.current,$.current=b.current,X(s,m.current,b.current)}},onOutput:(a,l,I)=>{if(m.current!==a||b.current!==l)return;const W=Fe(I,_.current);_.current=W.endedWithCR,s.write(W.normalized),T.current&&(s.buffer.active.baseY<=1&&s.scrollToTop(),T.current=!1),M.current=m.current,$.current=b.current,X(s,m.current,b.current)}}:{},[s,X,k]);r.useEffect(()=>{s?q.current!==s&&(_.current=!1,M.current=m.current,$.current=b.current,q.current=s):q.current=null},[s]),r.useEffect(()=>{if(!(!s||!n||!e))return()=>{if(U.current){U.current=!1;return}X(s,M.current,$.current)}},[n,s,e,X]),r.useEffect(()=>{ze(re)},[re]),r.useEffect(()=>()=>{ze({})},[]),r.useEffect(()=>{if(!s){w.current=null,j(null),D(null);return}const a=new Nt;return s.loadAddon(a),w.current=a,j(a),D(s),k(),()=>{try{a.dispose()}finally{w.current=null,j(null),D(null)}}},[s,k,j,D]),r.useEffect(()=>{const a=z.current;if(!a)return;let l=null;const I=new ResizeObserver(()=>{l!==null&&cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=null,A("resize")})});return I.observe(a),()=>{I.disconnect(),l!==null&&cancelAnimationFrame(l)}},[A]),r.useEffect(()=>{if(!s||!n||!e)return;const a=s.onData(l=>{!p||R||y(l)});return s.attachCustomKeyEventHandler(l=>!p||R||l.type!=="keydown"||c!=="direct"?!0:l.shiftKey&&l.key==="Enter"?(l.preventDefault(),y("\x1B[13;2u"),!1):!0),()=>{a.dispose(),s.attachCustomKeyEventHandler(()=>!0)}},[s,p,R,c,y,n,e]),r.useEffect(()=>{if(!(s!=null&&s.onLinkActivated))return;const a=s.onLinkActivated(l=>{window.open(l,"_blank","noopener,noreferrer")});return()=>a.dispose()},[s]),r.useEffect(()=>{if(!(s!=null&&s.onSelectionChange)){V(!1);return}const a=s.onSelectionChange(l=>{V(!!l)});return()=>{a.dispose(),V(!1)}},[s]);const ve=r.useCallback(()=>{var l;if(!s)return;const a=((l=s.getSelection)==null?void 0:l.call(s))??"";a&&ot(a).then(()=>{he.success(P("terminal.copied"))}).catch(()=>{he.error(P("terminal.copyFailed"))}).finally(()=>{var I;(I=s.clearSelection)==null||I.call(s),s.focus()})},[s,P]),ae=r.useCallback(()=>{var l;if(!s)return;((l=navigator.clipboard)!=null&&l.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(I=>{var W;I&&s.paste(I),(W=s.clearSelection)==null||W.call(s),s.focus()}).catch(()=>{he.error(P("terminal.pasteFailed"))})},[s,P]),ye=r.useCallback(()=>{var a;(a=s==null?void 0:s.clearSelection)==null||a.call(s),s==null||s.focus()},[s]);return r.useImperativeHandle(G,()=>({write:a=>s==null?void 0:s.write(a),reset:()=>{s==null||s.reset(),_.current=!1},scrollToBottom:()=>s==null?void 0:s.scrollToBottom(),resize:(a,l)=>s==null?void 0:s.resize(a,l),getTerminal:()=>s??null,getSize:()=>s?{cols:Math.max(2,s.cols),rows:Math.max(2,s.rows)}:null,runPostSelectResize:()=>k(),scheduleResize:(a,l)=>A(a,l),calculateSizeFromContainer:()=>{var le,ce,J,we,ue,pe,Se,be,Ie,Ce,je,Ne,Ee,t,d,u;const a=z.current,l=s,I=w.current;if(!a||!l)return null;const W=a.getBoundingClientRect();if(W.width===0||W.height===0)return null;const Z=l._core;let oe;if(I)try{const x=I.proposeDimensions();if(x)oe=Math.max(2,x.cols);else{const Y=((we=(J=(ce=(le=Z==null?void 0:Z._renderService)==null?void 0:le.dimensions)==null?void 0:ce.css)==null?void 0:J.cell)==null?void 0:we.width)??9;oe=Math.max(2,Math.floor(W.width/Y))}}catch{const x=((be=(Se=(pe=(ue=Z==null?void 0:Z._renderService)==null?void 0:ue.dimensions)==null?void 0:pe.css)==null?void 0:Se.cell)==null?void 0:be.width)??9;oe=Math.max(2,Math.floor(W.width/x))}else{const x=((Ne=(je=(Ce=(Ie=Z==null?void 0:Z._renderService)==null?void 0:Ie.dimensions)==null?void 0:Ce.css)==null?void 0:je.cell)==null?void 0:Ne.width)??9;oe=Math.max(2,Math.floor(W.width/x))}const ie=((u=(d=(t=(Ee=Z==null?void 0:Z._renderService)==null?void 0:Ee.dimensions)==null?void 0:t.css)==null?void 0:d.cell)==null?void 0:u.height)??17,ge=Math.max(2,Math.floor(W.height/ie));return{cols:oe,rows:ge}},getPendingLocalSize:()=>ne.current}),[s,ne,k,A]),o.jsxs("div",{className:"flex h-full w-full flex-col",style:{backgroundColor:B.background},"data-terminal-engine":Ue,children:[o.jsxs("div",{ref:z,className:"relative min-h-0 w-full flex-1",children:[o.jsx("div",{ref:H,className:"absolute inset-0"}),o.jsx(Wt,{visible:F,canPaste:c==="direct"&&p&&!R,onCopy:ve,onPaste:ae,onDismiss:ye})]}),E]})});Xe.displayName="Terminal";const sn=1200,on=2e3;function fe(n,e){return!n||!e?!1:n.windowId===e.windowId&&n.paneId===e.paneId}function Ke(n,e){const i=n.filter(c=>e-c.at<sn);return i.length===0?null:i.reduce((c,p)=>p.at>c.at?p:c)}function Te(n,e=Date.now()){return!n||e-n.at>on?null:n}function cn(n){const e=n.now??Date.now(),i=Ke(n.recentSelectRequests,e);if(i&&!fe(i,n.activePaneFromEvent)||fe(n.currentRoute,n.activePaneFromEvent)||fe(n.lastHandledActive,n.activePaneFromEvent))return!0;const c=Te(n.pendingUserSelection,e);return!!(c&&!fe(c,n.activePaneFromEvent))}function an(n){const e=n.now??Date.now(),i=Ke(n.recentSelectRequests,e),c=Te(n.pendingUserSelection,e);return!!(c&&!fe(c,n.snapshotActive)||i&&!fe(i,n.snapshotActive))}function ln(n){const e=n.now??Date.now(),i=Te(n.pendingUserSelection,e);return!(i&&fe(i,n.routeTarget)||n.snapshotActive&&fe(n.snapshotActive,n.routeTarget))}const Be=r.memo(function({onActivate:e,disabled:i}){const{data:c}=_e({queryKey:Lt,queryFn:Pt,staleTime:6e4}),p=(c==null?void 0:c.items)??[];return p.length===0?null:o.jsx("div",{className:"terminal-shortcuts-strip","data-testid":"terminal-shortcuts-strip",children:o.jsx(At,{items:p,useIcons:(c==null?void 0:c.useIcons)??!1,onActivate:e,disabled:i,preventFocusSteal:!0,rowTestId:"terminal-shortcuts-row",idPrefix:"terminal-shortcut"})})});function fn(){var Ee;const{t:n}=Re(),{deviceId:e,windowId:i,paneId:c}=Pe(),p=ct(),R=r.useRef(null),N=r.useRef(null),v=r.useRef(null),E=r.useRef(null),G=r.useRef(!1),s=r.useRef(!1),C=r.useRef(null),F=K(t=>t.selectPane),V=K(t=>e?t.snapshots[e]:void 0),O=K(t=>{var d;return e?(d=t.deviceErrors)==null?void 0:d[e]:void 0}),S=K(t=>{var d;return e?((d=t.deviceConnected)==null?void 0:d[e])??!1:!1}),Q=Oe(t=>{var d;return((d=t.settings)==null?void 0:d.siteName)??"tmex"}),f=r.useMemo(()=>Le(c),[c]),P=r.useMemo(()=>e&&f?`${e}:${f}`:null,[e,f]),[B,z]=r.useState(!1),[H,w]=r.useState(""),m=r.useRef(!1),b=!S||!f,[M,$]=r.useState(!1),h=ee(t=>t.inputMode),g=ee(t=>t.theme),L=ee(t=>t.editorSendWithEnter),_=ee(t=>t.setEditorSendWithEnter),T=ee(t=>t.addEditorHistory),q=ee(t=>t.setEditorDraft),U=ee(t=>t.removeEditorDraft),X=ee(t=>P?t.editorDrafts[P]??"":""),se=r.useMemo(()=>at(),[]),y=(Ee=V==null?void 0:V.session)==null?void 0:Ee.windows,ne=g==="light"?$e:He,{data:A}=_e({queryKey:["devices"],queryFn:async()=>{const t=await fetch("/api/devices");if(!t.ok)throw new Error("Failed to fetch devices");return t.json()},throwOnError:!1}),k=r.useMemo(()=>{if(e)return A==null?void 0:A.devices.find(t=>t.id===e)},[e,A==null?void 0:A.devices]),j=r.useMemo(()=>{if(!(!i||!y))return y.find(t=>t.id===i)},[i,y]),D=r.useMemo(()=>{if(!(!f||!j))return j.panes.find(t=>t.id===f)},[f,j]),re=!!y,a=!!(re&&!!i&&!j||re&&!!i&&!!f&&!!j&&!D?n("wsError.checkGateway"):null),l=!!(S&&f&&!a),I=r.useMemo(()=>{if(!j||!D)return null;const t=(k==null?void 0:k.name)??e;return qe({paneIdx:D.index,windowIdx:j.index,paneTitle:D.title,windowName:j.name,windowCustomName:j.customName,deviceName:t})},[k==null?void 0:k.name,e,D,j]),W=r.useMemo(()=>{if(!y||y.length===0)return null;const t=y.find(u=>u.active),d=t==null?void 0:t.panes.find(u=>u.active);return!t||!d?null:{windowId:t.id,paneId:d.id}},[y]),Z=r.useCallback((t,d)=>{!e||!f||K.getState().resizePane(e,f,t,d)},[e,f]),oe=r.useCallback((t,d)=>{!e||!f||K.getState().syncPaneSize(e,f,t,d)},[e,f]),ie=r.useCallback((t,d)=>{const u=E.current,x=(u==null?void 0:u.calculateSizeFromContainer())??(u==null?void 0:u.getSize())??void 0;if(x)return x;if(!t||!d||!y)return;const Y=y.find(me=>me.id===t),te=Y==null?void 0:Y.panes.find(me=>me.id===d);if(!(!te||te.width<=1||te.height<=1))return{cols:te.width,rows:te.height}},[y]);r.useEffect(()=>{const t=()=>{z(window.innerWidth<768||"ontouchstart"in window)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),r.useEffect(()=>{if(!B||!se||s.current)return;s.current=!0;const t=()=>{window.scrollTo(0,1)},d=window.requestAnimationFrame(t),u=window.setTimeout(t,120),x=window.setTimeout(t,420);return()=>{window.cancelAnimationFrame(d),window.clearTimeout(u),window.clearTimeout(x)}},[se,B]),r.useEffect(()=>{e&&(G.current=!1,we.current=null,ue.current=null,C.current=null,le.current=[])},[e]),r.useEffect(()=>{S||(G.current=!1)},[S]),r.useEffect(()=>{if(!e||!S||!i||!y)return;if(y.length===0){p("/devices",{replace:!0});return}const t=y.find(u=>u.id===i);if(!t)return;if(!f){const u=t.panes.find(x=>x.active)??t.panes[0];u&&p(`/devices/${e}/windows/${i}/panes/${xe(u.id)}`,{replace:!0});return}if(!t.panes.find(u=>u.id===f)){const u=t.panes.find(x=>x.active)??t.panes[0];u&&p(`/devices/${e}/windows/${i}/panes/${xe(u.id)}`,{replace:!0});return}},[e,S,y,i,f,p]),r.useEffect(()=>{if(!e||!S||!y||y.length===0||i&&f||G.current)return;const t=y.find(u=>u.active)??y[0],d=t.panes.find(u=>u.active)??t.panes[0];d&&(G.current=!0,p(`/devices/${e}/windows/${t.id}/panes/${xe(d.id)}`,{replace:!0}))},[S,e,p,f,i,y]);const ge=r.useRef(null);r.useEffect(()=>{ge.current=null},[e,f]),r.useEffect(()=>{if(!e||!i||!f||b||!S)return;const t=`${e}:${i}:${f}`;if(ge.current===t)return;ge.current=t;const d=ie(i,f);ce(i,f),F(e,i,f,d)},[S,e,ie,b,f,F,i]),r.useEffect(()=>{if(!e||!S||!i||!f)return;const t={windowId:i,paneId:f};ln({routeTarget:t,snapshotActive:W,pendingUserSelection:C.current})&&(C.current={windowId:t.windowId,paneId:t.paneId,at:Date.now()})},[S,e,f,W,i]);const le=r.useRef([]),ce=r.useCallback((t,d)=>{const u=Date.now(),x=[...le.current.filter(Y=>u-Y.at<2e3),{windowId:t,paneId:d,at:u}];le.current=x.slice(-8)},[]),J=K(t=>e?t.activePaneFromEvent[e]:void 0),we=r.useRef(null);r.useEffect(()=>{if(!e||!S||!i||!f||!J)return;const t=Date.now(),d=Te(C.current,t);if(C.current=d,cn({now:t,pendingUserSelection:d,activePaneFromEvent:J,currentRoute:{windowId:i,paneId:f},recentSelectRequests:le.current,lastHandledActive:we.current}))return;we.current={...J},d&&d.windowId===J.windowId&&d.paneId===J.paneId&&(C.current=null);const u=ie(J.windowId,J.paneId);ce(J.windowId,J.paneId),F(e,J.windowId,J.paneId,u),p(`/devices/${e}/windows/${J.windowId}/panes/${xe(J.paneId)}`,{replace:!0})},[e,S,i,f,J,ce,ie,F,p]);const ue=r.useRef(null);r.useEffect(()=>{if(!e||!S||!y||y.length===0)return;const t=le.current,d=y.find(Me=>Me.active);if(!d)return;const u=d.panes.find(Me=>Me.active);if(!u)return;const x={windowId:d.id,paneId:u.id},Y=Date.now(),te=Te(C.current,Y);if(C.current=te,an({now:Y,pendingUserSelection:te,snapshotActive:x,recentSelectRequests:t})||ue.current&&ue.current.windowId===x.windowId&&ue.current.paneId===x.paneId||(ue.current={...x},te&&te.windowId===x.windowId&&te.paneId===x.paneId&&(C.current=null),i===x.windowId&&f===x.paneId))return;const me=ie(x.windowId,x.paneId);ce(x.windowId,x.paneId),F(e,x.windowId,x.paneId,me),p(`/devices/${e}/windows/${x.windowId}/panes/${xe(x.paneId)}`,{replace:!0})},[e,S,y,i,f,ce,ie,F,p]);const pe=K(t=>e?t.pendingCreateWindowAt[e]:void 0);r.useEffect(()=>{if(!e||!S||!pe)return;const t=5e3,d=Date.now()-pe;if(d>t){K.getState().clearPendingCreateWindow(e);return}if(!W){const Y=window.setTimeout(()=>{K.getState().clearPendingCreateWindow(e)},t-d);return()=>window.clearTimeout(Y)}const u=W;if(i===u.windowId&&f===u.paneId){const Y=window.setTimeout(()=>{K.getState().clearPendingCreateWindow(e)},t-d);return()=>window.clearTimeout(Y)}C.current={windowId:u.windowId,paneId:u.paneId,at:Date.now()};const x=ie(u.windowId,u.paneId);ce(u.windowId,u.paneId),F(e,u.windowId,u.paneId,x),p(`/devices/${e}/windows/${u.windowId}/panes/${xe(u.paneId)}`,{replace:!0}),K.getState().clearPendingCreateWindow(e)},[e,S,pe,W,i,f,ce,ie,F,p]),r.useEffect(()=>{if(!l||!D||b)return;const t=E.current,d=t==null?void 0:t.getTerminal();if(!d)return;const u=Math.max(2,Math.floor(D.width||0)),x=Math.max(2,Math.floor(D.height||0));if(!u||!x)return;const Y=Date.now(),te={cols:u,rows:x},me=(t==null?void 0:t.getPendingLocalSize())??null;Kt({now:Y,remoteSize:te,pendingLocalSize:me})&&(d.cols===u&&d.rows===x||d.resize(u,x))},[l,b,D]),r.useEffect(()=>{const t=window.requestAnimationFrame(()=>{var u;(u=E.current)==null||u.scrollToBottom()}),d=window.setTimeout(()=>{var u;(u=E.current)==null||u.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(d)}},[h]),r.useEffect(()=>{O!=null&&O.message&&he.error(O.message)},[O==null?void 0:O.message]),r.useEffect(()=>(document.title=lt(I),()=>{document.title=Q}),[Q,I]),r.useEffect(()=>{const t=()=>{var d;(d=E.current)==null||d.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",t),()=>{window.removeEventListener("tmex:jump-to-latest",t)}},[]),r.useEffect(()=>{const t=d=>{const{deviceId:u,windowId:x,paneId:Y}=d.detail;u===e&&(C.current={windowId:x,paneId:Y,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",t),()=>{window.removeEventListener("tmex:user-initiated-selection",t)}},[e]),r.useEffect(()=>{w(X)},[X]);const Se=r.useCallback(t=>{if(!e||!f||!l)return;K.getState().sendInput(e,f,t,!1)},[l,e,f]),be=r.useCallback(t=>{var d,u;if(t.type==="action"){if(t.action==="toggleKeyboard"){ee.getState().setInputMode(h==="direct"?"editor":"direct");return}if(t.action==="scrollToBottom"){(d=E.current)==null||d.scrollToBottom();return}}if(t.type==="send"){t.payload&&Se(t.payload);return}if(!(!e||!f||!l))switch(t.action){case"paste":{((u=navigator.clipboard)!=null&&u.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(Y=>{Y&&K.getState().paste(e,f,Y)}).catch(()=>he.error(n("terminal.pasteFailed")));break}case"newAgentSession":ut.getState().startDraft(e,f,null),ee.getState().setSidebarCollapsed(!1),ee.getState().setSidebarTab("agent");break}},[l,e,Se,h,f,n]),Ie=r.useCallback(()=>{if(!l){he.error(n("wsError.checkGateway"));return}if(!e||!f||!H.trim())return;$(!0),window.setTimeout(()=>$(!1),150);const t=L?`${H}\r`:H;K.getState().sendInput(e,f,t,!1),T(H),P&&U(P),w("")},[T,l,e,P,L,H,U,f,n]),Ce=r.useCallback(()=>{if(!l){he.error(n("wsError.checkGateway"));return}if(!e||!f||!H.trim())return;$(!0),window.setTimeout(()=>$(!1),150);const t=H.split(/\r?\n/),d=K.getState();for(const u of t)u.trim()&&d.sendInput(e,f,`${u}\r`,!1);T(H),P&&U(P),w("")},[T,l,e,P,H,U,f,n]),je=r.useCallback(()=>{var t;(t=v.current)==null||t.focus({preventScroll:!0})},[]);if(!e)return o.jsx("div",{className:"flex h-full items-center justify-center p-4",children:o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:n("device.noDevices")})});const Ne=!S&&!O;return o.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[o.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${B&&h==="editor"?"pb-1":""}`,children:[o.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:ne.background},children:S&&f?o.jsx("div",{ref:R,className:"flex-1 h-full min-h-0 w-full","data-virtual-keyboard-avoid":!0,children:o.jsx(Xe,{ref:E,deviceId:e,paneId:f,theme:g,inputMode:h,deviceConnected:S,isSelectionInvalid:a,onResize:Z,onSync:oe,children:h==="direct"&&o.jsx("div",{className:"kb-floating-shortcuts",style:{backgroundColor:ne.background},children:o.jsx(Be,{onActivate:be,disabled:!l})})},`${e}:${f}`)}):o.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:o.jsx("div",{className:"max-w-sm space-y-4",children:S?i?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:o.jsx(ke,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),o.jsx("h3",{className:"text-lg font-medium",children:n("terminal.connecting")})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:o.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),o.jsx("h3",{className:"text-lg font-medium",children:n("window.noWindowSelected")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:n("window.selectWindowToStart")})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:o.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),o.jsx("h3",{className:"text-lg font-medium",children:n("device.disconnected")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:n("device.connectToStart")})]})})})}),Ne&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:o.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[o.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),o.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:n("terminal.connecting")})]})})]}),h==="editor"&&o.jsxs("div",{ref:N,"data-virtual-keyboard-avoid":!0,className:"editor-mode-input bg-card/85 backdrop-blur-sm",children:[B&&o.jsx(Be,{onActivate:t=>{be(t),t.type==="send"&&je()},disabled:!l}),o.jsx("textarea",{ref:v,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:H,onChange:t=>{const d=t.target.value;if(w(d),!!P){if(d){q(P,d);return}U(P)}},placeholder:n("terminal.inputPlaceholder"),onCompositionStart:()=>{m.current=!0},onCompositionEnd:()=>{m.current=!1}}),o.jsx("div",{className:"actions mt-2",children:o.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[o.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[o.jsx(dt,{size:"sm",checked:L,onCheckedChange:t=>_(!!t)}),o.jsx("span",{children:n("terminal.editorSendWithEnter")})]}),o.jsxs(de,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:t=>t.preventDefault(),onClick:()=>{var t;w(""),P&&U(P),B&&h==="editor"&&((t=v.current)==null||t.focus({preventScroll:!0}))},title:n("terminal.clear"),children:[o.jsx(ft,{className:"h-4 w-4"}),n("terminal.clear")]}),o.jsxs(de,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:t=>t.preventDefault(),onClick:()=>{var t;Ce(),B&&h==="editor"&&((t=v.current)==null||t.focus({preventScroll:!0}))},disabled:!l||M,children:[M?o.jsx(ke,{className:"h-4 w-4 animate-spin"}):o.jsx(De,{className:"h-4 w-4"}),n("terminal.editorSendLineByLine")]}),o.jsxs(de,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:t=>t.preventDefault(),onClick:()=>{var t;Ie(),B&&h==="editor"&&((t=v.current)==null||t.focus({preventScroll:!0}))},disabled:!l||M,children:[M?o.jsx(ke,{className:"h-4 w-4 animate-spin"}):o.jsx(De,{className:"h-4 w-4"}),n("common.send")]})]})})]})]})}function mn(){const{deviceId:n,windowId:e,paneId:i}=Pe(),c=i?Le(i):void 0,p=K(s=>s.snapshots),R=Oe(s=>{var C;return((C=s.settings)==null?void 0:C.siteName)??"tmex"}),N=n?p[n]:void 0,v=r.useMemo(()=>{var s;if(!(!e||!((s=N==null?void 0:N.session)!=null&&s.windows)))return N.session.windows.find(C=>C.id===e)},[e,N]),E=r.useMemo(()=>{if(!(!c||!v))return v.panes.find(s=>s.id===c)},[c,v]),G=r.useMemo(()=>v&&E?qe({paneIdx:E.index,windowIdx:v.index,paneTitle:E.title,windowName:v.name,windowCustomName:v.customName,deviceName:R}):n??"",[v,E,R,n]);return o.jsx(o.Fragment,{children:G})}function hn(){const{t:n}=Re(),{deviceId:e,paneId:i}=Pe(),c=i?Le(i):void 0,p=ee(z=>z.inputMode),R=ee(z=>z.setInputMode),N=K(z=>{var H;return e?((H=z.deviceConnected)==null?void 0:H[e])??!1:!1}),[v,E]=r.useState(!1),[G,s]=r.useState(!1),[C,F]=r.useState(!1),V=!!(c&&N),S=(_e({queryKey:yt(e??"",c??""),queryFn:()=>Rt(e??"",c??""),enabled:!!(e&&c),throwOnError:!1}).data??[]).some(z=>z.enabled),Q=()=>{R(p==="direct"?"editor":"direct")},f=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},P=()=>{E(!0)},B=()=>{window.location.reload()};return o.jsxs(o.Fragment,{children:[o.jsx(de,{variant:"ghost",size:"icon-sm",onClick:P,"aria-label":n("nav.refreshPage"),title:n("nav.refreshPage"),children:o.jsx(Mt,{className:"h-4 w-4"})}),o.jsx(de,{variant:"ghost",size:"icon-sm",onClick:Q,disabled:!V,"data-testid":"terminal-input-mode-toggle","aria-label":n(p==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:n(p==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:p==="direct"?o.jsx(mt,{className:"h-4 w-4"}):o.jsx(Ft,{className:"h-4 w-4"})}),o.jsx(de,{variant:"ghost",size:"icon-sm",onClick:f,disabled:!V,"aria-label":n("nav.jumpToLatest"),title:n("nav.jumpToLatest"),children:o.jsx(kt,{className:"h-4 w-4"})}),o.jsxs(de,{variant:"ghost",size:"icon-sm",className:"relative",onClick:()=>s(!0),disabled:!c,"data-testid":"watch-open-button","aria-label":n("watch.title"),title:n("watch.title"),children:[o.jsx(ht,{className:"h-4 w-4"}),S&&o.jsx("span",{className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-primary","data-testid":"watch-active-indicator"})]}),o.jsx(de,{variant:"ghost",size:"icon-sm",onClick:()=>F(!0),"data-testid":"keyboard-behavior-open-button","aria-label":n("settings.terminal.title"),title:n("settings.terminal.title"),children:o.jsx(zt,{className:"h-4 w-4"})}),o.jsx(Bt,{open:C,onOpenChange:F}),e&&c&&o.jsx(wt,{open:G,onOpenChange:s,deviceId:e,paneId:c}),o.jsx(pt,{open:v,onOpenChange:E,children:o.jsxs(xt,{children:[o.jsxs(vt,{children:[o.jsx(gt,{children:n("nav.refreshPage")}),o.jsx(St,{children:n("nav.refreshPageConfirm")})]}),o.jsxs(bt,{children:[o.jsx(Et,{onClick:()=>E(!1),children:n("common.cancel")}),o.jsx(Tt,{onClick:B,children:n("common.confirm")})]})]})})]})}export{hn as PageActions,mn as PageTitle,fn as default};
|
|
15
|
+
//# sourceMappingURL=DevicePage-EoPdR0a8.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as D,r as x,a as W,b as ae,c as ie,d as re,e as K,t as ne,j as e,M as _,B as C,P as X,A as oe,f as ce,g as de,h as le,T as Y,i as me,k as he,l as ue,m as pe,n as xe,G as ve,o as v,D as fe,p as ye,E as ge,q as je,s as A,v as we,Z as Ne,w as Ce,x as Q,y as De,S as be,L as Se,z as Ee,C as Me,F as Pe,H as Ke,I as Re,J as Ie,K as f,N as z,O as V,Q as U,R as J,U as j,V as ke,W as Ae}from"./index-Ra6pj0rt.js";import{C as M,a as P,b as $e,c as Te,d as Fe}from"./card-BkRqR9zz.js";function R(s){const o=s.trim();return o||void 0}function qe(s){return s?{name:s.name,type:s.type,host:s.host??"",port:s.port??22,username:s.username??"",sshConfigRef:s.sshConfigRef??"",session:s.session??"tmex",authMode:s.type==="local"?"auto":s.authMode,password:"",privateKey:"",privateKeyPassphrase:""}:{name:"",type:"local",host:"",port:22,username:"root",sshConfigRef:"",session:"tmex",authMode:"auto",password:"",privateKey:"",privateKeyPassphrase:""}}function Le(s){if(s.type==="local")return{name:s.name.trim(),type:"local",session:R(s.session)??"tmex",authMode:"auto"};const o={name:s.name.trim(),type:"ssh",host:s.host.trim(),port:s.port,username:s.username.trim(),session:R(s.session)??"tmex",authMode:s.authMode};return s.authMode==="configRef"&&(o.sshConfigRef=s.sshConfigRef.trim()),s.authMode==="password"&&(o.password=s.password),s.authMode==="key"&&(o.privateKey=s.privateKey,o.privateKeyPassphrase=s.privateKeyPassphrase||void 0),o}function He(s){if(s.type==="local")return{name:s.name.trim(),session:R(s.session)??"tmex",authMode:"auto"};const o={name:s.name.trim(),host:s.host.trim(),port:s.port,username:s.username.trim(),sshConfigRef:s.authMode==="configRef"?s.sshConfigRef.trim():"",session:R(s.session)??"tmex",authMode:s.authMode};return s.authMode==="password"&&s.password&&(o.password=s.password),s.authMode==="key"&&s.privateKey&&(o.privateKey=s.privateKey,o.privateKeyPassphrase=s.privateKeyPassphrase||void 0),o}function ee(s){return Number.isInteger(s)&&s>=1&&s<=65535}function Oe(s){return s.type!=="ssh"?null:s.host.trim()?ee(s.port)?s.username.trim()?s.authMode==="configRef"&&!s.sshConfigRef.trim()?"validation.sshConfigRequired":null:"validation.usernameRequired":"validation.portRequired":"validation.hostRequired"}async function G(s,o){try{return(await s.json()).error??o}catch{return o}}function Ve(){const{t:s}=D(),[o,m]=x.useState(!1),[t,y]=x.useState(null),[r,d]=x.useState(null),l=W(),u=ae(n=>{var p;return((p=n.settings)==null?void 0:p.language)??"en_US"});x.useEffect(()=>{const n=()=>m(!0);return window.addEventListener("tmex:open-add-device",n),()=>window.removeEventListener("tmex:open-add-device",n)},[]);const{data:c,isLoading:I,isError:w}=ie({queryKey:["devices"],queryFn:async()=>{const n=await fetch("/api/devices");if(!n.ok)throw new Error(s("device.loadFailed"));return n.json()},throwOnError:!1}),b=re(n=>n.hydrateDeviceErrors);x.useEffect(()=>{c!=null&&c.devices&&b(c.devices.map(n=>({deviceId:n.id,lastError:n.lastError??null,lastErrorType:n.lastErrorType??null})))},[c,b]);const S=K({mutationFn:async n=>{if(!(await fetch(`/api/devices/${n}`,{method:"DELETE"})).ok)throw new Error(s("device.deleteFailed"))},onSuccess:()=>{l.invalidateQueries({queryKey:["devices"]}),v.success(s("common.success"))},onError:n=>{v.error(n instanceof Error?n.message:s("common.error"))}}),E=x.useMemo(()=>[...(c==null?void 0:c.devices)??[]].sort((p,N)=>p.sortOrder-N.sortOrder||p.name.localeCompare(N.name,ne(u),{numeric:!0,sensitivity:"base"})),[c==null?void 0:c.devices,u]);return e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-3 p-3 pb-[calc(1rem+env(safe-area-inset-bottom))] sm:gap-4 sm:p-5","data-testid":"devices-page",children:[I?e.jsx(M,{children:e.jsx(P,{className:"py-16 text-center text-sm text-muted-foreground",children:s("common.loading")})}):w?e.jsx(M,{children:e.jsx(P,{className:"py-16 text-center text-sm text-destructive",children:s("device.loadFailed")})}):E.length===0?e.jsx(M,{children:e.jsxs(P,{className:"space-y-4 py-14 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted",children:e.jsx(_,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-medium",children:s("device.noDevices")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("device.addDevice")})]}),e.jsxs(C,{variant:"default","data-testid":"devices-add-empty",onClick:()=>m(!0),children:[e.jsx(X,{className:"h-4 w-4"}),s("device.addDevice")]})]})}):e.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:E.map(n=>e.jsx(Be,{device:n,onEdit:()=>y(n),onDelete:()=>d(n)},n.id))}),o&&e.jsx(Z,{mode:"create",onClose:()=>m(!1)}),t&&e.jsx(Z,{mode:"edit",device:t,onClose:()=>y(null)}),e.jsx(oe,{open:r!==null,onOpenChange:n=>!n&&d(null),children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsx(le,{className:"bg-destructive/10",children:e.jsx(Y,{className:"h-5 w-5 text-destructive"})}),e.jsx(me,{children:s("device.deleteConfirm")}),e.jsx(he,{children:s("device.deleteDescription",{name:(r==null?void 0:r.name)??""})})]}),e.jsxs(ue,{children:[e.jsx(pe,{children:s("common.cancel")}),e.jsx(xe,{variant:"destructive",disabled:!r||S.isPending,onClick:()=>{r&&(S.mutate(r.id),d(null))},children:s("common.delete")})]})]})})]})}function Be({device:s,onEdit:o,onDelete:m}){const{t}=D(),y=s.type==="local"?e.jsx(_,{className:"h-4 w-4"}):e.jsx(ve,{className:"h-4 w-4"}),r=s.type==="local"?t("device.typeLocal"):`${s.username??"-"}@${s.host??"-"}:${s.port??22}`,d=K({mutationFn:async()=>{const l=await fetch(`/api/devices/${s.id}/test-connection`,{method:"POST"});let u=null;try{u=await l.json()}catch{u=null}if(!l.ok){const c=u;throw new Error((c==null?void 0:c.error)??t("common.error"))}return u},onSuccess:l=>{v.success(l.message??t("common.success"))},onError:l=>{v.error(l instanceof Error?l.message:t("common.error"))}});return e.jsxs(M,{"data-testid":"device-card","data-device-id":s.id,"data-device-name":s.name,className:"overflow-hidden border-border/50",children:[e.jsxs($e,{className:"space-y-2 pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground",children:y}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx(Te,{className:"line-clamp-1 text-sm",title:s.name,children:s.name}),e.jsx(Fe,{className:"line-clamp-1 text-xs",children:r})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:e.jsxs(fe,{children:[e.jsx(ye,{render:e.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":`device-card-actions-${s.id}`,"aria-label":t("common.edit"),title:t("common.edit")}),children:e.jsx(ge,{className:"h-4 w-4"})}),e.jsxs(je,{align:"end",children:[e.jsxs(A,{"data-testid":`device-card-edit-${s.id}`,onClick:o,children:[e.jsx(we,{className:"h-4 w-4"}),t("common.edit")]}),s.type==="ssh"&&e.jsxs(A,{"data-testid":`device-card-test-${s.id}`,onClick:()=>d.mutate(),disabled:d.isPending,children:[e.jsx(Ne,{className:"h-4 w-4"}),t("common.test")]}),e.jsx(Ce,{}),e.jsxs(A,{"data-testid":`device-card-delete-${s.id}`,variant:"destructive",onClick:m,children:[e.jsx(Y,{className:"h-4 w-4"}),t("common.delete")]})]})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:s.type==="local"?t("device.typeLocal"):t("device.typeSSHBadge")}),s.session&&e.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:s.session}),e.jsx(De,{deviceId:s.id})]})]}),e.jsxs(P,{className:"pt-0",children:[e.jsx(be,{className:"mb-2"}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(Se,{to:`/devices/${s.id}`,"data-testid":`device-card-connect-${s.id}`,className:Ee({variant:"outline",size:"sm"}),children:t("device.connect")})})]})]})}function Z({mode:s,device:o,onClose:m}){const{t}=D(),y=W(),[r,d]=x.useState(qe(o)),[l,u]=x.useState(!1),[c,I]=x.useState(!1),w=s==="edit",b=r.type==="ssh",S=K({mutationFn:async a=>{const i=await fetch("/api/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.createFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(t("common.success")),m()},onError:a=>{v.error(a instanceof Error?a.message:t("common.error"))}}),E=K({mutationFn:async a=>{if(!o)throw new Error(t("apiError.deviceNotFound"));const i=await fetch(`/api/devices/${o.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.updateFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(t("common.success")),m()},onError:a=>{v.error(a instanceof Error?a.message:t("common.error"))}}),n=async a=>{a.preventDefault(),I(!0);const i=Oe(r);if(i){v.error(t(i));return}u(!0);try{s==="create"?await S.mutateAsync(Le(r)):await E.mutateAsync(He(r))}catch{}finally{u(!1)}},p=`${s}-device-name`,N=`${s}-device-type`,$=`${s}-device-host`,T=`${s}-device-port`,F=`${s}-device-username`,q=`${s}-device-session`,L=`${s}-device-auth-mode`,H=`${s}-device-password`,O=`${s}-device-private-key`,B=`${s}-device-private-key-passphrase`,se={local:t("device.typeLocal"),ssh:t("device.typeSSH")},te={password:t("device.authPassword"),key:t("device.authKey"),agent:t("device.authAgent"),configRef:t("device.authConfigRef")},k=a=>e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),h=(a,i,g)=>e.jsxs("label",{className:"block text-xs font-medium text-foreground",htmlFor:a,children:[i,g&&e.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]});return e.jsx(Me,{open:!0,onOpenChange:a=>!a&&m(),children:e.jsxs(Pe,{"data-testid":"device-dialog",className:"w-full max-w-2xl",children:[e.jsxs(Ke,{children:[e.jsx(Re,{children:t(w?"device.editDevice":"device.addDevice")}),e.jsx(Ie,{children:t(w?"device.editDeviceDescription":"device.addDeviceDescription")})]}),e.jsxs("form",{onSubmit:n,className:"space-y-4",children:[e.jsxs("div",{className:"-mr-2 max-h-[min(70dvh,720px)] space-y-5 overflow-y-auto pr-2",children:[e.jsxs("section",{className:"space-y-2.5",children:[k(t("device.sectionBasic")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(p,t("device.name"),!0),e.jsx(f,{id:p,"data-testid":"device-name-input",type:"text",value:r.name,onChange:a=>d(i=>({...i,name:a.target.value})),placeholder:t("device.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(N,t("device.type")),e.jsxs(z,{value:r.type,onValueChange:a=>{if(!a)return;const i=a;d(g=>({...g,type:i,authMode:i==="local"?"auto":g.authMode==="auto"?"agent":g.authMode}))},disabled:w,children:[e.jsx(V,{id:N,"data-testid":"device-type-select",className:"w-full",children:e.jsx(U,{placeholder:t("device.type"),children:a=>se[a]??""})}),e.jsxs(J,{children:[e.jsx(j,{value:"local",children:t("device.typeLocal")}),e.jsx(j,{value:"ssh",children:t("device.typeSSH")})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(q,t("device.session")),e.jsx(f,{id:q,"data-testid":"device-session-input",type:"text",value:r.session,onChange:a=>d(i=>({...i,session:a.target.value})),placeholder:t("device.sessionPlaceholder")})]})]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-2.5",children:[k(t("device.sectionConnection")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h($,t("device.host"),!0),e.jsx(f,{id:$,type:"text",value:r.host,onChange:a=>d(i=>({...i,host:a.target.value})),placeholder:t("device.hostPlaceholder"),"aria-invalid":c&&!r.host.trim()})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(T,t("device.port"),!0),e.jsx(f,{id:T,type:"number",value:Number.isNaN(r.port)?"":r.port,onChange:a=>{const i=a.target.value;d(g=>({...g,port:i===""?Number.NaN:Number.parseInt(i,10)}))},min:1,max:65535,"aria-invalid":c&&!ee(r.port)})]}),e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(F,t("device.username"),!0),e.jsx(f,{id:F,type:"text",value:r.username,onChange:a=>d(i=>({...i,username:a.target.value})),placeholder:t("device.usernamePlaceholder"),"aria-invalid":c&&!r.username.trim()})]})]})]}),e.jsxs("section",{className:"space-y-2.5",children:[k(t("device.sectionAuth")),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[h(L,t("device.authMode")),e.jsxs(z,{value:r.authMode,onValueChange:a=>{a&&d(i=>({...i,authMode:a}))},children:[e.jsx(V,{id:L,"data-testid":"device-auth-mode-select",className:"w-full",children:e.jsx(U,{placeholder:t("device.authMode"),children:a=>te[a]??""})}),e.jsxs(J,{children:[e.jsx(j,{value:"password",children:t("device.authPassword")}),e.jsx(j,{value:"key",children:t("device.authKey")}),e.jsx(j,{value:"agent",children:t("device.authAgent")}),e.jsx(j,{value:"configRef",children:t("device.authConfigRef")})]})]})]}),r.authMode==="password"&&e.jsxs("div",{className:"space-y-1.5",children:[h(H,t("device.password")),e.jsx(f,{id:H,type:"password",value:r.password,onChange:a=>d(i=>({...i,password:a.target.value}))})]}),r.authMode==="key"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[h(O,t("device.privateKey")),e.jsx(ke,{id:O,value:r.privateKey,onChange:a=>d(i=>({...i,privateKey:a.target.value})),className:"h-28 font-mono text-xs",placeholder:t("device.privateKeyPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(B,t("device.passphrase")),e.jsx(f,{id:B,type:"password",value:r.privateKeyPassphrase,onChange:a=>d(i=>({...i,privateKeyPassphrase:a.target.value}))})]})]}),r.authMode==="configRef"&&e.jsxs("div",{className:"space-y-1.5",children:[h(`${s}-device-ssh-config-ref`,t("device.authConfigRef"),!0),e.jsx(f,{id:`${s}-device-ssh-config-ref`,"data-testid":"device-ssh-config-ref-input",type:"text",value:r.sshConfigRef,onChange:a=>d(i=>({...i,sshConfigRef:a.target.value})),placeholder:t("device.sshConfigRefPlaceholder"),"aria-invalid":c&&!r.sshConfigRef.trim()}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("device.sshConfigRefHint")})]})]})]})]})]}),e.jsxs(Ae,{children:[e.jsx(C,{type:"button",variant:"outline",onClick:m,children:t("common.cancel")}),e.jsx(C,{type:"submit",variant:"default","data-testid":"device-dialog-save",disabled:l,children:t(l?"common.saving":"common.save")})]})]})]})})}function Ue(){const{t:s}=D();return e.jsx(e.Fragment,{children:s("sidebar.manageDevices")})}function Je(){const{t:s}=D(),o=()=>{window.dispatchEvent(new CustomEvent("tmex:open-add-device"))};return e.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":"devices-add",onClick:o,"aria-label":s("sidebar.addDevice"),title:s("sidebar.addDevice"),children:e.jsx(X,{className:"h-4 w-4"})})}export{Je as PageActions,Ue as PageTitle,Ve as default};
|
|
2
|
-
//# sourceMappingURL=DevicesPage-
|
|
1
|
+
import{u as D,r as x,a as W,b as ae,c as ie,d as re,e as K,t as ne,j as e,M as _,B as C,P as X,A as oe,f as ce,g as de,h as le,T as Y,i as me,k as he,l as ue,m as pe,n as xe,G as ve,o as v,D as fe,p as ye,E as ge,q as je,s as A,v as we,Z as Ne,w as Ce,x as Q,y as De,S as be,L as Se,z as Ee,C as Me,F as Pe,H as Ke,I as Re,J as Ie,K as f,N as z,O as V,Q as U,R as J,U as j,V as ke,W as Ae}from"./index-FNpsxYPN.js";import{C as M,a as P,b as $e,c as Te,d as Fe}from"./card-CMyk5OFt.js";function R(s){const o=s.trim();return o||void 0}function qe(s){return s?{name:s.name,type:s.type,host:s.host??"",port:s.port??22,username:s.username??"",sshConfigRef:s.sshConfigRef??"",session:s.session??"tmex",authMode:s.type==="local"?"auto":s.authMode,password:"",privateKey:"",privateKeyPassphrase:""}:{name:"",type:"local",host:"",port:22,username:"root",sshConfigRef:"",session:"tmex",authMode:"auto",password:"",privateKey:"",privateKeyPassphrase:""}}function Le(s){if(s.type==="local")return{name:s.name.trim(),type:"local",session:R(s.session)??"tmex",authMode:"auto"};const o={name:s.name.trim(),type:"ssh",host:s.host.trim(),port:s.port,username:s.username.trim(),session:R(s.session)??"tmex",authMode:s.authMode};return s.authMode==="configRef"&&(o.sshConfigRef=s.sshConfigRef.trim()),s.authMode==="password"&&(o.password=s.password),s.authMode==="key"&&(o.privateKey=s.privateKey,o.privateKeyPassphrase=s.privateKeyPassphrase||void 0),o}function He(s){if(s.type==="local")return{name:s.name.trim(),session:R(s.session)??"tmex",authMode:"auto"};const o={name:s.name.trim(),host:s.host.trim(),port:s.port,username:s.username.trim(),sshConfigRef:s.authMode==="configRef"?s.sshConfigRef.trim():"",session:R(s.session)??"tmex",authMode:s.authMode};return s.authMode==="password"&&s.password&&(o.password=s.password),s.authMode==="key"&&s.privateKey&&(o.privateKey=s.privateKey,o.privateKeyPassphrase=s.privateKeyPassphrase||void 0),o}function ee(s){return Number.isInteger(s)&&s>=1&&s<=65535}function Oe(s){return s.type!=="ssh"?null:s.host.trim()?ee(s.port)?s.username.trim()?s.authMode==="configRef"&&!s.sshConfigRef.trim()?"validation.sshConfigRequired":null:"validation.usernameRequired":"validation.portRequired":"validation.hostRequired"}async function G(s,o){try{return(await s.json()).error??o}catch{return o}}function Ve(){const{t:s}=D(),[o,m]=x.useState(!1),[t,y]=x.useState(null),[r,d]=x.useState(null),l=W(),u=ae(n=>{var p;return((p=n.settings)==null?void 0:p.language)??"en_US"});x.useEffect(()=>{const n=()=>m(!0);return window.addEventListener("tmex:open-add-device",n),()=>window.removeEventListener("tmex:open-add-device",n)},[]);const{data:c,isLoading:I,isError:w}=ie({queryKey:["devices"],queryFn:async()=>{const n=await fetch("/api/devices");if(!n.ok)throw new Error(s("device.loadFailed"));return n.json()},throwOnError:!1}),b=re(n=>n.hydrateDeviceErrors);x.useEffect(()=>{c!=null&&c.devices&&b(c.devices.map(n=>({deviceId:n.id,lastError:n.lastError??null,lastErrorType:n.lastErrorType??null})))},[c,b]);const S=K({mutationFn:async n=>{if(!(await fetch(`/api/devices/${n}`,{method:"DELETE"})).ok)throw new Error(s("device.deleteFailed"))},onSuccess:()=>{l.invalidateQueries({queryKey:["devices"]}),v.success(s("common.success"))},onError:n=>{v.error(n instanceof Error?n.message:s("common.error"))}}),E=x.useMemo(()=>[...(c==null?void 0:c.devices)??[]].sort((p,N)=>p.sortOrder-N.sortOrder||p.name.localeCompare(N.name,ne(u),{numeric:!0,sensitivity:"base"})),[c==null?void 0:c.devices,u]);return e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-3 p-3 pb-[calc(1rem+env(safe-area-inset-bottom))] sm:gap-4 sm:p-5","data-testid":"devices-page",children:[I?e.jsx(M,{children:e.jsx(P,{className:"py-16 text-center text-sm text-muted-foreground",children:s("common.loading")})}):w?e.jsx(M,{children:e.jsx(P,{className:"py-16 text-center text-sm text-destructive",children:s("device.loadFailed")})}):E.length===0?e.jsx(M,{children:e.jsxs(P,{className:"space-y-4 py-14 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted",children:e.jsx(_,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-medium",children:s("device.noDevices")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("device.addDevice")})]}),e.jsxs(C,{variant:"default","data-testid":"devices-add-empty",onClick:()=>m(!0),children:[e.jsx(X,{className:"h-4 w-4"}),s("device.addDevice")]})]})}):e.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:E.map(n=>e.jsx(Be,{device:n,onEdit:()=>y(n),onDelete:()=>d(n)},n.id))}),o&&e.jsx(Z,{mode:"create",onClose:()=>m(!1)}),t&&e.jsx(Z,{mode:"edit",device:t,onClose:()=>y(null)}),e.jsx(oe,{open:r!==null,onOpenChange:n=>!n&&d(null),children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsx(le,{className:"bg-destructive/10",children:e.jsx(Y,{className:"h-5 w-5 text-destructive"})}),e.jsx(me,{children:s("device.deleteConfirm")}),e.jsx(he,{children:s("device.deleteDescription",{name:(r==null?void 0:r.name)??""})})]}),e.jsxs(ue,{children:[e.jsx(pe,{children:s("common.cancel")}),e.jsx(xe,{variant:"destructive",disabled:!r||S.isPending,onClick:()=>{r&&(S.mutate(r.id),d(null))},children:s("common.delete")})]})]})})]})}function Be({device:s,onEdit:o,onDelete:m}){const{t}=D(),y=s.type==="local"?e.jsx(_,{className:"h-4 w-4"}):e.jsx(ve,{className:"h-4 w-4"}),r=s.type==="local"?t("device.typeLocal"):`${s.username??"-"}@${s.host??"-"}:${s.port??22}`,d=K({mutationFn:async()=>{const l=await fetch(`/api/devices/${s.id}/test-connection`,{method:"POST"});let u=null;try{u=await l.json()}catch{u=null}if(!l.ok){const c=u;throw new Error((c==null?void 0:c.error)??t("common.error"))}return u},onSuccess:l=>{v.success(l.message??t("common.success"))},onError:l=>{v.error(l instanceof Error?l.message:t("common.error"))}});return e.jsxs(M,{"data-testid":"device-card","data-device-id":s.id,"data-device-name":s.name,className:"overflow-hidden border-border/50",children:[e.jsxs($e,{className:"space-y-2 pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground",children:y}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx(Te,{className:"line-clamp-1 text-sm",title:s.name,children:s.name}),e.jsx(Fe,{className:"line-clamp-1 text-xs",children:r})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:e.jsxs(fe,{children:[e.jsx(ye,{render:e.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":`device-card-actions-${s.id}`,"aria-label":t("common.edit"),title:t("common.edit")}),children:e.jsx(ge,{className:"h-4 w-4"})}),e.jsxs(je,{align:"end",children:[e.jsxs(A,{"data-testid":`device-card-edit-${s.id}`,onClick:o,children:[e.jsx(we,{className:"h-4 w-4"}),t("common.edit")]}),s.type==="ssh"&&e.jsxs(A,{"data-testid":`device-card-test-${s.id}`,onClick:()=>d.mutate(),disabled:d.isPending,children:[e.jsx(Ne,{className:"h-4 w-4"}),t("common.test")]}),e.jsx(Ce,{}),e.jsxs(A,{"data-testid":`device-card-delete-${s.id}`,variant:"destructive",onClick:m,children:[e.jsx(Y,{className:"h-4 w-4"}),t("common.delete")]})]})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:s.type==="local"?t("device.typeLocal"):t("device.typeSSHBadge")}),s.session&&e.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:s.session}),e.jsx(De,{deviceId:s.id})]})]}),e.jsxs(P,{className:"pt-0",children:[e.jsx(be,{className:"mb-2"}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(Se,{to:`/devices/${s.id}`,"data-testid":`device-card-connect-${s.id}`,className:Ee({variant:"outline",size:"sm"}),children:t("device.connect")})})]})]})}function Z({mode:s,device:o,onClose:m}){const{t}=D(),y=W(),[r,d]=x.useState(qe(o)),[l,u]=x.useState(!1),[c,I]=x.useState(!1),w=s==="edit",b=r.type==="ssh",S=K({mutationFn:async a=>{const i=await fetch("/api/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.createFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(t("common.success")),m()},onError:a=>{v.error(a instanceof Error?a.message:t("common.error"))}}),E=K({mutationFn:async a=>{if(!o)throw new Error(t("apiError.deviceNotFound"));const i=await fetch(`/api/devices/${o.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.updateFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(t("common.success")),m()},onError:a=>{v.error(a instanceof Error?a.message:t("common.error"))}}),n=async a=>{a.preventDefault(),I(!0);const i=Oe(r);if(i){v.error(t(i));return}u(!0);try{s==="create"?await S.mutateAsync(Le(r)):await E.mutateAsync(He(r))}catch{}finally{u(!1)}},p=`${s}-device-name`,N=`${s}-device-type`,$=`${s}-device-host`,T=`${s}-device-port`,F=`${s}-device-username`,q=`${s}-device-session`,L=`${s}-device-auth-mode`,H=`${s}-device-password`,O=`${s}-device-private-key`,B=`${s}-device-private-key-passphrase`,se={local:t("device.typeLocal"),ssh:t("device.typeSSH")},te={password:t("device.authPassword"),key:t("device.authKey"),agent:t("device.authAgent"),configRef:t("device.authConfigRef")},k=a=>e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),h=(a,i,g)=>e.jsxs("label",{className:"block text-xs font-medium text-foreground",htmlFor:a,children:[i,g&&e.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]});return e.jsx(Me,{open:!0,onOpenChange:a=>!a&&m(),children:e.jsxs(Pe,{"data-testid":"device-dialog",className:"w-full max-w-2xl",children:[e.jsxs(Ke,{children:[e.jsx(Re,{children:t(w?"device.editDevice":"device.addDevice")}),e.jsx(Ie,{children:t(w?"device.editDeviceDescription":"device.addDeviceDescription")})]}),e.jsxs("form",{onSubmit:n,className:"space-y-4",children:[e.jsxs("div",{className:"-mr-2 max-h-[min(70dvh,720px)] space-y-5 overflow-y-auto pr-2",children:[e.jsxs("section",{className:"space-y-2.5",children:[k(t("device.sectionBasic")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(p,t("device.name"),!0),e.jsx(f,{id:p,"data-testid":"device-name-input",type:"text",value:r.name,onChange:a=>d(i=>({...i,name:a.target.value})),placeholder:t("device.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(N,t("device.type")),e.jsxs(z,{value:r.type,onValueChange:a=>{if(!a)return;const i=a;d(g=>({...g,type:i,authMode:i==="local"?"auto":g.authMode==="auto"?"agent":g.authMode}))},disabled:w,children:[e.jsx(V,{id:N,"data-testid":"device-type-select",className:"w-full",children:e.jsx(U,{placeholder:t("device.type"),children:a=>se[a]??""})}),e.jsxs(J,{children:[e.jsx(j,{value:"local",children:t("device.typeLocal")}),e.jsx(j,{value:"ssh",children:t("device.typeSSH")})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(q,t("device.session")),e.jsx(f,{id:q,"data-testid":"device-session-input",type:"text",value:r.session,onChange:a=>d(i=>({...i,session:a.target.value})),placeholder:t("device.sessionPlaceholder")})]})]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-2.5",children:[k(t("device.sectionConnection")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h($,t("device.host"),!0),e.jsx(f,{id:$,type:"text",value:r.host,onChange:a=>d(i=>({...i,host:a.target.value})),placeholder:t("device.hostPlaceholder"),"aria-invalid":c&&!r.host.trim()})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(T,t("device.port"),!0),e.jsx(f,{id:T,type:"number",value:Number.isNaN(r.port)?"":r.port,onChange:a=>{const i=a.target.value;d(g=>({...g,port:i===""?Number.NaN:Number.parseInt(i,10)}))},min:1,max:65535,"aria-invalid":c&&!ee(r.port)})]}),e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(F,t("device.username"),!0),e.jsx(f,{id:F,type:"text",value:r.username,onChange:a=>d(i=>({...i,username:a.target.value})),placeholder:t("device.usernamePlaceholder"),"aria-invalid":c&&!r.username.trim()})]})]})]}),e.jsxs("section",{className:"space-y-2.5",children:[k(t("device.sectionAuth")),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[h(L,t("device.authMode")),e.jsxs(z,{value:r.authMode,onValueChange:a=>{a&&d(i=>({...i,authMode:a}))},children:[e.jsx(V,{id:L,"data-testid":"device-auth-mode-select",className:"w-full",children:e.jsx(U,{placeholder:t("device.authMode"),children:a=>te[a]??""})}),e.jsxs(J,{children:[e.jsx(j,{value:"password",children:t("device.authPassword")}),e.jsx(j,{value:"key",children:t("device.authKey")}),e.jsx(j,{value:"agent",children:t("device.authAgent")}),e.jsx(j,{value:"configRef",children:t("device.authConfigRef")})]})]})]}),r.authMode==="password"&&e.jsxs("div",{className:"space-y-1.5",children:[h(H,t("device.password")),e.jsx(f,{id:H,type:"password",value:r.password,onChange:a=>d(i=>({...i,password:a.target.value}))})]}),r.authMode==="key"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[h(O,t("device.privateKey")),e.jsx(ke,{id:O,value:r.privateKey,onChange:a=>d(i=>({...i,privateKey:a.target.value})),className:"h-28 font-mono text-xs",placeholder:t("device.privateKeyPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(B,t("device.passphrase")),e.jsx(f,{id:B,type:"password",value:r.privateKeyPassphrase,onChange:a=>d(i=>({...i,privateKeyPassphrase:a.target.value}))})]})]}),r.authMode==="configRef"&&e.jsxs("div",{className:"space-y-1.5",children:[h(`${s}-device-ssh-config-ref`,t("device.authConfigRef"),!0),e.jsx(f,{id:`${s}-device-ssh-config-ref`,"data-testid":"device-ssh-config-ref-input",type:"text",value:r.sshConfigRef,onChange:a=>d(i=>({...i,sshConfigRef:a.target.value})),placeholder:t("device.sshConfigRefPlaceholder"),"aria-invalid":c&&!r.sshConfigRef.trim()}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("device.sshConfigRefHint")})]})]})]})]})]}),e.jsxs(Ae,{children:[e.jsx(C,{type:"button",variant:"outline",onClick:m,children:t("common.cancel")}),e.jsx(C,{type:"submit",variant:"default","data-testid":"device-dialog-save",disabled:l,children:t(l?"common.saving":"common.save")})]})]})]})})}function Ue(){const{t:s}=D();return e.jsx(e.Fragment,{children:s("sidebar.manageDevices")})}function Je(){const{t:s}=D(),o=()=>{window.dispatchEvent(new CustomEvent("tmex:open-add-device"))};return e.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":"devices-add",onClick:o,"aria-label":s("sidebar.addDevice"),title:s("sidebar.addDevice"),children:e.jsx(X,{className:"h-4 w-4"})})}export{Je as PageActions,Ue as PageTitle,Ve as default};
|
|
2
|
+
//# sourceMappingURL=DevicesPage-DaO7f0iC.js.map
|