@kabmo-labs/kabmo 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +785 -624
- package/dist/client/static/js/{CsvGrid-fncjbg6j.js → CsvGrid-vze4m5ag.js} +1 -1
- package/dist/client/static/js/{DocxView-c9v2vr3r.js → DocxView-jbf21gmh.js} +5 -5
- package/dist/client/static/js/{DrawioView-vxjksm12.js → DrawioView-b52qybx5.js} +2 -2
- package/dist/client/static/js/{ImageView-a3g5k226.js → ImageView-mdgzj8px.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-hnjfwsjh.js → LayoutWrapper-3c49dvtt.js} +2 -2
- package/dist/client/static/js/Modal-sqp864vd.js +38 -0
- package/dist/client/static/js/{PdfView-ksaes53y.js → PdfView-g06rxqb1.js} +1 -1
- package/dist/client/static/js/{SessionsView-30vcr95v.js → SessionsView-521adxyr.js} +1 -1
- package/dist/client/static/js/{SheetView-vc484scg.js → SheetView-h8xmsz7q.js} +22 -22
- package/dist/client/static/js/{SvgPreview-tph89jet.js → SvgPreview-1j4jvcvz.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-xbar278c.js → abnfDiagram-O67JEVCF-pasxh4b6.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-fc9kmq1w.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-s171n2z6.js → architectureDiagram-NJMV4G6O-ms14g0bm.js} +4 -4
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-gzx6rv9n.js → blockDiagram-BEXU5L5S-ycn78fcq.js} +4 -4
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-7f00skch.js → c4Diagram-YGBWAQC7-vn2gpjfm.js} +5 -5
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-j79v95nc.js → classDiagram-v2-NBCMYWYE-fyrm1pr5.js} +4 -4
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-5fkn7ee5.js → cose-bilkent-JH36ORCC-ea5nwvgq.js} +1 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-a4t8992q.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-cfs1yvrd.js → cynefinDiagram-VND7K2PF-j6bsjpre.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-44bgc48p.js → dagre-6A5THRUB-4smdkwv8.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-a4g4x83k.js → diagram-22UHCM2B-9sm4kqwc.js} +11 -11
- package/dist/client/static/js/{diagram-3UASUU5V-gm4rg5na.js → diagram-3UASUU5V-2h3qxaed.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-a95y41vk.js → diagram-ATOU4E4O-1981bc94.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-t3j93mmc.js → diagram-CDSNMT55-3vgsxavc.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-c2wdez02.js → diagram-MLGK6HIB-c9gf2r3f.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-gya9jhs5.js → diagram-MPIPVDR6-gjqeq92d.js} +2 -2
- package/dist/client/static/js/{dockerfile-a7q6174s.js → dockerfile-8v935dkn.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jjhkza6t.js → ebnfDiagram-ZINNZB2B-4vbsgh99.js} +1 -1
- package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-vcbg60wv.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-f7re45mw.js → elk-276RUBZZ-nca3t891.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-tpm9g5te.js → erDiagram-OPXOYQCR-5kfkev03.js} +2 -2
- package/dist/client/static/js/eventmodeling-NTZA5JFV-18bdrkv5.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-fg0yqx0h.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-fz43n12d.js → ganttDiagram-FUAMR5RP-mxc73wmq.js} +3 -3
- package/dist/client/static/js/gitGraph-4MIJSDKK-8fa6y40p.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-f61hgbn6.js → gitGraphDiagram-X574FWY7-7en3ag0e.js} +12 -12
- package/dist/client/static/js/html-dbrwss36.js +1 -0
- package/dist/client/static/js/{index-m73za75e.js → index-0vm41je9.js} +3 -3
- package/dist/client/static/js/{index-eyzeya95.js → index-1b0t1428.js} +5 -5
- package/dist/client/static/js/{index-2x5f66t6.js → index-1ksg88qf.js} +1 -1
- package/dist/client/static/js/{index-sffjtm5w.js → index-231241f4.js} +9 -9
- package/dist/client/static/js/index-2mx9ej4k.css +1 -0
- package/dist/client/static/js/{index-8239j2v1.js → index-4g46wbdw.js} +1 -1
- package/dist/client/static/js/{index-1xqs14fr.js → index-4qwzxj81.js} +1 -1
- package/dist/client/static/js/{index-gcs49f3p.js → index-52rqxgya.js} +1 -1
- package/dist/client/static/js/{index-at6bhjyf.js → index-6sf2vsp2.js} +1 -1
- package/dist/client/static/js/{index-q2w6s8n7.js → index-7a64yjrm.js} +4 -4
- package/dist/client/static/js/{index-rg8jpbsw.js → index-8acv5b77.js} +2 -2
- package/dist/client/static/js/{index-js7t1vb1.js → index-a0fmsv1d.js} +5 -5
- package/dist/client/static/js/{index-w0fwb80e.js → index-ag2rmtas.js} +1 -1
- package/dist/client/static/js/{index-djmg1d7h.js → index-b29afsjh.js} +1 -1
- package/dist/client/static/js/{index-e4p4cd3r.js → index-c3ek61zv.js} +1 -1
- package/dist/client/static/js/{index-0e40xskg.js → index-cd65zqba.js} +1 -1
- package/dist/client/static/js/{index-zt75xpq0.js → index-cgzrpvzj.js} +204 -204
- package/dist/client/static/js/{index-0n5wwe60.js → index-ev3yt353.js} +2 -2
- package/dist/client/static/js/{index-9y3gjdj7.js → index-eyfcm0cy.js} +1 -1
- package/dist/client/static/js/{index-qsm2z36d.js → index-f7jhhqtk.js} +1 -1
- package/dist/client/static/js/{index-vw5k8csz.js → index-fta1y9pc.js} +50 -50
- package/dist/client/static/js/{index-ajs3jj6j.js → index-fvmfge3p.js} +1 -1
- package/dist/client/static/js/{index-pxv2nw9w.js → index-g2dyfze9.js} +1 -1
- package/dist/client/static/js/{index-bkye8mz4.js → index-h5bn97p6.js} +1 -1
- package/dist/client/static/js/{index-trm9x02n.js → index-j51d5a5m.js} +6 -6
- package/dist/client/static/js/{index-pbe4yed4.js → index-jsyekbx9.js} +2 -2
- package/dist/client/static/js/{index-gs6f0qwa.js → index-nccwxv0s.js} +2 -2
- package/dist/client/static/js/{index-d495kfm0.js → index-p0nz38bm.js} +1 -1
- package/dist/client/static/js/{index-sdtye3jy.js → index-pm6xxwz1.js} +2 -2
- package/dist/client/static/js/{index-3rcjx70v.js → index-ptcrwswj.js} +1 -1
- package/dist/client/static/js/{index-14vndmcr.js → index-ptcwae2n.js} +1 -1
- package/dist/client/static/js/{index-5tgq7aqx.js → index-r014brzs.js} +2 -2
- package/dist/client/static/js/{index-xj9649ac.js → index-ray2czf6.js} +7 -7
- package/dist/client/static/js/{index-apvkd37e.js → index-rs80cwsv.js} +3 -3
- package/dist/client/static/js/{index-vw4brsdx.js → index-rzxcj7cg.js} +1 -1
- package/dist/client/static/js/{index-a293pdg7.js → index-s7gkkkyz.js} +2 -2
- package/dist/client/static/js/{index-1a0zkj8h.js → index-sd66wv26.js} +2 -2
- package/dist/client/static/js/{index-ypx3qmhq.js → index-vhqe0y82.js} +1 -1
- package/dist/client/static/js/{index-9fjt5anh.js → index-vy6termr.js} +1 -1
- package/dist/client/static/js/{index-0tf0arsp.js → index-xx6mqpxm.js} +3 -3
- package/dist/client/static/js/{index-03h3bkcf.js → index-ybm2x4vh.js} +1 -1
- package/dist/client/static/js/info-A6RAGUB7-3hk844f7.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-1qj804sn.js → infoDiagram-VRGFBTTK-sef80132.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-4j4qsnzw.js → ishikawaDiagram-OU5B5YK6-yhvepp1q.js} +6 -6
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-j0brnfft.js → journeyDiagram-ZHPQQLJL-5w77y95w.js} +5 -5
- package/dist/client/static/js/{julia-4ghmfy3e.js → julia-d4j6wgvf.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-qqc22br0.js → kanban-definition-PNTS6WVX-02znqtna.js} +6 -6
- package/dist/client/static/js/{mermaid.core-vv3wbe65.js → mermaid.core-a6e6vck4.js} +5 -5
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y5b2z8zp.js → mindmap-definition-NLK3R4M7-y4n74q9x.js} +8 -8
- package/dist/client/static/js/one-dark-pro-vwhfpzr8.js +1 -0
- package/dist/client/static/js/one-light-y5t9x6zh.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-4nj2yy10.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-0be07mqs.js → pegDiagram-GJSIUBJH-pr7ehgzb.js} +1 -1
- package/dist/client/static/js/{perl-sd00t4b4.js → perl-srptw5vm.js} +1 -1
- package/dist/client/static/js/{php-2zfyqa61.js → php-n89g3fk7.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-k7rde3f9.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-544w86jk.js → pieDiagram-5QR66LMP-39wpsk08.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-p09e7z5s.js → quadrantDiagram-O4NWA36T-esm913km.js} +5 -5
- package/dist/client/static/js/radar-RG4KPBEZ-513dpw4f.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-9bqnst9c.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-7367d5bv.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-b806b1mj.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-5a67rwf8.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-de830ed2.js → railroadDiagram-XR7U4H2S-wy2mgya6.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b47d74p1.js → requirementDiagram-PLB6GJNP-6z9xdgbq.js} +2 -2
- package/dist/client/static/js/{ruby-v9qaqhby.js → ruby-r81ytgcm.js} +1 -1
- package/dist/client/static/js/{rust-fkt0qyrs.js → rust-frn3szvc.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-6ezc2fpj.js → sankeyDiagram-IPEJSGJF-rtmxk3ys.js} +4 -4
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-by5zqj6w.js → sequenceDiagram-PO4LG4MO-awzcrafg.js} +18 -18
- package/dist/client/static/js/{sizeCapture-INFHLROL-q85r06j6.js → sizeCapture-INFHLROL-03gy196j.js} +1 -1
- package/dist/client/static/js/sql-0e9mnrda.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-ep5pyexs.js → stateDiagram-v2-GCMORJYK-an8v3q5n.js} +3 -3
- package/dist/client/static/js/{swimlanes-2SLR337P-95fcqkh8.js → swimlanes-2SLR337P-n9yb4wcs.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-xs2en5dv.js → swimlanesDiagram-TC7HE7FX-nx5nfnf0.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-461e615g.js → timeline-definition-EJHVYXUP-jceb575g.js} +4 -4
- package/dist/client/static/js/treeView-Q6P3EWNA-kcy40evb.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-fsrvqxf4.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ftqfnvhg.js → usecaseDiagram-POWQR4AR-888h3100.js} +13 -13
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-7t96h6ez.js → vennDiagram-UO4OBE2U-wbfz0rzv.js} +7 -7
- package/dist/client/static/js/{vue-j8vb9d7r.js → vue-c0rtg1wf.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-36dmxww4.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-0de8w8c6.js → wardleyDiagram-VNRHLVJA-rn8c5qf9.js} +4 -4
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-dez9phkf.js → xychartDiagram-PMCCYNJV-8sn1apt6.js} +5 -5
- package/package.json +4 -1
- package/src/client/components/auth/login-screen/index.tsx +1 -0
- package/src/client/components/common/MarkdownRenderer.tsx +9 -12
- package/src/client/components/settings/Modal.tsx +14 -84
- package/src/client/components/settings/Sidebar.tsx +3 -1
- package/src/client/components/settings/categories/ConnectSettings.tsx +105 -0
- package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +145 -0
- package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +160 -0
- package/src/client/components/settings/categories/connect-settings/QrCode.tsx +73 -0
- package/src/client/components/settings/categories/connect-settings/ServerCard.tsx +94 -0
- package/src/client/components/settings/categories/connect-settings/TunnelRow.tsx +127 -0
- package/src/client/components/settings/category-content.tsx +116 -0
- package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.test.tsx +120 -0
- package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +56 -20
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +1 -0
- package/src/client/hooks/chat/timeline/change-stats.ts +57 -0
- package/src/client/hooks/connect/use-connect-status.ts +116 -0
- package/src/client/hooks/connect/use-pairing.ts +100 -0
- package/src/client/hooks/ui/clipboard.ts +26 -0
- package/src/client/tailwind.css +5 -0
- package/src/server/index.ts +2 -0
- package/src/server/lib/assets/font-css.server.test.ts +19 -0
- package/src/server/lib/auth/client-address.test.ts +58 -0
- package/src/server/lib/auth/client-address.ts +37 -3
- package/src/server/lib/auth/guard.ts +31 -4
- package/src/server/lib/auth/rate-limit.test.ts +25 -8
- package/src/server/lib/auth/rate-limit.ts +8 -5
- package/src/server/lib/connect/cloudflared.lifecycle.test.ts +88 -0
- package/src/server/lib/connect/cloudflared.server.test.ts +65 -0
- package/src/server/lib/connect/cloudflared.server.ts +206 -0
- package/src/server/lib/connect/devices.server.ts +192 -0
- package/src/server/lib/connect/identity.server.ts +81 -0
- package/src/server/lib/connect/pairing.server.test.ts +56 -0
- package/src/server/lib/connect/pairing.server.ts +113 -0
- package/src/server/lib/connect/qr.roundtrip.test.ts +106 -0
- package/src/server/lib/connect/qr.server.ts +36 -0
- package/src/server/lib/connect/run.server.ts +101 -0
- package/src/server/lib/connect/status.server.ts +177 -0
- package/src/server/lib/connect/tailscale.server.test.ts +117 -0
- package/src/server/lib/connect/tailscale.server.ts +172 -0
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/omp/session/changes.test.ts +64 -1
- package/src/server/lib/omp/session/changes.ts +94 -1
- package/src/server/routes/connect/devices.ts +56 -0
- package/src/server/routes/connect/index.ts +15 -0
- package/src/server/routes/connect/pair-page.ts +177 -0
- package/src/server/routes/connect/pair.ts +158 -0
- package/src/server/routes/connect/status.ts +19 -0
- package/src/server/routes/connect/tunnels.ts +76 -0
- package/src/server/routes/health/probe.ts +5 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/sessions/changes.test.ts +12 -3
- package/src/server/routes/sessions/changes.ts +27 -3
- package/src/server/routes/sessions/index.ts +2 -1
- package/src/shared/lib/connect/payload.test.ts +144 -0
- package/src/shared/lib/connect/payload.ts +229 -0
- package/src/shared/lib/connect/tier.test.ts +73 -0
- package/src/shared/lib/connect/tier.ts +105 -0
- package/src/shared/lib/connect/types.ts +99 -0
- package/src/shared/lib/markdown/fira-code-fonts.css +65 -6
- package/src/shared/lib/markdown/marked.ts +7 -4
- package/src/shared/lib/markdown/mermaid-actions.test.ts +78 -0
- package/src/shared/lib/markdown/mermaid-actions.ts +45 -0
- package/src/shared/lib/markdown/mermaid.ts +41 -7
- package/src/shared/lib/settings/sections.ts +6 -1
- package/src/shared/types/session-changes.ts +6 -0
- package/src/shared/types/settings/state.ts +2 -0
- package/dist/client/static/js/Modal-qtftcp2t.js +0 -38
- package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +0 -1
- package/dist/client/static/js/html-pv88ny12.js +0 -1
- package/dist/client/static/js/index-e94a1en0.css +0 -1
- package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +0 -1
- package/dist/client/static/js/one-dark-pro-hm3f56n1.js +0 -1
- package/dist/client/static/js/one-light-xrz49rct.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +0 -1
- package/dist/client/static/js/sql-g8wcshpc.js +0 -1
- package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LucideIcon } from 'lucide-preact';
|
|
2
|
-
import { BarChart3, Bell, BookOpen, Bot, Boxes, Cloud, Coins, Cpu, FolderGit, Keyboard, Library, MessageSquare, Palette, Plug, Power, Puzzle, RefreshCw, Search, Sliders, Terminal, Waypoints, X } from 'lucide-preact';
|
|
2
|
+
import { BarChart3, Bell, BookOpen, Bot, Boxes, Cloud, Coins, Cpu, FolderGit, Keyboard, Library, MessageSquare, Palette, Plug, Power, Puzzle, Radio, RefreshCw, Search, Sliders, Terminal, Waypoints, X } from 'lucide-preact';
|
|
3
3
|
import { HarnessGlyph } from '@/client/components/common/harness-glyph';
|
|
4
4
|
import type { SettingsCategoryId } from '@/shared/types';
|
|
5
5
|
import { SETTINGS_SECTIONS, type SettingsSection } from '@/shared/lib/settings/sections';
|
|
@@ -28,6 +28,8 @@ export const SETTINGS_CATEGORIES: CategoryDef[] = [
|
|
|
28
28
|
{ id: 'usage', label: 'Usage', icon: BarChart3, section: 'KABMO', description: 'Build minutes quota, storage, and general usage.' },
|
|
29
29
|
{ id: 'token-usage', label: 'Token Usage', icon: Coins, section: 'KABMO', description: 'Token telemetry, cache, and cost breakdown.' },
|
|
30
30
|
{ id: 'panel-plugins', label: 'Plugins Kabmo', icon: Puzzle, section: 'KABMO', description: 'Plugins installed into Kabmo: panels, background services, and the MCP servers they register.' },
|
|
31
|
+
// CONNECT
|
|
32
|
+
{ id: 'connect', label: 'Connect', icon: Radio, section: 'CONNECT', description: 'Tunnels, addresses, and the devices paired to this server.' },
|
|
31
33
|
// WORKSPACE
|
|
32
34
|
{ id: 'projects', label: 'Projects', icon: FolderGit, section: 'WORKSPACE', description: 'Workspace directories, roots, and ignored paths.' },
|
|
33
35
|
// OMP
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Settings → Connect.
|
|
8
|
+
*
|
|
9
|
+
* Three blocks, one page: this server's identity and addresses, the two tunnel
|
|
10
|
+
* providers, and the devices that have been paired. No master-detail, because
|
|
11
|
+
* there is nothing to drill into — the only list is the device table, and it is
|
|
12
|
+
* short by construction (a person pairs a handful of devices, not hundreds).
|
|
13
|
+
*
|
|
14
|
+
* The page's job is to make the route order visible. Tailscale is the preferred
|
|
15
|
+
* route even on the same network: it is a direct WireGuard peer connection, so
|
|
16
|
+
* it costs a fraction of a millisecond over the LAN address, and it is the only
|
|
17
|
+
* one of the two that gives the page a secure origin — which is what keeps
|
|
18
|
+
* dictation, clipboard read and the service worker working. The LAN row is the
|
|
19
|
+
* fallback for a device with no tailnet, and it says so when it cannot answer.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
23
|
+
import { useConnectStatus } from '@/client/hooks/connect/use-connect-status';
|
|
24
|
+
import { usePairing } from '@/client/hooks/connect/use-pairing';
|
|
25
|
+
import { ServerCard } from '@/client/components/settings/categories/connect-settings/ServerCard';
|
|
26
|
+
import { TunnelRow } from '@/client/components/settings/categories/connect-settings/TunnelRow';
|
|
27
|
+
import { DeviceTable } from '@/client/components/settings/categories/connect-settings/DeviceTable';
|
|
28
|
+
import { PairDialog } from '@/client/components/settings/categories/connect-settings/PairDialog';
|
|
29
|
+
|
|
30
|
+
export function ConnectSettings() {
|
|
31
|
+
const { status, error, busy, refresh, setTunnel, revoke } = useConnectStatus();
|
|
32
|
+
const pairing = usePairing();
|
|
33
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
34
|
+
|
|
35
|
+
const openDialog = useCallback(() => {
|
|
36
|
+
setDialogOpen(true);
|
|
37
|
+
void pairing.create();
|
|
38
|
+
}, [pairing]);
|
|
39
|
+
|
|
40
|
+
const closeDialog = useCallback(() => {
|
|
41
|
+
setDialogOpen(false);
|
|
42
|
+
pairing.reset();
|
|
43
|
+
// A device that paired while the dialog was open appears on the next read;
|
|
44
|
+
// the dialog has no way to know, so the page asks once it closes.
|
|
45
|
+
void refresh();
|
|
46
|
+
}, [pairing, refresh]);
|
|
47
|
+
|
|
48
|
+
if (!status) {
|
|
49
|
+
return (
|
|
50
|
+
<div className="mx-auto w-full max-w-3xl">
|
|
51
|
+
<p className="text-[11px] text-ink/60">{error ?? 'Reading the connection state…'}</p>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className="mx-auto w-full max-w-3xl space-y-4">
|
|
58
|
+
<p className="text-[11px] leading-relaxed text-ink/60">
|
|
59
|
+
Reach this server from your phone or another desktop without typing an address or a password.
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
{error && (
|
|
63
|
+
<p className="rounded-lg border border-ink/10 bg-ink/[0.03] px-3 py-2 text-[11px] leading-relaxed text-ink/70">
|
|
64
|
+
{error}
|
|
65
|
+
</p>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
<ServerCard status={status} />
|
|
69
|
+
|
|
70
|
+
<section className="rounded-xl border border-ink/10 bg-paper">
|
|
71
|
+
<header className="border-b border-ink/10 px-4 py-3">
|
|
72
|
+
<h4 className="text-sm font-semibold text-ink">Tunnels</h4>
|
|
73
|
+
</header>
|
|
74
|
+
<div className="divide-y divide-ink/10">
|
|
75
|
+
{status.tunnels.map((tunnel) => (
|
|
76
|
+
<TunnelRow
|
|
77
|
+
key={tunnel.provider}
|
|
78
|
+
tunnel={tunnel}
|
|
79
|
+
busy={busy === `${tunnel.provider}:start` || busy === `${tunnel.provider}:stop`}
|
|
80
|
+
onToggle={(next) => void setTunnel(tunnel.provider, next)}
|
|
81
|
+
/>
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
</section>
|
|
85
|
+
|
|
86
|
+
<DeviceTable
|
|
87
|
+
devices={status.devices}
|
|
88
|
+
busy={busy}
|
|
89
|
+
onRevoke={(id) => void revoke(id)}
|
|
90
|
+
onAdd={openDialog}
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
{dialogOpen && (
|
|
94
|
+
<PairDialog
|
|
95
|
+
code={pairing.code}
|
|
96
|
+
error={pairing.error}
|
|
97
|
+
busy={pairing.busy}
|
|
98
|
+
secondsLeft={pairing.secondsLeft}
|
|
99
|
+
onClose={closeDialog}
|
|
100
|
+
onRetry={() => void pairing.create()}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The paired devices, and the one action that matters on each row.
|
|
8
|
+
*
|
|
9
|
+
* The route and round trip are what the DEVICE reported, not something the
|
|
10
|
+
* server measured — it cannot measure a phone's latency. Showing them is what
|
|
11
|
+
* makes the fallback order visible: a phone on Tailscale at home and the same
|
|
12
|
+
* phone on Cloudflare at a café are two different rows of the same device, and
|
|
13
|
+
* the user can see which one it is using right now.
|
|
14
|
+
*
|
|
15
|
+
* A table on a desktop, stacked rows on a phone. The columns are the same facts
|
|
16
|
+
* in both; only the arrangement changes, because a horizontally scrolling table
|
|
17
|
+
* on a phone hides the revoke button off-screen.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { Trash2 } from 'lucide-preact';
|
|
21
|
+
import type { PairedDevice } from '@/shared/lib/connect/types';
|
|
22
|
+
|
|
23
|
+
const ROUTE_LABEL: Record<NonNullable<PairedDevice['route']>, string> = {
|
|
24
|
+
tailscale: 'Tailscale',
|
|
25
|
+
lan: 'LAN',
|
|
26
|
+
cloudflare: 'Cloudflare',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function relative(iso: string | null): string {
|
|
30
|
+
if (!iso) return 'never';
|
|
31
|
+
const then = Date.parse(iso);
|
|
32
|
+
if (!Number.isFinite(then)) return 'never';
|
|
33
|
+
const seconds = Math.max(0, Math.round((Date.now() - then) / 1000));
|
|
34
|
+
if (seconds < 60) return 'just now';
|
|
35
|
+
const minutes = Math.round(seconds / 60);
|
|
36
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
37
|
+
const hours = Math.round(minutes / 60);
|
|
38
|
+
if (hours < 24) return `${hours} h ago`;
|
|
39
|
+
return `${Math.round(hours / 24)} d ago`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface DeviceTableProps {
|
|
43
|
+
devices: PairedDevice[];
|
|
44
|
+
busy: string | null;
|
|
45
|
+
onRevoke: (id: string) => void;
|
|
46
|
+
onAdd: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function DeviceTable({ devices, busy, onRevoke, onAdd }: DeviceTableProps) {
|
|
50
|
+
return (
|
|
51
|
+
<section className="rounded-xl border border-ink/10 bg-paper">
|
|
52
|
+
<header className="flex items-center justify-between gap-2 border-b border-ink/10 px-4 py-3">
|
|
53
|
+
<h4 className="text-sm font-semibold text-ink">Paired devices</h4>
|
|
54
|
+
<button
|
|
55
|
+
type="button"
|
|
56
|
+
onClick={onAdd}
|
|
57
|
+
className="rounded-lg border border-ink/15 px-2.5 py-1 text-[11px] font-semibold text-ink transition-colors hover:bg-ink/5"
|
|
58
|
+
>
|
|
59
|
+
Add a device
|
|
60
|
+
</button>
|
|
61
|
+
</header>
|
|
62
|
+
|
|
63
|
+
{devices.length === 0 ? (
|
|
64
|
+
<div className="px-4 py-6">
|
|
65
|
+
<p className="text-[11px] leading-relaxed text-ink/60">
|
|
66
|
+
No device has been paired yet. Add one to reach this server from your phone without typing an
|
|
67
|
+
address or a password.
|
|
68
|
+
</p>
|
|
69
|
+
</div>
|
|
70
|
+
) : (
|
|
71
|
+
<>
|
|
72
|
+
{/* Desktop: one row per device. */}
|
|
73
|
+
<table className="hidden w-full md:table">
|
|
74
|
+
<thead>
|
|
75
|
+
<tr className="text-left text-[10px] font-bold uppercase tracking-wider text-ink/40">
|
|
76
|
+
<th className="px-4 py-2 font-bold">Device</th>
|
|
77
|
+
<th className="px-2 py-2 font-bold">Platform</th>
|
|
78
|
+
<th className="px-2 py-2 font-bold">Route</th>
|
|
79
|
+
<th className="px-2 py-2 font-bold">RTT</th>
|
|
80
|
+
<th className="px-2 py-2 font-bold">Last seen</th>
|
|
81
|
+
<th className="px-4 py-2" />
|
|
82
|
+
</tr>
|
|
83
|
+
</thead>
|
|
84
|
+
<tbody>
|
|
85
|
+
{devices.map((device) => (
|
|
86
|
+
<tr key={device.id} className="border-t border-ink/5">
|
|
87
|
+
<td className="px-4 py-2 text-[12px] font-medium text-ink">{device.name}</td>
|
|
88
|
+
<td className="px-2 py-2 text-[11px] text-ink/70">{device.platform}</td>
|
|
89
|
+
<td className="px-2 py-2 text-[11px] text-ink/70">
|
|
90
|
+
{device.route ? ROUTE_LABEL[device.route] : '—'}
|
|
91
|
+
</td>
|
|
92
|
+
<td className="px-2 py-2 font-mono text-[11px] tabular-nums text-ink/70">
|
|
93
|
+
{device.rttMs === null ? '—' : `${device.rttMs} ms`}
|
|
94
|
+
</td>
|
|
95
|
+
<td className="px-2 py-2 text-[11px] text-ink/60">{relative(device.lastSeenAt)}</td>
|
|
96
|
+
<td className="px-4 py-2 text-right">
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
onClick={() => onRevoke(device.id)}
|
|
100
|
+
disabled={busy === `device:${device.id}`}
|
|
101
|
+
aria-label={`Revoke ${device.name}`}
|
|
102
|
+
className="rounded-md p-1 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50"
|
|
103
|
+
>
|
|
104
|
+
<Trash2 size={13} />
|
|
105
|
+
</button>
|
|
106
|
+
</td>
|
|
107
|
+
</tr>
|
|
108
|
+
))}
|
|
109
|
+
</tbody>
|
|
110
|
+
</table>
|
|
111
|
+
|
|
112
|
+
{/* Phone: the same facts, stacked. */}
|
|
113
|
+
<ul className="divide-y divide-ink/5 md:hidden">
|
|
114
|
+
{devices.map((device) => (
|
|
115
|
+
<li key={device.id} className="flex items-start justify-between gap-3 px-4 py-3">
|
|
116
|
+
<div className="min-w-0">
|
|
117
|
+
<div className="text-[12px] font-medium text-ink">{device.name}</div>
|
|
118
|
+
<div className="mt-0.5 text-[11px] text-ink/60">
|
|
119
|
+
{device.platform}
|
|
120
|
+
{device.route ? ` · ${ROUTE_LABEL[device.route]}` : ''}
|
|
121
|
+
{device.rttMs === null ? '' : ` · ${device.rttMs} ms`}
|
|
122
|
+
{` · ${relative(device.lastSeenAt)}`}
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<button
|
|
126
|
+
type="button"
|
|
127
|
+
onClick={() => onRevoke(device.id)}
|
|
128
|
+
disabled={busy === `device:${device.id}`}
|
|
129
|
+
aria-label={`Revoke ${device.name}`}
|
|
130
|
+
className="flex-shrink-0 rounded-md p-1.5 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50"
|
|
131
|
+
>
|
|
132
|
+
<Trash2 size={14} />
|
|
133
|
+
</button>
|
|
134
|
+
</li>
|
|
135
|
+
))}
|
|
136
|
+
</ul>
|
|
137
|
+
</>
|
|
138
|
+
)}
|
|
139
|
+
|
|
140
|
+
<p className="border-t border-ink/10 px-4 py-2.5 text-[11px] leading-relaxed text-ink/55">
|
|
141
|
+
Each device holds its own token. Revoking cuts it off immediately; pair it again with a new code.
|
|
142
|
+
</p>
|
|
143
|
+
</section>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The pairing dialog: one QR, its clock, and the routes it carries.
|
|
8
|
+
*
|
|
9
|
+
* PORTALED TO `<body>`, not positioned inside the settings panel. The panel is
|
|
10
|
+
* `overflow-hidden` and the composer card can become a containing block for
|
|
11
|
+
* `position: fixed` through `backdrop-filter`, a `transform` or `contain:
|
|
12
|
+
* layout` — either one clips or mis-sizes a nested overlay, and the dialog then
|
|
13
|
+
* opens in front of the wrong thing. `createPortal` is the rule the Goal dialog
|
|
14
|
+
* already follows for the same reason.
|
|
15
|
+
*
|
|
16
|
+
* The routes are listed because the code carries all of them: a phone that
|
|
17
|
+
* cannot reach the LAN address still pairs over Tailscale, and the user should
|
|
18
|
+
* be able to see that before scanning.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useEffect } from 'preact/hooks';
|
|
22
|
+
import { createPortal } from 'preact/compat';
|
|
23
|
+
import { X } from 'lucide-preact';
|
|
24
|
+
import { QrCode } from '@/client/components/settings/categories/connect-settings/QrCode';
|
|
25
|
+
import type { PairingCode } from '@/client/hooks/connect/use-pairing';
|
|
26
|
+
|
|
27
|
+
const ROUTE_LABEL: Record<string, string> = {
|
|
28
|
+
tailscale: 'Tailscale',
|
|
29
|
+
lan: 'LAN',
|
|
30
|
+
cloudflare: 'Cloudflare',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export interface PairDialogProps {
|
|
34
|
+
code: PairingCode | null;
|
|
35
|
+
error: string | null;
|
|
36
|
+
busy: boolean;
|
|
37
|
+
secondsLeft: number;
|
|
38
|
+
onClose: () => void;
|
|
39
|
+
onRetry: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function clock(seconds: number): string {
|
|
43
|
+
const minutes = Math.floor(seconds / 60);
|
|
44
|
+
const rest = seconds % 60;
|
|
45
|
+
return `${minutes}:${String(rest).padStart(2, '0')}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function PairDialog({ code, error, busy, secondsLeft, onClose, onRetry }: PairDialogProps) {
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const onKey = (event: KeyboardEvent) => {
|
|
51
|
+
if (event.key === 'Escape') onClose();
|
|
52
|
+
};
|
|
53
|
+
window.addEventListener('keydown', onKey);
|
|
54
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
55
|
+
}, [onClose]);
|
|
56
|
+
|
|
57
|
+
const expired = code !== null && secondsLeft === 0;
|
|
58
|
+
|
|
59
|
+
return createPortal(
|
|
60
|
+
<div
|
|
61
|
+
className="fixed inset-0 z-[60] flex items-center justify-center bg-ink/40 p-4 backdrop-blur-[2px]"
|
|
62
|
+
onClick={onClose}
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
role="dialog"
|
|
66
|
+
aria-modal="true"
|
|
67
|
+
aria-label="Add a device"
|
|
68
|
+
className="w-full max-w-md rounded-2xl border border-ink/15 bg-paper p-5 shadow-2xl"
|
|
69
|
+
onClick={(event) => event.stopPropagation()}
|
|
70
|
+
>
|
|
71
|
+
<div className="mb-3 flex items-start justify-between gap-3">
|
|
72
|
+
<div>
|
|
73
|
+
<h3 className="text-sm font-semibold text-ink">Add a device</h3>
|
|
74
|
+
<p className="mt-0.5 text-[11px] text-ink/60">Scan with Kabmo on your phone.</p>
|
|
75
|
+
</div>
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
onClick={onClose}
|
|
79
|
+
aria-label="Close"
|
|
80
|
+
className="rounded-lg p-1 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink"
|
|
81
|
+
>
|
|
82
|
+
<X size={16} />
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
{error && (
|
|
87
|
+
<p className="mb-3 rounded-lg border border-ink/10 bg-ink/[0.03] px-3 py-2 text-[11px] leading-relaxed text-ink/70">
|
|
88
|
+
{error}
|
|
89
|
+
</p>
|
|
90
|
+
)}
|
|
91
|
+
|
|
92
|
+
{busy && !code && <p className="py-10 text-center text-[11px] text-ink/60">Creating a code…</p>}
|
|
93
|
+
|
|
94
|
+
{code && (
|
|
95
|
+
<>
|
|
96
|
+
<div className={`flex justify-center ${expired ? 'opacity-30' : ''}`}>
|
|
97
|
+
<QrCode matrix={code.qr} label="Pairing QR code" />
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<p className="mt-3 text-center text-[11px] text-ink/60">
|
|
101
|
+
{expired ? (
|
|
102
|
+
'This code has expired.'
|
|
103
|
+
) : (
|
|
104
|
+
<>
|
|
105
|
+
Expires in <span className="font-mono tabular-nums text-ink">{clock(secondsLeft)}</span> · works once
|
|
106
|
+
</>
|
|
107
|
+
)}
|
|
108
|
+
</p>
|
|
109
|
+
|
|
110
|
+
<div className="mt-4">
|
|
111
|
+
<div className="mb-1.5 text-[10px] font-bold uppercase tracking-wider text-ink/40">
|
|
112
|
+
Routes in this code
|
|
113
|
+
</div>
|
|
114
|
+
<ul className="space-y-1">
|
|
115
|
+
{code.candidates.map((candidate) => (
|
|
116
|
+
<li key={`${candidate.kind}:${candidate.url}`} className="flex items-baseline gap-2">
|
|
117
|
+
<span aria-hidden="true" className="mt-1.5 h-1.5 w-1.5 flex-shrink-0 rounded-full bg-ink" />
|
|
118
|
+
<span className="w-[74px] flex-shrink-0 text-[11px] font-semibold text-ink">
|
|
119
|
+
{ROUTE_LABEL[candidate.kind] ?? candidate.kind}
|
|
120
|
+
</span>
|
|
121
|
+
<span className="truncate font-mono text-[11px] text-ink/70">{candidate.url}</span>
|
|
122
|
+
</li>
|
|
123
|
+
))}
|
|
124
|
+
</ul>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div className="mt-4 flex items-center justify-between gap-2">
|
|
128
|
+
<button
|
|
129
|
+
type="button"
|
|
130
|
+
onClick={() => void navigator.clipboard?.writeText(code.webLink).catch(() => {})}
|
|
131
|
+
className="rounded-lg border border-ink/15 px-2.5 py-1.5 text-[11px] font-semibold text-ink transition-colors hover:bg-ink/5"
|
|
132
|
+
>
|
|
133
|
+
Copy link
|
|
134
|
+
</button>
|
|
135
|
+
<div className="flex items-center gap-2">
|
|
136
|
+
{expired && (
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
onClick={onRetry}
|
|
140
|
+
className="rounded-lg border border-ink/15 px-2.5 py-1.5 text-[11px] font-semibold text-ink transition-colors hover:bg-ink/5"
|
|
141
|
+
>
|
|
142
|
+
New code
|
|
143
|
+
</button>
|
|
144
|
+
)}
|
|
145
|
+
<button
|
|
146
|
+
type="button"
|
|
147
|
+
onClick={onClose}
|
|
148
|
+
className="rounded-lg bg-ink px-3 py-1.5 text-[11px] font-semibold text-paper transition-opacity hover:opacity-90"
|
|
149
|
+
>
|
|
150
|
+
Done
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
</>
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
157
|
+
</div>,
|
|
158
|
+
document.body,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The pairing QR, drawn from the server's module matrix.
|
|
8
|
+
*
|
|
9
|
+
* A matrix rather than an SVG string from the server: the payload is a deep link
|
|
10
|
+
* carrying a one-time secret, and injecting server-built markup to render it is
|
|
11
|
+
* the shortcut that turns a QR renderer into an injection point. Here the only
|
|
12
|
+
* thing that reaches the DOM is a `<rect>` per dark module.
|
|
13
|
+
*
|
|
14
|
+
* The quiet zone is part of the drawing, not padding on the container: a scanner
|
|
15
|
+
* needs four modules of margin, and a CSS padding that a theme or a layout rule
|
|
16
|
+
* can shrink is a code that scans on one screen and not another.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { JSX } from 'preact';
|
|
20
|
+
import type { QrMatrix } from '@/shared/lib/connect/types';
|
|
21
|
+
|
|
22
|
+
const QUIET_ZONE = 4;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The widest the code is drawn, in CSS pixels.
|
|
26
|
+
*
|
|
27
|
+
* A screenshot of this dialog is what a camera-less device uploads, so the size
|
|
28
|
+
* is a functional choice, not a layout one: at 260 px a ~100-module code is under
|
|
29
|
+
* 3 px per module, and `jsQR` failed to read a real capture of it ("no QR code
|
|
30
|
+
* found") while the same code at 4 px per module decoded every time.
|
|
31
|
+
*/
|
|
32
|
+
const TARGET_EDGE = 340;
|
|
33
|
+
|
|
34
|
+
export function QrCode({ matrix, label }: { matrix: QrMatrix; label: string }) {
|
|
35
|
+
const span = matrix.size + QUIET_ZONE * 2;
|
|
36
|
+
// An INTEGER number of pixels per module. A fractional size makes the browser
|
|
37
|
+
// antialias every module edge, which is exactly what a binarizer cannot read —
|
|
38
|
+
// and it is why the same code scanned from a phone camera but not from a
|
|
39
|
+
// screenshot.
|
|
40
|
+
const modulePx = Math.max(3, Math.floor(TARGET_EDGE / span));
|
|
41
|
+
const edge = span * modulePx;
|
|
42
|
+
const rects: JSX.Element[] = [];
|
|
43
|
+
for (let row = 0; row < matrix.size; row += 1) {
|
|
44
|
+
const line = matrix.rows[row] ?? '';
|
|
45
|
+
for (let column = 0; column < matrix.size; column += 1) {
|
|
46
|
+
if (line[column] !== '1') continue;
|
|
47
|
+
rects.push(
|
|
48
|
+
<rect
|
|
49
|
+
key={`${row}:${column}`}
|
|
50
|
+
x={column + QUIET_ZONE}
|
|
51
|
+
y={row + QUIET_ZONE}
|
|
52
|
+
width={1}
|
|
53
|
+
height={1}
|
|
54
|
+
/>,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<svg
|
|
61
|
+
role="img"
|
|
62
|
+
aria-label={label}
|
|
63
|
+
viewBox={`0 0 ${span} ${span}`}
|
|
64
|
+
width={edge}
|
|
65
|
+
height={edge}
|
|
66
|
+
className="block h-auto max-w-full rounded-lg bg-white"
|
|
67
|
+
shape-rendering="crispEdges"
|
|
68
|
+
>
|
|
69
|
+
<rect x={0} y={0} width={span} height={span} fill="#ffffff" />
|
|
70
|
+
<g fill="#141310">{rects}</g>
|
|
71
|
+
</svg>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This server's identity and the addresses it answers on.
|
|
8
|
+
*
|
|
9
|
+
* The identity is shown because a device pins it: when a phone refuses a server
|
|
10
|
+
* that "looks right", the two ids are what the user compares. The addresses are
|
|
11
|
+
* shown with their reason when they do not work — a LAN row on a loopback-only
|
|
12
|
+
* listener says so, rather than looking like a broken network.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Copy } from 'lucide-preact';
|
|
16
|
+
import type { ConnectAddress, ConnectStatus } from '@/shared/lib/connect/types';
|
|
17
|
+
|
|
18
|
+
const ROUTE_LABEL: Record<ConnectAddress['kind'], string> = {
|
|
19
|
+
tailscale: 'Tailscale',
|
|
20
|
+
lan: 'LAN',
|
|
21
|
+
cloudflare: 'Cloudflare',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function copy(value: string): void {
|
|
25
|
+
void navigator.clipboard?.writeText(value).catch(() => {
|
|
26
|
+
// A clipboard the page cannot reach is not worth a dialog: the address is
|
|
27
|
+
// on screen and selectable.
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ServerCard({ status }: { status: ConnectStatus }) {
|
|
32
|
+
return (
|
|
33
|
+
<section className="rounded-xl border border-ink/10 bg-paper">
|
|
34
|
+
<header className="flex flex-wrap items-baseline justify-between gap-2 border-b border-ink/10 px-4 py-3">
|
|
35
|
+
<div className="min-w-0">
|
|
36
|
+
<h4 className="text-sm font-semibold text-ink">{status.label}</h4>
|
|
37
|
+
<p className="mt-0.5 text-[11px] text-ink/60">kabmo {status.version}</p>
|
|
38
|
+
</div>
|
|
39
|
+
<div className="text-right">
|
|
40
|
+
<div className="text-[10px] font-mono uppercase tracking-wider text-ink/40">server id</div>
|
|
41
|
+
<div className="font-mono text-[11px] text-ink/70" title={status.serverId}>
|
|
42
|
+
{status.serverId.slice(0, 6)}…{status.serverId.slice(-4)}
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</header>
|
|
46
|
+
|
|
47
|
+
<div className="px-4 py-3">
|
|
48
|
+
<div className="mb-2 text-[10px] font-bold uppercase tracking-wider text-ink/40">Addresses</div>
|
|
49
|
+
{status.addresses.length === 0 ? (
|
|
50
|
+
<p className="text-[11px] text-ink/60">
|
|
51
|
+
No address yet. Turn on Tailscale Serve, or start this server with --lan.
|
|
52
|
+
</p>
|
|
53
|
+
) : (
|
|
54
|
+
<ul className="space-y-1.5">
|
|
55
|
+
{status.addresses.map((address) => {
|
|
56
|
+
const usable = address.unavailable === null && address.url !== '';
|
|
57
|
+
return (
|
|
58
|
+
<li key={`${address.kind}:${address.url}`} className="flex items-start gap-2">
|
|
59
|
+
<span
|
|
60
|
+
aria-hidden="true"
|
|
61
|
+
className={`mt-1.5 h-1.5 w-1.5 flex-shrink-0 rounded-full ${usable ? 'bg-ink' : 'bg-ink/25'}`}
|
|
62
|
+
/>
|
|
63
|
+
<div className="min-w-0 flex-1">
|
|
64
|
+
<div className="flex items-baseline gap-2">
|
|
65
|
+
<span className="w-[74px] flex-shrink-0 text-[11px] font-semibold text-ink">
|
|
66
|
+
{ROUTE_LABEL[address.kind]}
|
|
67
|
+
</span>
|
|
68
|
+
<span className={`truncate font-mono text-[11px] ${usable ? 'text-ink/80' : 'text-ink/40'}`}>
|
|
69
|
+
{usable ? address.url : '—'}
|
|
70
|
+
</span>
|
|
71
|
+
</div>
|
|
72
|
+
{address.unavailable && (
|
|
73
|
+
<p className="mt-0.5 pl-[82px] text-[11px] leading-relaxed text-ink/55">{address.unavailable}</p>
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
{usable && (
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
onClick={() => copy(address.url)}
|
|
80
|
+
aria-label={`Copy ${ROUTE_LABEL[address.kind]} address`}
|
|
81
|
+
className="flex-shrink-0 rounded-md p-1 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink"
|
|
82
|
+
>
|
|
83
|
+
<Copy size={13} />
|
|
84
|
+
</button>
|
|
85
|
+
)}
|
|
86
|
+
</li>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
</ul>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
</section>
|
|
93
|
+
);
|
|
94
|
+
}
|