@hanzo/dev 4.0.1 → 4.2.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/LICENSE +21 -0
- package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
- package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
- package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
- package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
- package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
- package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
- package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
- package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
- package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
- package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
- package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
- package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
- package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
- package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
- package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
- package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
- package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
- package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
- package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
- package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
- package/dist/builder/activity.d.ts +16 -0
- package/dist/builder/activity.js +51 -0
- package/dist/builder/address.d.ts +11 -0
- package/dist/builder/address.js +50 -0
- package/dist/builder/ago.d.ts +2 -0
- package/dist/builder/ago.js +18 -0
- package/dist/builder/api/agents.d.ts +139 -0
- package/dist/builder/api/agents.js +253 -0
- package/dist/builder/api/auto.d.ts +166 -0
- package/dist/builder/api/auto.js +300 -0
- package/dist/builder/api/billing.d.ts +263 -0
- package/dist/builder/api/billing.js +401 -0
- package/dist/builder/api/call.d.ts +53 -0
- package/dist/builder/api/call.js +123 -0
- package/dist/builder/api/capabilities.d.ts +14 -0
- package/dist/builder/api/capabilities.js +41 -0
- package/dist/builder/api/changes.d.ts +74 -0
- package/dist/builder/api/changes.js +75 -0
- package/dist/builder/api/chat.d.ts +12 -0
- package/dist/builder/api/chat.js +28 -0
- package/dist/builder/api/cli.d.ts +59 -0
- package/dist/builder/api/cli.js +133 -0
- package/dist/builder/api/codebases.d.ts +46 -0
- package/dist/builder/api/codebases.js +100 -0
- package/dist/builder/api/coding.d.ts +117 -0
- package/dist/builder/api/coding.js +222 -0
- package/dist/builder/api/connectors.d.ts +76 -0
- package/dist/builder/api/connectors.js +111 -0
- package/dist/builder/api/consent.d.ts +22 -0
- package/dist/builder/api/consent.js +28 -0
- package/dist/builder/api/conversations.d.ts +20 -0
- package/dist/builder/api/conversations.js +23 -0
- package/dist/builder/api/draft.d.ts +38 -0
- package/dist/builder/api/draft.js +87 -0
- package/dist/builder/api/environment.d.ts +55 -0
- package/dist/builder/api/environment.js +126 -0
- package/dist/builder/api/gallery.d.ts +32 -0
- package/dist/builder/api/gallery.js +85 -0
- package/dist/builder/api/git.d.ts +59 -0
- package/dist/builder/api/git.js +117 -0
- package/dist/builder/api/github.d.ts +230 -0
- package/dist/builder/api/github.js +373 -0
- package/dist/builder/api/keys.d.ts +35 -0
- package/dist/builder/api/keys.js +72 -0
- package/dist/builder/api/library.d.ts +116 -0
- package/dist/builder/api/library.js +214 -0
- package/dist/builder/api/limits.d.ts +69 -0
- package/dist/builder/api/limits.js +86 -0
- package/dist/builder/api/links.d.ts +51 -0
- package/dist/builder/api/links.js +75 -0
- package/dist/builder/api/machines.d.ts +122 -0
- package/dist/builder/api/machines.js +238 -0
- package/dist/builder/api/mcp.d.ts +10 -0
- package/dist/builder/api/mcp.js +47 -0
- package/dist/builder/api/members.d.ts +35 -0
- package/dist/builder/api/members.js +95 -0
- package/dist/builder/api/memory.d.ts +14 -0
- package/dist/builder/api/memory.js +35 -0
- package/dist/builder/api/models.d.ts +17 -0
- package/dist/builder/api/models.js +20 -0
- package/dist/builder/api/places.d.ts +32 -0
- package/dist/builder/api/places.js +29 -0
- package/dist/builder/api/platform.d.ts +68 -0
- package/dist/builder/api/platform.js +87 -0
- package/dist/builder/api/plugins.d.ts +42 -0
- package/dist/builder/api/plugins.js +175 -0
- package/dist/builder/api/pref.d.ts +77 -0
- package/dist/builder/api/pref.js +93 -0
- package/dist/builder/api/profile.d.ts +11 -0
- package/dist/builder/api/profile.js +41 -0
- package/dist/builder/api/projects.d.ts +99 -0
- package/dist/builder/api/projects.js +166 -0
- package/dist/builder/api/provider.d.ts +49 -0
- package/dist/builder/api/provider.js +96 -0
- package/dist/builder/api/sandbox.d.ts +90 -0
- package/dist/builder/api/sandbox.js +223 -0
- package/dist/builder/api/sessions.d.ts +123 -0
- package/dist/builder/api/sessions.js +255 -0
- package/dist/builder/api/skills.d.ts +82 -0
- package/dist/builder/api/skills.js +117 -0
- package/dist/builder/api/sse.d.ts +24 -0
- package/dist/builder/api/sse.js +68 -0
- package/dist/builder/api/studio.d.ts +59 -0
- package/dist/builder/api/studio.js +91 -0
- package/dist/builder/api/talk.d.ts +48 -0
- package/dist/builder/api/talk.js +81 -0
- package/dist/builder/api/tools.d.ts +34 -0
- package/dist/builder/api/tools.js +37 -0
- package/dist/builder/api/turn.d.ts +202 -0
- package/dist/builder/api/turn.js +772 -0
- package/dist/builder/api/verdict.d.ts +3 -0
- package/dist/builder/api/verdict.js +21 -0
- package/dist/builder/api/webhooks.d.ts +47 -0
- package/dist/builder/api/webhooks.js +82 -0
- package/dist/builder/api/work.d.ts +110 -0
- package/dist/builder/api/work.js +218 -0
- package/dist/builder/ask.d.ts +51 -0
- package/dist/builder/ask.js +147 -0
- package/dist/builder/automations.d.ts +33 -0
- package/dist/builder/automations.js +453 -0
- package/dist/builder/awake.d.ts +24 -0
- package/dist/builder/awake.js +68 -0
- package/dist/builder/back.d.ts +30 -0
- package/dist/builder/back.js +105 -0
- package/dist/builder/builder.d.ts +12 -0
- package/dist/builder/builder.js +162 -0
- package/dist/builder/carry.d.ts +48 -0
- package/dist/builder/carry.js +278 -0
- package/dist/builder/choice.d.ts +134 -0
- package/dist/builder/choice.js +152 -0
- package/dist/builder/claims.d.ts +13 -0
- package/dist/builder/claims.js +35 -0
- package/dist/builder/clipboard.d.ts +2 -0
- package/dist/builder/clipboard.js +10 -0
- package/dist/builder/customize/agents.d.ts +11 -0
- package/dist/builder/customize/agents.js +513 -0
- package/dist/builder/customize/connectors.d.ts +2 -0
- package/dist/builder/customize/connectors.js +319 -0
- package/dist/builder/customize/drafted.d.ts +4 -0
- package/dist/builder/customize/drafted.js +92 -0
- package/dist/builder/customize/index.d.ts +8 -0
- package/dist/builder/customize/index.js +127 -0
- package/dist/builder/customize/inventory.d.ts +14 -0
- package/dist/builder/customize/inventory.js +127 -0
- package/dist/builder/customize/load.d.ts +9 -0
- package/dist/builder/customize/load.js +22 -0
- package/dist/builder/customize/ocean.d.ts +41 -0
- package/dist/builder/customize/ocean.js +332 -0
- package/dist/builder/customize/plugins.d.ts +2 -0
- package/dist/builder/customize/plugins.js +136 -0
- package/dist/builder/customize/roles.d.ts +4 -0
- package/dist/builder/customize/roles.js +105 -0
- package/dist/builder/customize/say.d.ts +13 -0
- package/dist/builder/customize/say.js +32 -0
- package/dist/builder/customize/skills.d.ts +2 -0
- package/dist/builder/customize/skills.js +208 -0
- package/dist/builder/customize/ui.d.ts +152 -0
- package/dist/builder/customize/ui.js +208 -0
- package/dist/builder/data.d.ts +57 -0
- package/dist/builder/data.js +322 -0
- package/dist/builder/design.d.ts +140 -0
- package/dist/builder/design.js +175 -0
- package/dist/builder/desk.d.ts +48 -0
- package/dist/builder/desk.js +449 -0
- package/dist/builder/dev-mode.d.ts +43 -0
- package/dist/builder/dev-mode.js +120 -0
- package/dist/builder/door.d.ts +11 -0
- package/dist/builder/door.js +126 -0
- package/dist/builder/environment.d.ts +23 -0
- package/dist/builder/environment.js +193 -0
- package/dist/builder/files.d.ts +23 -0
- package/dist/builder/files.js +175 -0
- package/dist/builder/find.d.ts +7 -0
- package/dist/builder/find.js +80 -0
- package/dist/builder/foot.d.ts +30 -0
- package/dist/builder/foot.js +79 -0
- package/dist/builder/forge.d.ts +4 -0
- package/dist/builder/forge.js +639 -0
- package/dist/builder/gear.d.ts +60 -0
- package/dist/builder/gear.js +180 -0
- package/dist/builder/git.d.ts +21 -0
- package/dist/builder/git.js +118 -0
- package/dist/builder/github-sync.d.ts +70 -0
- package/dist/builder/github-sync.js +435 -0
- package/dist/builder/gutter.d.ts +17 -0
- package/dist/builder/gutter.js +25 -0
- package/dist/builder/handoff.d.ts +8 -0
- package/dist/builder/handoff.js +22 -0
- package/dist/builder/host.d.ts +189 -0
- package/dist/builder/host.js +46 -0
- package/dist/builder/index.d.ts +108 -0
- package/dist/builder/index.js +99 -0
- package/dist/builder/landing.d.ts +34 -0
- package/dist/builder/landing.js +725 -0
- package/dist/builder/library.d.ts +21 -0
- package/dist/builder/library.js +526 -0
- package/dist/builder/local.d.ts +80 -0
- package/dist/builder/local.js +124 -0
- package/dist/builder/make.d.ts +10 -0
- package/dist/builder/make.js +120 -0
- package/dist/builder/markdown.d.ts +49 -0
- package/dist/builder/markdown.js +125 -0
- package/dist/builder/marks.d.ts +15 -0
- package/dist/builder/marks.js +18 -0
- package/dist/builder/merge.d.ts +223 -0
- package/dist/builder/merge.js +380 -0
- package/dist/builder/meter.d.ts +31 -0
- package/dist/builder/meter.js +54 -0
- package/dist/builder/mind.d.ts +107 -0
- package/dist/builder/mind.js +335 -0
- package/dist/builder/names.d.ts +40 -0
- package/dist/builder/names.js +189 -0
- package/dist/builder/nav.d.ts +28 -0
- package/dist/builder/nav.js +218 -0
- package/dist/builder/out.d.ts +16 -0
- package/dist/builder/out.js +24 -0
- package/dist/builder/page.d.ts +55 -0
- package/dist/builder/page.js +217 -0
- package/dist/builder/pane.d.ts +30 -0
- package/dist/builder/pane.js +21 -0
- package/dist/builder/panel.d.ts +101 -0
- package/dist/builder/panel.js +408 -0
- package/dist/builder/pdf.d.ts +139 -0
- package/dist/builder/pdf.js +847 -0
- package/dist/builder/pick.d.ts +10 -0
- package/dist/builder/pick.js +38 -0
- package/dist/builder/plain.d.ts +59 -0
- package/dist/builder/plain.js +209 -0
- package/dist/builder/plan.d.ts +63 -0
- package/dist/builder/plan.js +155 -0
- package/dist/builder/plans.d.ts +1 -0
- package/dist/builder/plans.js +157 -0
- package/dist/builder/plugin.d.ts +60 -0
- package/dist/builder/plugin.js +1 -0
- package/dist/builder/plugins/design.d.ts +8 -0
- package/dist/builder/plugins/design.js +71 -0
- package/dist/builder/plugins/index.d.ts +46 -0
- package/dist/builder/plugins/index.js +117 -0
- package/dist/builder/plugins/pdf.d.ts +18 -0
- package/dist/builder/plugins/pdf.js +83 -0
- package/dist/builder/plugins/project.d.ts +5 -0
- package/dist/builder/plugins/project.js +68 -0
- package/dist/builder/plugins/research.d.ts +24 -0
- package/dist/builder/plugins/research.js +147 -0
- package/dist/builder/plugins/sketch.d.ts +9 -0
- package/dist/builder/plugins/sketch.js +101 -0
- package/dist/builder/plugins/slides.d.ts +14 -0
- package/dist/builder/plugins/slides.js +55 -0
- package/dist/builder/plugins/template.d.ts +13 -0
- package/dist/builder/plugins/template.js +95 -0
- package/dist/builder/prefs.d.ts +29 -0
- package/dist/builder/prefs.js +91 -0
- package/dist/builder/preview-url.d.ts +47 -0
- package/dist/builder/preview-url.js +107 -0
- package/dist/builder/project.d.ts +18 -0
- package/dist/builder/project.js +604 -0
- package/dist/builder/prose.d.ts +4 -0
- package/dist/builder/prose.js +57 -0
- package/dist/builder/publish.d.ts +18 -0
- package/dist/builder/publish.js +141 -0
- package/dist/builder/question.d.ts +33 -0
- package/dist/builder/question.js +64 -0
- package/dist/builder/redesign.d.ts +32 -0
- package/dist/builder/redesign.js +117 -0
- package/dist/builder/removal.d.ts +71 -0
- package/dist/builder/removal.js +73 -0
- package/dist/builder/reply.d.ts +50 -0
- package/dist/builder/reply.js +196 -0
- package/dist/builder/roles.d.ts +10 -0
- package/dist/builder/roles.js +28 -0
- package/dist/builder/route.d.ts +85 -0
- package/dist/builder/route.js +126 -0
- package/dist/builder/run.d.ts +4 -0
- package/dist/builder/run.js +804 -0
- package/dist/builder/runmeta.d.ts +16 -0
- package/dist/builder/runmeta.js +69 -0
- package/dist/builder/say.d.ts +2 -0
- package/dist/builder/say.js +7 -0
- package/dist/builder/scheduled.d.ts +3 -0
- package/dist/builder/scheduled.js +328 -0
- package/dist/builder/section.d.ts +27 -0
- package/dist/builder/section.js +60 -0
- package/dist/builder/settings/account.d.ts +1 -0
- package/dist/builder/settings/account.js +111 -0
- package/dist/builder/settings/billing.d.ts +1 -0
- package/dist/builder/settings/billing.js +210 -0
- package/dist/builder/settings/capabilities.d.ts +1 -0
- package/dist/builder/settings/capabilities.js +66 -0
- package/dist/builder/settings/card.d.ts +31 -0
- package/dist/builder/settings/card.js +140 -0
- package/dist/builder/settings/code.d.ts +1 -0
- package/dist/builder/settings/code.js +70 -0
- package/dist/builder/settings/credits.d.ts +10 -0
- package/dist/builder/settings/credits.js +123 -0
- package/dist/builder/settings/environments.d.ts +1 -0
- package/dist/builder/settings/environments.js +60 -0
- package/dist/builder/settings/general.d.ts +1 -0
- package/dist/builder/settings/general.js +58 -0
- package/dist/builder/settings/index.d.ts +4 -0
- package/dist/builder/settings/index.js +25 -0
- package/dist/builder/settings/integrations.d.ts +8 -0
- package/dist/builder/settings/integrations.js +138 -0
- package/dist/builder/settings/keys.d.ts +1 -0
- package/dist/builder/settings/keys.js +114 -0
- package/dist/builder/settings/list.d.ts +10 -0
- package/dist/builder/settings/list.js +28 -0
- package/dist/builder/settings/machines.d.ts +4 -0
- package/dist/builder/settings/machines.js +243 -0
- package/dist/builder/settings/members.d.ts +1 -0
- package/dist/builder/settings/members.js +77 -0
- package/dist/builder/settings/memory.d.ts +1 -0
- package/dist/builder/settings/memory.js +62 -0
- package/dist/builder/settings/notifications.d.ts +1 -0
- package/dist/builder/settings/notifications.js +111 -0
- package/dist/builder/settings/plan.d.ts +17 -0
- package/dist/builder/settings/plan.js +131 -0
- package/dist/builder/settings/privacy.d.ts +1 -0
- package/dist/builder/settings/privacy.js +76 -0
- package/dist/builder/settings/sections.d.ts +16 -0
- package/dist/builder/settings/sections.js +34 -0
- package/dist/builder/settings/shared.d.ts +6 -0
- package/dist/builder/settings/shared.js +58 -0
- package/dist/builder/settings/ui.d.ts +50 -0
- package/dist/builder/settings/ui.js +53 -0
- package/dist/builder/settings/usage.d.ts +1 -0
- package/dist/builder/settings/usage.js +24 -0
- package/dist/builder/shared.d.ts +26 -0
- package/dist/builder/shared.js +15 -0
- package/dist/builder/shelf.d.ts +16 -0
- package/dist/builder/shelf.js +219 -0
- package/dist/builder/side.d.ts +40 -0
- package/dist/builder/side.js +208 -0
- package/dist/builder/site.d.ts +75 -0
- package/dist/builder/site.js +138 -0
- package/dist/builder/spend.d.ts +21 -0
- package/dist/builder/spend.js +80 -0
- package/dist/builder/standing.d.ts +36 -0
- package/dist/builder/standing.js +66 -0
- package/dist/builder/suggest.d.ts +238 -0
- package/dist/builder/suggest.js +463 -0
- package/dist/builder/suggestions.d.ts +49 -0
- package/dist/builder/suggestions.js +260 -0
- package/dist/builder/summary.d.ts +60 -0
- package/dist/builder/summary.js +81 -0
- package/dist/builder/sync.d.ts +1 -0
- package/dist/builder/sync.js +187 -0
- package/dist/builder/tabs.d.ts +85 -0
- package/dist/builder/tabs.js +288 -0
- package/dist/builder/talk.d.ts +5 -0
- package/dist/builder/talk.js +108 -0
- package/dist/builder/thread.d.ts +60 -0
- package/dist/builder/thread.js +302 -0
- package/dist/builder/tools.d.ts +22 -0
- package/dist/builder/tools.js +52 -0
- package/dist/builder/transcript.d.ts +47 -0
- package/dist/builder/transcript.js +108 -0
- package/dist/builder/voice.d.ts +8 -0
- package/dist/builder/voice.js +24 -0
- package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
- package/dist/core.js +1 -0
- package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
- package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
- package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
- package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
- package/package.json +101 -11
- /package/{index.d.ts → dist/core.d.ts} +0 -0
- /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GitHub repository creation, public `owner/repo` forking, outbound mirror sync,
|
|
4
|
+
* and repository import modal for `/dev`.
|
|
5
|
+
*
|
|
6
|
+
* Follows the monochrome design system (`@hanzo/gui`, `@hanzo/ui`, `@hanzo/i18n`)
|
|
7
|
+
* and works cleanly from mobile (`390px`) to desktop (`1440px`).
|
|
8
|
+
*/
|
|
9
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
10
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
11
|
+
import { ArrowRight, ArrowUpRight, GitBranch, GitFork, Github, Globe, Link2, Lock, Plus, Search, X, } from '@hanzogui/lucide-icons-2';
|
|
12
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogTitle, Input, Skeleton, toast } from '@hanzo/ui';
|
|
13
|
+
import { useEffect, useId, useMemo, useState } from 'react';
|
|
14
|
+
import { here } from './back.js';
|
|
15
|
+
import { told } from './api/call.js';
|
|
16
|
+
import { codebases } from './api/codebases.js';
|
|
17
|
+
import { attachGitHubMirror, bring, connect, connection, createGitHubRepo, forkGitHubRepo, installations, isGitHubUserOAuthRequired, parseGitHubRepo, repos as listGitHubRepos, } from './api/github.js';
|
|
18
|
+
import { links } from './api/links.js';
|
|
19
|
+
import { authorize, read as readProvider } from './api/provider.js';
|
|
20
|
+
import { pinHub, readPending, writePending } from './choice.js';
|
|
21
|
+
import { useRead } from './data.js';
|
|
22
|
+
import { useHost, useTarget } from './host.js';
|
|
23
|
+
import { Out } from './out.js';
|
|
24
|
+
import { RING } from './pane.js';
|
|
25
|
+
import { path } from './route.js';
|
|
26
|
+
const EMPTY_REPOS = { repos: [], next: '', total: 0, unread: [], connected: false };
|
|
27
|
+
/**
|
|
28
|
+
* Crisp monochrome GitHub badge/link (`owner/repo ↗`) with optional sync status.
|
|
29
|
+
*/
|
|
30
|
+
export function GitHubBadge({ fullName, htmlUrl, syncedLabel, compact = false, }) {
|
|
31
|
+
const { t } = useI18n();
|
|
32
|
+
return (_jsx(XStack, { "data-slot": "github-badge", "data-repo": fullName, items: "center", rounded: 999, borderWidth: 1, borderColor: "$borderColor", bg: "$panel", px: "$2", py: "$0.5", minH: 26, minW: 0, shrink: 1, maxW: compact ? 180 : 240, "$max-md": { maxW: compact ? 132 : 180 }, hoverStyle: { bg: '$hover' }, children: _jsx(Out, { href: htmlUrl, label: t('Open {repo} on GitHub', { repo: fullName }), children: _jsxs(XStack, { items: "center", gap: "$1.5", minW: 0, maxW: "100%", 'data-i18n-ltr': '', children: [_jsx(Github, { size: 12, color: "$ink", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$ink", fontWeight: "500", numberOfLines: 1, minW: 0, shrink: 1, children: fullName }), syncedLabel && !compact ? (_jsx(SizableText, { size: "$1", color: "$soft", shrink: 0, "$max-md": { display: 'none' }, children: `· ${syncedLabel}` })) : null, _jsx(ArrowUpRight, { size: 11, color: "$soft", "aria-hidden": true })] }) }) }));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 1-click user OAuth fallback callout shown when creating/forking under a
|
|
36
|
+
* personal GitHub account returns HTTP 412 or 409.
|
|
37
|
+
*/
|
|
38
|
+
export function GitHubOAuthCallout({ message, label, }) {
|
|
39
|
+
const host = useHost();
|
|
40
|
+
const target = useTarget();
|
|
41
|
+
const { t } = useI18n();
|
|
42
|
+
const [busy, setBusy] = useState(false);
|
|
43
|
+
const [err, setErr] = useState('');
|
|
44
|
+
const authorizeUser = async () => {
|
|
45
|
+
setBusy(true);
|
|
46
|
+
setErr('');
|
|
47
|
+
try {
|
|
48
|
+
const url = await connect(target, here());
|
|
49
|
+
host.open(url);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
setErr(told(e, t));
|
|
53
|
+
setBusy(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return (_jsxs(YStack, { "data-slot": "github-oauth-fallback", role: "alert", gap: "$2", px: "$3", py: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "$panel", children: [_jsx(SizableText, { size: "$2", color: "$ink", children: message || t('Authorize your personal GitHub account to create or fork repositories.') }), err ? (_jsx(SizableText, { size: "$1", color: "var(--state-error)", children: err })) : null, _jsx(XStack, { children: _jsxs(Button, { size: "sm", variant: "primary", "data-slot": "github-oauth-cta", "aria-label": label || t('Authorize GitHub account'), disabled: busy, onPress: () => void authorizeUser(), children: [_jsx(Github, { size: 14 }), busy ? t('Opening GitHub…') : label || t('Authorize GitHub account')] }) })] }));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Segmented toggle pill button used for tabs and visibility switches.
|
|
60
|
+
*/
|
|
61
|
+
function SegmentButton({ active, label, icon, role, onPress, disabled = false, dataSlot, }) {
|
|
62
|
+
return (_jsxs(XStack, { render: "button", "data-slot": dataSlot, role: role, "aria-selected": role === 'tab' ? active : undefined, "aria-pressed": role !== 'tab' ? active : undefined, "aria-label": label, disabled: disabled, onPress: onPress, items: "center", justify: "center", gap: "$1.5", px: "$3", py: "$1.5", minH: 36, rounded: "$3", borderWidth: 1, borderColor: active ? '$ink' : '$borderColor', bg: active ? '$ink' : '$panel', cursor: disabled ? 'default' : 'pointer', opacity: disabled ? 0.6 : 1, focusVisibleStyle: RING, children: [icon, _jsx(SizableText, { size: "$2", fontWeight: active ? '500' : '400', color: active ? '$background' : '$ink', numberOfLines: 1, children: label })] }));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Form to create a new GitHub repository (`POST /v1/provider/github/repos`).
|
|
66
|
+
* Handles 412/409 personal account OAuth requirement with a 1-click CTA.
|
|
67
|
+
*/
|
|
68
|
+
export function CreateGitHubRepoForm({ defaultName = '', defaultDescription = '', linkRepo, orgs = [], submitLabel, oauthLabel, onCreated, onCancel, }) {
|
|
69
|
+
const target = useTarget();
|
|
70
|
+
const { t } = useI18n();
|
|
71
|
+
const id = useId();
|
|
72
|
+
const [name, setName] = useState(defaultName);
|
|
73
|
+
const [description, setDescription] = useState(defaultDescription);
|
|
74
|
+
const [isPrivate, setIsPrivate] = useState(true);
|
|
75
|
+
const [org, setOrg] = useState('');
|
|
76
|
+
const [busy, setBusy] = useState(false);
|
|
77
|
+
const [error, setError] = useState('');
|
|
78
|
+
const [needsOAuth, setNeedsOAuth] = useState(false);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
setName(defaultName);
|
|
81
|
+
setDescription(defaultDescription);
|
|
82
|
+
setError('');
|
|
83
|
+
setNeedsOAuth(false);
|
|
84
|
+
}, [defaultName, defaultDescription, linkRepo]);
|
|
85
|
+
const submit = async () => {
|
|
86
|
+
const trimmed = name.trim();
|
|
87
|
+
if (!trimmed) {
|
|
88
|
+
setError(t('Enter a repository name.'));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
setBusy(true);
|
|
92
|
+
setError('');
|
|
93
|
+
setNeedsOAuth(false);
|
|
94
|
+
try {
|
|
95
|
+
const created = await createGitHubRepo(target, {
|
|
96
|
+
name: trimmed,
|
|
97
|
+
description: description.trim() || undefined,
|
|
98
|
+
private: isPrivate,
|
|
99
|
+
org: org || undefined,
|
|
100
|
+
linkRepo,
|
|
101
|
+
});
|
|
102
|
+
await onCreated(created);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
if (isGitHubUserOAuthRequired(e)) {
|
|
106
|
+
setNeedsOAuth(true);
|
|
107
|
+
setError(told(e, t));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
setError(told(e, t));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
setBusy(false);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return (_jsxs(YStack, { "data-slot": "create-github-repo-form", gap: "$3", children: [_jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-name`, children: t('Repository name') }), _jsx(Input, { id: `${id}-name`, value: name, onChangeText: setName, placeholder: "my-project", "aria-label": t('Repository name'), disabled: busy, onKeyDown: (e) => {
|
|
118
|
+
if (e.key === 'Enter')
|
|
119
|
+
void submit();
|
|
120
|
+
} })] }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-desc`, children: t('Description') }), _jsx(Input, { id: `${id}-desc`, value: description, onChangeText: setDescription, placeholder: t('Short description (optional)'), "aria-label": t('Description'), disabled: busy, onKeyDown: (e) => {
|
|
121
|
+
if (e.key === 'Enter')
|
|
122
|
+
void submit();
|
|
123
|
+
} })] }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Visibility') }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", role: "group", "aria-label": t('Visibility'), children: [_jsx(SegmentButton, { dataSlot: "visibility-private", active: isPrivate, label: t('Private'), icon: _jsx(Lock, { size: 13, color: isPrivate ? '$background' : '$ink' }), disabled: busy, onPress: () => setIsPrivate(true) }), _jsx(SegmentButton, { dataSlot: "visibility-public", active: !isPrivate, label: t('Public'), icon: _jsx(Globe, { size: 13, color: !isPrivate ? '$background' : '$ink' }), disabled: busy, onPress: () => setIsPrivate(false) })] })] }), orgs.length > 0 ? (_jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Owner') }), _jsxs(XStack, { gap: "$1.5", flexWrap: "wrap", role: "group", "aria-label": t('Owner'), children: [_jsx(SegmentButton, { active: org === '', label: t('Personal account'), disabled: busy, onPress: () => setOrg('') }), orgs.map((o) => (_jsx(SegmentButton, { active: org === o, label: o, disabled: busy, onPress: () => setOrg(o) }, o)))] })] })) : null, needsOAuth ? (_jsx(GitHubOAuthCallout, { message: error || t('Your personal GitHub account needs authorization before creating repositories.'), label: oauthLabel })) : error ? (_jsx(SizableText, { size: "$2", color: "var(--state-error)", role: "alert", children: error })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [onCancel ? (_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: onCancel, children: t('Cancel') })) : null, _jsxs(Button, { size: "sm", variant: "primary", "data-slot": "create-github-repo-submit", disabled: busy || !name.trim(), onPress: () => void submit(), children: [_jsx(Plus, { size: 14 }), busy ? t('Creating…') : submitLabel || t('Create repository')] })] })] }));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Form to fork a GitHub repository (`POST /v1/provider/github/fork`).
|
|
127
|
+
* Supports `owner/repo`, GitHub URLs, and bare repository names.
|
|
128
|
+
*/
|
|
129
|
+
export function ForkGitHubRepoForm({ orgs = [], submitLabel, onForked, onCancel, }) {
|
|
130
|
+
const target = useTarget();
|
|
131
|
+
const { t } = useI18n();
|
|
132
|
+
const id = useId();
|
|
133
|
+
const [repo, setRepo] = useState('');
|
|
134
|
+
const [name, setName] = useState('');
|
|
135
|
+
const [org, setOrg] = useState('');
|
|
136
|
+
const [busy, setBusy] = useState(false);
|
|
137
|
+
const [error, setError] = useState('');
|
|
138
|
+
const [needsOAuth, setNeedsOAuth] = useState(false);
|
|
139
|
+
const submit = async () => {
|
|
140
|
+
const trimmed = repo.trim();
|
|
141
|
+
if (!trimmed) {
|
|
142
|
+
setError(t('Enter a repository to fork, such as owner/repo.'));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
setBusy(true);
|
|
146
|
+
setError('');
|
|
147
|
+
setNeedsOAuth(false);
|
|
148
|
+
try {
|
|
149
|
+
const forked = await forkGitHubRepo(target, {
|
|
150
|
+
repo: trimmed,
|
|
151
|
+
org: org || undefined,
|
|
152
|
+
name: name.trim() || undefined,
|
|
153
|
+
});
|
|
154
|
+
await onForked(forked);
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
if (isGitHubUserOAuthRequired(e)) {
|
|
158
|
+
setNeedsOAuth(true);
|
|
159
|
+
setError(told(e, t));
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
setError(told(e, t));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
setBusy(false);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return (_jsxs(YStack, { "data-slot": "fork-github-repo-form", gap: "$3", children: [_jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-repo`, children: t('Repository to fork') }), _jsx(Input, { id: `${id}-repo`, value: repo, onChangeText: setRepo, placeholder: "owner/repo", "aria-label": t('Repository to fork'), disabled: busy, onKeyDown: (e) => {
|
|
170
|
+
if (e.key === 'Enter')
|
|
171
|
+
void submit();
|
|
172
|
+
} }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Enter any public GitHub repository (e.g. hanzoai/ui) or paste its URL.') })] }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-rename`, children: t('New repository name (optional)') }), _jsx(Input, { id: `${id}-rename`, value: name, onChangeText: setName, placeholder: t('Keep original name'), "aria-label": t('New repository name (optional)'), disabled: busy, onKeyDown: (e) => {
|
|
173
|
+
if (e.key === 'Enter')
|
|
174
|
+
void submit();
|
|
175
|
+
} })] }), orgs.length > 0 ? (_jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Fork into') }), _jsxs(XStack, { gap: "$1.5", flexWrap: "wrap", role: "group", "aria-label": t('Fork into'), children: [_jsx(SegmentButton, { active: org === '', label: t('Personal account'), disabled: busy, onPress: () => setOrg('') }), orgs.map((o) => (_jsx(SegmentButton, { active: org === o, label: o, disabled: busy, onPress: () => setOrg(o) }, o)))] })] })) : null, needsOAuth ? (_jsx(GitHubOAuthCallout, { message: error || t('Authorize your personal GitHub account to fork repositories into it.') })) : error ? (_jsx(SizableText, { size: "$2", color: "var(--state-error)", role: "alert", children: error })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [onCancel ? (_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: onCancel, children: t('Cancel') })) : null, _jsxs(Button, { size: "sm", variant: "primary", "data-slot": "fork-github-repo-submit", disabled: busy || !repo.trim(), onPress: () => void submit(), children: [_jsx(GitFork, { size: 14 }), busy ? t('Forking…') : submitLabel || t('Fork & edit in /dev')] })] })] }));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Dialog to sync a Hanzo Git project to GitHub:
|
|
179
|
+
* - Create & sync a new GitHub repository (`POST /v1/provider/github/repos` with `linkRepo`), OR
|
|
180
|
+
* - Link an existing GitHub repository URL (`POST /v1/git/repos/:name/targets`).
|
|
181
|
+
*/
|
|
182
|
+
export function SyncToGitHubDialog({ open, onOpenChange, repoName, defaultName, defaultDescription = '', onSynced, }) {
|
|
183
|
+
const target = useTarget();
|
|
184
|
+
const { t } = useI18n();
|
|
185
|
+
const id = useId();
|
|
186
|
+
const [mode, setMode] = useState('create');
|
|
187
|
+
const [existingUrl, setExistingUrl] = useState('');
|
|
188
|
+
const [busy, setBusy] = useState(false);
|
|
189
|
+
const [error, setError] = useState('');
|
|
190
|
+
const [needsOAuth, setNeedsOAuth] = useState(false);
|
|
191
|
+
const installed = useRead(open ? () => installations(target).catch(() => []) : null, [], [target, open]);
|
|
192
|
+
const orgLogins = useMemo(() => installed.value.filter((i) => i.connected && i.type.toLowerCase() === 'organization').map((i) => i.login), [installed.value]);
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
if (!open)
|
|
195
|
+
return;
|
|
196
|
+
setMode('create');
|
|
197
|
+
setExistingUrl('');
|
|
198
|
+
setError('');
|
|
199
|
+
setNeedsOAuth(false);
|
|
200
|
+
}, [open, repoName]);
|
|
201
|
+
const attachExisting = async () => {
|
|
202
|
+
const at = parseGitHubRepo(existingUrl);
|
|
203
|
+
if (!at) {
|
|
204
|
+
setError(t('Enter a GitHub repository URL or owner/repo (e.g. https://github.com/owner/repo).'));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
setBusy(true);
|
|
208
|
+
setError('');
|
|
209
|
+
setNeedsOAuth(false);
|
|
210
|
+
try {
|
|
211
|
+
await attachGitHubMirror(target, repoName, existingUrl);
|
|
212
|
+
const fullName = `${at.owner}/${at.name}`;
|
|
213
|
+
const htmlUrl = `https://github.com/${fullName}`;
|
|
214
|
+
toast.success(t('Syncing {repo} to GitHub ({target})', { repo: repoName, target: fullName }));
|
|
215
|
+
onSynced({ owner: at.owner, name: at.name, fullName, htmlUrl, source: 'target' });
|
|
216
|
+
onOpenChange(false);
|
|
217
|
+
}
|
|
218
|
+
catch (e) {
|
|
219
|
+
if (isGitHubUserOAuthRequired(e)) {
|
|
220
|
+
setNeedsOAuth(true);
|
|
221
|
+
setError(told(e, t));
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
setError(told(e, t));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
setBusy(false);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
return (_jsx(Dialog, { open: open, onOpenChange: (o) => !busy && onOpenChange(o), children: _jsxs(DialogContent, { "data-slot": "sync-to-github-dialog", width: "100%", maxW: 480, maxH: "85vh", overflow: "scroll", gap: "$3", children: [_jsx(DialogTitle, { children: t('Sync to GitHub') }), _jsx(DialogDescription, { children: t('Push {repo} to a new or existing GitHub repository and keep commits synced.', { repo: repoName }) }), _jsxs(XStack, { role: "tablist", "aria-label": t('Sync method'), gap: "$2", flexWrap: "wrap", children: [_jsx(SegmentButton, { role: "tab", dataSlot: "sync-tab-create", active: mode === 'create', label: t('Create new repo'), icon: _jsx(Plus, { size: 13, color: mode === 'create' ? '$background' : '$ink' }), disabled: busy, onPress: () => {
|
|
232
|
+
setMode('create');
|
|
233
|
+
setError('');
|
|
234
|
+
setNeedsOAuth(false);
|
|
235
|
+
} }), _jsx(SegmentButton, { role: "tab", dataSlot: "sync-tab-link", active: mode === 'link', label: t('Link existing repo'), icon: _jsx(Link2, { size: 13, color: mode === 'link' ? '$background' : '$ink' }), disabled: busy, onPress: () => {
|
|
236
|
+
setMode('link');
|
|
237
|
+
setError('');
|
|
238
|
+
setNeedsOAuth(false);
|
|
239
|
+
} })] }), mode === 'create' ? (_jsx(CreateGitHubRepoForm, { defaultName: defaultName || repoName, defaultDescription: defaultDescription, linkRepo: repoName, orgs: orgLogins, submitLabel: t('Create & sync to GitHub'), oauthLabel: t('Authorize GitHub to create repos'), onCancel: () => onOpenChange(false), onCreated: (created) => {
|
|
240
|
+
const parts = created.full_name.split('/');
|
|
241
|
+
const owner = parts[0] ?? '';
|
|
242
|
+
const name = parts[1] ?? created.full_name;
|
|
243
|
+
toast.success(t('Synced to {repo} on GitHub', { repo: created.full_name }));
|
|
244
|
+
onSynced({
|
|
245
|
+
owner,
|
|
246
|
+
name,
|
|
247
|
+
fullName: created.full_name,
|
|
248
|
+
htmlUrl: created.html_url || `https://github.com/${created.full_name}`,
|
|
249
|
+
source: 'target',
|
|
250
|
+
});
|
|
251
|
+
onOpenChange(false);
|
|
252
|
+
} })) : (_jsxs(YStack, { "data-slot": "link-existing-github-form", gap: "$3", children: [_jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-url`, children: t('GitHub repository') }), _jsx(Input, { id: `${id}-url`, value: existingUrl, onChangeText: setExistingUrl, placeholder: "https://github.com/owner/repo", "aria-label": t('GitHub repository URL'), disabled: busy, onKeyDown: (e) => {
|
|
253
|
+
if (e.key === 'Enter')
|
|
254
|
+
void attachExisting();
|
|
255
|
+
} }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Attaches an outbound mirror target and triggers an initial sync push.') })] }), needsOAuth ? (_jsx(GitHubOAuthCallout, { message: error || t('Authorize your GitHub account to push to this repository.') })) : error ? (_jsx(SizableText, { size: "$2", color: "var(--state-error)", role: "alert", children: error })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => onOpenChange(false), children: t('Cancel') }), _jsxs(Button, { size: "sm", variant: "primary", "data-slot": "link-existing-github-submit", disabled: busy || !existingUrl.trim(), onPress: () => void attachExisting(), children: [_jsx(Link2, { size: 14 }), busy ? t('Syncing…') : t('Link & sync to GitHub')] })] })] }))] }) }));
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Modal/drawer experience for "Link a GitHub repo" / "Sync repositories" on `/dev/projects`:
|
|
259
|
+
* - When connected with 0 repositories, presents first-class "Create a new GitHub repository"
|
|
260
|
+
* and "Fork a GitHub repository" actions instead of a dead-end empty state.
|
|
261
|
+
* - When repositories are listed, provides instant search, 1-click "Import & edit in /dev",
|
|
262
|
+
* and clean access to "Create new repo" and "Fork repo".
|
|
263
|
+
* - Responsive from 390px mobile to 1440px desktop with zero overlap.
|
|
264
|
+
*/
|
|
265
|
+
export function GitHubReposModal({ open, onOpenChange, initialTab = 'browse', onChanged, }) {
|
|
266
|
+
const host = useHost();
|
|
267
|
+
const target = useTarget();
|
|
268
|
+
const { t } = useI18n();
|
|
269
|
+
const signed = Boolean(host.person);
|
|
270
|
+
const [tab, setTab] = useState(initialTab);
|
|
271
|
+
const [q, setQ] = useState('');
|
|
272
|
+
const [importing, setImporting] = useState('');
|
|
273
|
+
const [connecting, setConnecting] = useState(false);
|
|
274
|
+
const [error, setError] = useState('');
|
|
275
|
+
const [needsOAuth, setNeedsOAuth] = useState(false);
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
if (!open)
|
|
278
|
+
return;
|
|
279
|
+
setTab(initialTab);
|
|
280
|
+
setQ('');
|
|
281
|
+
setError('');
|
|
282
|
+
setNeedsOAuth(false);
|
|
283
|
+
setImporting('');
|
|
284
|
+
}, [open, initialTab]);
|
|
285
|
+
const me = useRead(open && signed ? () => connection(target).catch(() => null) : null, null, [target, open, signed]);
|
|
286
|
+
const providerConn = useRead(open && signed ? () => readProvider(target, 'github').catch(() => null) : null, null, [target, open, signed]);
|
|
287
|
+
const installed = useRead(open && signed ? () => installations(target).catch(() => []) : null, [], [target, open, signed]);
|
|
288
|
+
const repoPage = useRead(open && signed ? () => listGitHubRepos(target, { limit: 100 }) : null, EMPTY_REPOS, [target, open, signed]);
|
|
289
|
+
const held = useRead(open && signed ? () => codebases(target).catch(() => []) : null, [], [target, open, signed]);
|
|
290
|
+
const syncedLinks = useRead(open && signed ? () => links(target).catch(() => []) : null, [], [target, open, signed]);
|
|
291
|
+
const isConnected = Boolean(me.value?.connected ||
|
|
292
|
+
providerConn.value?.connected ||
|
|
293
|
+
repoPage.value.connected ||
|
|
294
|
+
installed.value.some((i) => i.connected));
|
|
295
|
+
const login = me.value?.login ||
|
|
296
|
+
providerConn.value?.account ||
|
|
297
|
+
installed.value.find((i) => i.connected)?.login ||
|
|
298
|
+
'';
|
|
299
|
+
const orgLogins = useMemo(() => installed.value.filter((i) => i.connected && i.type.toLowerCase() === 'organization').map((i) => i.login), [installed.value]);
|
|
300
|
+
const loading = me.loading || repoPage.loading;
|
|
301
|
+
const heldNames = useMemo(() => new Set(held.value.map((c) => c.name.toLowerCase())), [held.value]);
|
|
302
|
+
const linkedMap = useMemo(() => new Map(syncedLinks.value.map((l) => [`${l.owner}/${l.name}`.toLowerCase(), l])), [syncedLinks.value]);
|
|
303
|
+
const needle = q.trim().toLowerCase();
|
|
304
|
+
const filteredRepos = useMemo(() => repoPage.value.repos.filter((r) => !needle || r.full_name.toLowerCase().includes(needle) || r.name.toLowerCase().includes(needle) || r.owner.toLowerCase().includes(needle)), [repoPage.value.repos, needle]);
|
|
305
|
+
const startConnect = async () => {
|
|
306
|
+
setConnecting(true);
|
|
307
|
+
setError('');
|
|
308
|
+
try {
|
|
309
|
+
host.open(await connect(target, here()));
|
|
310
|
+
}
|
|
311
|
+
catch (e) {
|
|
312
|
+
setError(told(e, t));
|
|
313
|
+
setConnecting(false);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const installApp = async () => {
|
|
317
|
+
setConnecting(true);
|
|
318
|
+
setError('');
|
|
319
|
+
try {
|
|
320
|
+
host.open(await authorize(target, 'github', here()));
|
|
321
|
+
}
|
|
322
|
+
catch (e) {
|
|
323
|
+
setError(told(e, t));
|
|
324
|
+
setConnecting(false);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
const openCreatedOrForked = async (created, verb) => {
|
|
328
|
+
const [owner = '', name = created.full_name] = created.full_name.split('/');
|
|
329
|
+
try {
|
|
330
|
+
const queued = await bring(target, [created.full_name]);
|
|
331
|
+
const codebaseName = queued.codebases[created.full_name.toLowerCase()] || name;
|
|
332
|
+
const nextPending = [
|
|
333
|
+
...readPending(host.org).filter((p) => p.fullName.toLowerCase() !== created.full_name.toLowerCase()),
|
|
334
|
+
{ fullName: created.full_name, name: codebaseName },
|
|
335
|
+
];
|
|
336
|
+
writePending(host.org, nextPending);
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
// Personal OAuth repos can still be edited directly via github.com/owner/repo even without an org mirror.
|
|
340
|
+
}
|
|
341
|
+
pinHub(host.org, {
|
|
342
|
+
owner,
|
|
343
|
+
name,
|
|
344
|
+
private: created.private,
|
|
345
|
+
branch: created.default_branch || 'main',
|
|
346
|
+
});
|
|
347
|
+
toast.success(verb === 'created'
|
|
348
|
+
? t('Created {repo} on GitHub — opening in Dev', { repo: created.full_name })
|
|
349
|
+
: t('Forked {repo} to GitHub — opening in Dev', { repo: created.full_name }));
|
|
350
|
+
onChanged?.();
|
|
351
|
+
onOpenChange(false);
|
|
352
|
+
host.go('');
|
|
353
|
+
};
|
|
354
|
+
const importAndEdit = async (r) => {
|
|
355
|
+
const existingLink = linkedMap.get(r.full_name.toLowerCase());
|
|
356
|
+
const forgeName = existingLink?.forge || r.codebase || r.name;
|
|
357
|
+
if (heldNames.has(forgeName.toLowerCase())) {
|
|
358
|
+
onOpenChange(false);
|
|
359
|
+
host.go(path({ kind: 'repo', org: host.org || '', name: forgeName }));
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
setImporting(r.full_name);
|
|
363
|
+
setError('');
|
|
364
|
+
setNeedsOAuth(false);
|
|
365
|
+
try {
|
|
366
|
+
const queued = await bring(target, [r.full_name]);
|
|
367
|
+
const codebaseName = queued.codebases[r.full_name.toLowerCase()] || r.codebase || r.name;
|
|
368
|
+
const nextPending = [
|
|
369
|
+
...readPending(host.org).filter((p) => p.fullName.toLowerCase() !== r.full_name.toLowerCase()),
|
|
370
|
+
{ fullName: r.full_name, name: codebaseName },
|
|
371
|
+
];
|
|
372
|
+
writePending(host.org, nextPending);
|
|
373
|
+
pinHub(host.org, {
|
|
374
|
+
owner: r.owner,
|
|
375
|
+
name: r.name,
|
|
376
|
+
private: r.private,
|
|
377
|
+
branch: r.default_branch || 'main',
|
|
378
|
+
});
|
|
379
|
+
toast.success(t('Importing {repo} — opening in Dev', { repo: r.full_name }));
|
|
380
|
+
onChanged?.();
|
|
381
|
+
onOpenChange(false);
|
|
382
|
+
host.go('');
|
|
383
|
+
}
|
|
384
|
+
catch (e) {
|
|
385
|
+
if (isGitHubUserOAuthRequired(e)) {
|
|
386
|
+
// When user has personal GitHub connected, they can still work directly on github.com/owner/repo.
|
|
387
|
+
if (me.value?.connected) {
|
|
388
|
+
pinHub(host.org, {
|
|
389
|
+
owner: r.owner,
|
|
390
|
+
name: r.name,
|
|
391
|
+
private: r.private,
|
|
392
|
+
branch: r.default_branch || 'main',
|
|
393
|
+
});
|
|
394
|
+
toast.success(t('Opened {repo} in Dev', { repo: r.full_name }));
|
|
395
|
+
onOpenChange(false);
|
|
396
|
+
host.go('');
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
setNeedsOAuth(true);
|
|
400
|
+
setError(told(e, t));
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
setError(told(e, t));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
finally {
|
|
407
|
+
setImporting('');
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
return (_jsx(Dialog, { open: open, onOpenChange: (o) => !importing && onOpenChange(o), children: _jsxs(DialogContent, { "data-slot": "github-repos-modal", width: "100%", maxW: 540, maxH: "85vh", overflow: "scroll", gap: "$3", children: [_jsx(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: _jsxs(YStack, { gap: "$0.5", flex: 1, minW: 0, children: [_jsx(DialogTitle, { children: t('GitHub repositories') }), isConnected && login ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: t('Connected as @{login}', { login }) })) : null] }) }), !signed ? (_jsxs(YStack, { gap: "$3", items: "center", py: "$4", children: [_jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Sign in to connect GitHub and work on repositories in Dev.') }), _jsx(Button, { size: "sm", variant: "primary", onPress: () => host.signIn?.(), children: t('Sign in') })] })) : !isConnected && !loading ? (_jsxs(YStack, { "data-slot": "github-not-connected", gap: "$3", py: "$2", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Connect your GitHub account to import, create, or fork repositories right from Dev.') }), error ? (_jsx(SizableText, { size: "$2", color: "var(--state-error)", role: "alert", children: error })) : null, _jsxs(XStack, { gap: "$2", flexWrap: "wrap", children: [_jsxs(Button, { size: "sm", variant: "primary", disabled: connecting, onPress: () => void startConnect(), children: [_jsx(Github, { size: 14 }), connecting ? t('Opening GitHub…') : t('Connect GitHub')] }), host.admin ? (_jsx(Button, { size: "sm", variant: "outline", disabled: connecting, onPress: () => void installApp(), children: t('Install on organization') })) : null] })] })) : (_jsxs(_Fragment, { children: [_jsxs(XStack, { role: "tablist", "aria-label": t('GitHub actions'), gap: "$2", flexWrap: "wrap", children: [_jsx(SegmentButton, { role: "tab", dataSlot: "github-tab-browse", active: tab === 'browse', label: repoPage.value.repos.length > 0
|
|
411
|
+
? t('Repositories ({n})', { n: repoPage.value.total || repoPage.value.repos.length })
|
|
412
|
+
: t('Repositories'), icon: _jsx(Github, { size: 13, color: tab === 'browse' ? '$background' : '$ink' }), onPress: () => {
|
|
413
|
+
setTab('browse');
|
|
414
|
+
setError('');
|
|
415
|
+
setNeedsOAuth(false);
|
|
416
|
+
} }), _jsx(SegmentButton, { role: "tab", dataSlot: "github-tab-create", active: tab === 'create', label: t('Create new repo'), icon: _jsx(Plus, { size: 13, color: tab === 'create' ? '$background' : '$ink' }), onPress: () => {
|
|
417
|
+
setTab('create');
|
|
418
|
+
setError('');
|
|
419
|
+
setNeedsOAuth(false);
|
|
420
|
+
} }), _jsx(SegmentButton, { role: "tab", dataSlot: "github-tab-fork", active: tab === 'fork', label: t('Fork repo'), icon: _jsx(GitFork, { size: 13, color: tab === 'fork' ? '$background' : '$ink' }), onPress: () => {
|
|
421
|
+
setTab('fork');
|
|
422
|
+
setError('');
|
|
423
|
+
setNeedsOAuth(false);
|
|
424
|
+
} })] }), tab === 'browse' ? (loading && repoPage.value.repos.length === 0 ? (_jsxs(YStack, { gap: "$2", "aria-busy": true, py: "$2", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Reading your GitHub repositories…') }), _jsx(Skeleton, { layout: "block", height: 40, rounded: "$3" }), _jsx(Skeleton, { layout: "block", height: 40, rounded: "$3" }), _jsx(Skeleton, { layout: "block", height: 40, rounded: "$3" })] })) : repoPage.error && repoPage.value.repos.length === 0 ? (_jsxs(YStack, { gap: "$3", py: "$2", children: [_jsx(SizableText, { size: "$2", color: "var(--state-error)", role: "alert", children: told(repoPage.error, t) }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "outline", onPress: repoPage.reload, children: t('Try again') }), _jsxs(Button, { size: "sm", variant: "primary", onPress: () => setTab('create'), children: [_jsx(Plus, { size: 14 }), t('Create a new GitHub repository')] }), _jsxs(Button, { size: "sm", variant: "outline", onPress: () => setTab('fork'), children: [_jsx(GitFork, { size: 14 }), t('Fork a GitHub repository')] })] })] })) : repoPage.value.repos.length === 0 ? (_jsxs(YStack, { "data-slot": "github-empty-state", gap: "$3", py: "$2", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", children: t('No repositories on GitHub yet') }), _jsx(SizableText, { size: "$2", color: "$soft", children: login
|
|
425
|
+
? t('Your GitHub account (@{login}) has 0 repositories right now. Create a new repository or fork any public owner/repo to start editing in Dev.', { login })
|
|
426
|
+
: t('Your connected GitHub account has 0 repositories right now. Create a new repository or fork any public owner/repo to start editing in Dev.') })] }), _jsxs(XStack, { gap: "$2.5", flexWrap: "wrap", children: [_jsxs(YStack, { render: "button", "data-slot": "empty-create-github-repo", "aria-label": t('Create a new GitHub repository'), onPress: () => setTab('create'), flex: 1, flexBasis: 200, minW: 0, gap: "$1.5", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", items: "flex-start", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$platform-web": { textAlign: 'start' }, children: [_jsx(Plus, { size: 18, color: "$ink" }), _jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", children: t('Create a new GitHub repository') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Name, description, and visibility — created on GitHub and opened in Dev.') })] }), _jsxs(YStack, { render: "button", "data-slot": "empty-fork-github-repo", "aria-label": t('Fork a GitHub repository'), onPress: () => setTab('fork'), flex: 1, flexBasis: 200, minW: 0, gap: "$1.5", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", items: "flex-start", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$platform-web": { textAlign: 'start' }, children: [_jsx(GitFork, { size: 18, color: "$ink" }), _jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", children: t('Fork a GitHub repository') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Fork any public owner/repo to your GitHub and edit it in Dev.') })] })] }), host.admin ? (_jsx(XStack, { children: _jsx(Button, { size: "sm", variant: "ghost", disabled: connecting, onPress: () => void installApp(), children: t('Grant access to more repositories on GitHub') }) })) : null] })) : (_jsxs(YStack, { "data-slot": "github-repo-list", gap: "$2.5", children: [_jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Search repositories…'), "aria-label": t('Search repositories'), startAdornment: _jsx(Search, { size: 14, color: "$soft", "aria-hidden": true }), endAdornment: q ? (_jsx(XStack, { render: "button", "aria-label": t('Clear search'), onPress: () => setQ(''), minW: 24, minH: 24, items: "center", justify: "center", focusVisibleStyle: RING, children: _jsx(X, { size: 13, color: "$soft" }) })) : undefined }), needsOAuth ? (_jsx(GitHubOAuthCallout, { message: error })) : error ? (_jsx(SizableText, { size: "$2", color: "var(--state-error)", role: "alert", children: error })) : null, _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", maxH: 320, overflow: "scroll", children: filteredRepos.length === 0 ? (_jsxs(YStack, { p: "$4", gap: "$2", items: "center", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Nothing matches.') }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => setQ(''), children: t('Clear search') })] })) : (filteredRepos.map((r, i) => {
|
|
427
|
+
const existingLink = linkedMap.get(r.full_name.toLowerCase());
|
|
428
|
+
const forgeName = existingLink?.forge || r.codebase || r.name;
|
|
429
|
+
const onForge = heldNames.has(forgeName.toLowerCase());
|
|
430
|
+
const isBusy = importing === r.full_name;
|
|
431
|
+
return (_jsxs(XStack, { items: "center", gap: "$2.5", px: "$3", py: "$2.5", minH: 48, borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, flexWrap: "wrap", children: [_jsxs(XStack, { items: "center", gap: "$2", flex: 1, minW: 160, children: [r.private ? _jsx(Lock, { size: 14, color: "$soft", "aria-hidden": true }) : _jsx(Globe, { size: 14, color: "$soft", "aria-hidden": true }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "500", numberOfLines: 1, 'data-i18n-ltr': '', children: r.full_name }), r.default_branch ? (_jsxs(XStack, { items: "center", gap: "$1", children: [_jsx(GitBranch, { size: 10, color: "$soft", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: r.default_branch })] })) : null] })] }), _jsxs(Button, { size: "sm", variant: onForge ? 'outline' : 'primary', "data-slot": "import-edit-repo", "aria-label": onForge
|
|
432
|
+
? t('Open {repo} in /dev', { repo: r.full_name })
|
|
433
|
+
: t('Import & edit {repo} in /dev', { repo: r.full_name }), disabled: Boolean(importing), onPress: () => void importAndEdit(r), shrink: 0, children: [isBusy ? t('Importing…') : onForge ? t('Open in /dev') : t('Import & edit in /dev'), !isBusy ? _jsx(ArrowRight, { size: 13 }) : null] })] }, r.full_name));
|
|
434
|
+
})) })] }))) : tab === 'create' ? (_jsx(CreateGitHubRepoForm, { orgs: orgLogins, submitLabel: t('Create & edit in /dev'), onCreated: (r) => openCreatedOrForked(r, 'created'), onCancel: () => setTab('browse') })) : (_jsx(ForkGitHubRepoForm, { orgs: orgLogins, submitLabel: t('Fork & edit in /dev'), onForked: (r) => openCreatedOrForked(r, 'forked'), onCancel: () => setTab('browse') }))] }))] }) }));
|
|
435
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grip between two panes, one for every edge: the sidebar's, the side
|
|
3
|
+
* panel's, a run's chat against its work. The kit's Grip with its `inline` bar
|
|
4
|
+
* (drawn only while it is reached for), its band centred across the gutter and
|
|
5
|
+
* the bar halfway down it, so each edge looks and moves the same.
|
|
6
|
+
*
|
|
7
|
+
* side the edge the box it sits in is pinned to (Grip's): `left` for a
|
|
8
|
+
* sidebar, whose free edge is its right, `right` for an aside
|
|
9
|
+
* gap the gutter's width; the frame's `--pane-gap` by default
|
|
10
|
+
* inset the box's own border, px: an absolute place is measured inside it
|
|
11
|
+
*/
|
|
12
|
+
import { type GripProps } from '@hanzo/ui';
|
|
13
|
+
export type GutterProps = Omit<GripProps, 'bar'> & {
|
|
14
|
+
gap?: string | number;
|
|
15
|
+
inset?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function Gutter({ side, gap, inset, ...rest }: GutterProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The grip between two panes, one for every edge: the sidebar's, the side
|
|
4
|
+
* panel's, a run's chat against its work. The kit's Grip with its `inline` bar
|
|
5
|
+
* (drawn only while it is reached for), its band centred across the gutter and
|
|
6
|
+
* the bar halfway down it, so each edge looks and moves the same.
|
|
7
|
+
*
|
|
8
|
+
* side the edge the box it sits in is pinned to (Grip's): `left` for a
|
|
9
|
+
* sidebar, whose free edge is its right, `right` for an aside
|
|
10
|
+
* gap the gutter's width; the frame's `--pane-gap` by default
|
|
11
|
+
* inset the box's own border, px: an absolute place is measured inside it
|
|
12
|
+
*/
|
|
13
|
+
import { Grip } from '@hanzo/ui';
|
|
14
|
+
import { gap as GAP } from './pane.js';
|
|
15
|
+
export function Gutter({ side, gap = GAP, inset = 0, ...rest }) {
|
|
16
|
+
const g = typeof gap === 'number' ? `${gap}px` : gap;
|
|
17
|
+
// A CSS length gui takes as written; its types name only tokens and numbers.
|
|
18
|
+
const band = `max(8px, ${g})`;
|
|
19
|
+
// The band's start, so its middle is the gutter's: half the gutter and half the band out from the edge.
|
|
20
|
+
const at = (w) => `calc(-1 * (${g} + ${w}) / 2 - ${inset}px)`;
|
|
21
|
+
const edge = side === 'left' ? 'r' : 'l';
|
|
22
|
+
return (_jsx(Grip, { side: side, bar: "inline", justify: "center", width: band, [edge]: at(band),
|
|
23
|
+
// A finger's band, centred on the same line.
|
|
24
|
+
$touchable: { width: 44, [edge]: at('44px') }, ...rest }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What Chat's "Open in Dev" leaves in this tab's session storage for the New
|
|
3
|
+
* page to pick up: a prompt, and optionally some code to run it on. One key, one
|
|
4
|
+
* reader, so Chat and Dev cannot drift apart.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEV_HANDOFF = "hanzo.handoff.dev";
|
|
7
|
+
/** The draft the handoff makes, or '' for none; the handoff is consumed either way. */
|
|
8
|
+
export declare function takeHandoff(store: Pick<Storage, 'getItem' | 'removeItem'>): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What Chat's "Open in Dev" leaves in this tab's session storage for the New
|
|
3
|
+
* page to pick up: a prompt, and optionally some code to run it on. One key, one
|
|
4
|
+
* reader, so Chat and Dev cannot drift apart.
|
|
5
|
+
*/
|
|
6
|
+
export const DEV_HANDOFF = 'hanzo.handoff.dev';
|
|
7
|
+
/** The draft the handoff makes, or '' for none; the handoff is consumed either way. */
|
|
8
|
+
export function takeHandoff(store) {
|
|
9
|
+
try {
|
|
10
|
+
const raw = store.getItem(DEV_HANDOFF);
|
|
11
|
+
if (!raw)
|
|
12
|
+
return '';
|
|
13
|
+
store.removeItem(DEV_HANDOFF);
|
|
14
|
+
const h = JSON.parse(raw);
|
|
15
|
+
const text = (v) => (typeof v === 'string' ? v.trim() : '');
|
|
16
|
+
const code = text(h.code);
|
|
17
|
+
return [text(h.prompt), code && `\`\`\`${text(h.language)}\n${code}\n\`\`\``].filter(Boolean).join('\n\n');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
}
|