@hanzo/dev 4.1.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/{BinaryViewer-CmFUK4zZ.js → BinaryViewer-BCDMNW2g.js} +19 -19
  2. package/dist/{ChatMarkdown-nvEI7iCv.js → ChatMarkdown-BUidXqSs.js} +2460 -2460
  3. package/dist/{DevicePanel-v5e3sEIf.js → DevicePanel-D-pksK3r.js} +532 -532
  4. package/dist/{DeviceStreamView-CCIfmbxH.js → DeviceStreamView-DsCoOzDV.js} +377 -377
  5. package/dist/{DiffCommentAnnotation-BPTN_2a6.js → DiffCommentAnnotation-2HD5qiyt.js} +227 -227
  6. package/dist/{DiffFileTree-B_br90vY.js → DiffFileTree-CuWvI5hS.js} +13 -13
  7. package/dist/{DiffPanel-V5R5TPuK.js → DiffPanel-Z2QVmBzu.js} +328 -328
  8. package/dist/{DiffWorkerPoolProvider-BwFR-Fc9.js → DiffWorkerPoolProvider-CEfiCIGR.js} +3 -3
  9. package/dist/{DocumentPages-VSn83vty.js → DocumentPages-glImt2JO.js} +3 -3
  10. package/dist/{ExpandedImageDialog-CAorLacL.js → ExpandedImageDialog-iqO3LiIj.js} +404 -404
  11. package/dist/{FileExplorerPane-CeHulcPz.js → FileExplorerPane-GwnRmXEh.js} +4 -4
  12. package/dist/{FilePreviewPanel-BVNLvWOc.js → FilePreviewPanel-CXWpTlfI.js} +1089 -1089
  13. package/dist/{FontFilePreview-Dj8Blcay.js → FontFilePreview-CDydHOXg.js} +2 -2
  14. package/dist/{FontViewer-CLDdwhSr.js → FontViewer-DDt9C5Cb.js} +5 -5
  15. package/dist/{HanzoConnectAccountPages-BEzYfu2l.js → HanzoConnectAccountPages-_sfrtw9j.js} +357 -357
  16. package/dist/{HanzoConnectSidebarSignIn-BhD6-Up5.js → HanzoConnectSidebarSignIn-coFQvyRw.js} +3 -3
  17. package/dist/{Icons-CvSmt8vD.js → Icons-CdegMw5l.js} +1 -1
  18. package/dist/{LargeTextViewer-DfFnYGCw.js → LargeTextViewer-D3RklYQB.js} +8 -8
  19. package/dist/{MermaidDiagram-CTolIzQD.js → MermaidDiagram-sVLnox7j.js} +8 -8
  20. package/dist/{MermaidFilePreview-CP2zP4FU.js → MermaidFilePreview-BmPdNxW5.js} +2 -2
  21. package/dist/{MermaidViewer-BDfYkS9E.js → MermaidViewer-BlKTevTF.js} +3 -3
  22. package/dist/{NotebookPreview-Cybs5uM0.js → NotebookPreview-C0gSEyeO.js} +10 -10
  23. package/dist/{OfficeFilePreview-7JsmSoKU.js → OfficeFilePreview-Ago_DWEt.js} +2 -2
  24. package/dist/{OfficeViewer-CJoojlJK.js → OfficeViewer-DBRqtLet.js} +10 -10
  25. package/dist/{OpenInPicker-BIMWUxBP.js → OpenInPicker-DD_h7VLv.js} +287 -287
  26. package/dist/{OpenXmlOfficeViewer-C24Kj8DM.js → OpenXmlOfficeViewer-B4dxjpba.js} +4 -4
  27. package/dist/{PdfViewer-Cf1iD759.js → PdfViewer-BanXvPmz.js} +16 -16
  28. package/dist/{PreviewFaviconIcon-zFOuzIxe.js → PreviewFaviconIcon-BwYKB-3e.js} +892 -892
  29. package/dist/{PreviewImage-oY5YnuTr.js → PreviewImage-6UU-M6_B.js} +3 -3
  30. package/dist/{PreviewImageContent-n6eLzY99.js → PreviewImageContent-D-00K-A9.js} +3 -3
  31. package/dist/{PreviewPanel-Bo4Lt02m.js → PreviewPanel-CiuHdDv8.js} +489 -489
  32. package/dist/{PreviewPanelShell-DhXLeN5j.js → PreviewPanelShell-Dezxjg0T.js} +71 -71
  33. package/dist/{ProjectIconPickerDialog-D0kFzt8f.js → ProjectIconPickerDialog-LomrzROv.js} +29 -29
  34. package/dist/{ProjectMonogram-D35xrrXQ.js → ProjectMonogram-D21--FQY.js} +1 -1
  35. package/dist/{ProviderAuthTerminal-DfsXnu7A.js → ProviderAuthTerminal-pQXIfodT.js} +3 -3
  36. package/dist/{PullRequestCodeTab-Dv_0kVad.js → PullRequestCodeTab-Cqfh5eN2.js} +476 -476
  37. package/dist/{PullRequestReviewAnnotation-LeuwO-iH.js → PullRequestReviewAnnotation-B4Lp8Ktf.js} +334 -334
  38. package/dist/{ReadOnlySourcePreview-D__IA5g1.js → ReadOnlySourcePreview-7xXUUySV.js} +5 -5
  39. package/dist/{RelativeTime-BMRprQS8.js → RelativeTime-B_yprjav.js} +2 -2
  40. package/dist/{RightPanelResizeHandle-BLbSz-gk.js → RightPanelResizeHandle-PumvYb9P.js} +2 -2
  41. package/dist/{ThemeEditorPanel-CUDdsRsE.js → ThemeEditorPanel-BmXXpaCI.js} +196 -196
  42. package/dist/{ThreadTerminalDrawer-BF3Ix0q_.js → ThreadTerminalDrawer-DCgE3ojz.js} +461 -461
  43. package/dist/{VirtualTablePreview-dajviAfu.js → VirtualTablePreview-mA6DOFwb.js} +1 -1
  44. package/dist/{anchoredCopyToast-DnUtg1n_.js → anchoredCopyToast-BVa_dlBU.js} +2 -2
  45. package/dist/{assetUrls-DkY7vXfM.js → assetUrls-D8lRk7Xd.js} +45 -45
  46. package/dist/{browserLinkTarget-CA46wnQC.js → browserLinkTarget-BbVlDQYx.js} +18 -18
  47. package/dist/builder/api/git.d.ts +32 -4
  48. package/dist/builder/api/git.js +74 -4
  49. package/dist/builder/api/github.d.ts +54 -0
  50. package/dist/builder/api/github.js +103 -1
  51. package/dist/builder/api/models.d.ts +2 -0
  52. package/dist/builder/api/models.js +6 -1
  53. package/dist/builder/api/sandbox.d.ts +2 -0
  54. package/dist/builder/api/sandbox.js +3 -1
  55. package/dist/builder/desk.d.ts +6 -0
  56. package/dist/builder/desk.js +79 -14
  57. package/dist/builder/forge.js +79 -10
  58. package/dist/builder/github-sync.d.ts +70 -0
  59. package/dist/builder/github-sync.js +435 -0
  60. package/dist/builder/mind.d.ts +5 -5
  61. package/dist/builder/mind.js +35 -14
  62. package/dist/builder/pane.d.ts +1 -1
  63. package/dist/builder/pane.js +1 -1
  64. package/dist/builder/panel.js +5 -5
  65. package/dist/builder/preview-fallback.d.ts +47 -0
  66. package/dist/builder/preview-fallback.js +341 -0
  67. package/dist/builder/project.js +17 -4
  68. package/dist/builder/sync.js +27 -4
  69. package/dist/{changedFileKind-D6QYvIez.js → changedFileKind-DrjqPCpz.js} +5 -5
  70. package/dist/{collapsible-DFT41MdC.js → collapsible-CDT6JKbk.js} +1 -1
  71. package/dist/{color-picker-CshqBbpY.js → color-picker-kSVcH92L.js} +16 -16
  72. package/dist/core.js +1 -1
  73. package/dist/{decodeImagePreview-DnfFEjhw.js → decodeImagePreview-ZtWU3urU.js} +2 -2
  74. package/dist/{delimitedPreview-BiEpdYOj.js → delimitedPreview-DbbXcqOT.js} +1 -1
  75. package/dist/{dialog-DhQtWGRa.js → dialog-EmpqFZiK.js} +40 -40
  76. package/dist/{embed-c030vUqM.js → embed-CPWZKyIW.js} +36098 -35677
  77. package/dist/{empty-Bm5EzcG8.js → empty-ChM6gdzn.js} +1 -1
  78. package/dist/{errors-DrFQSJW3.js → errors-D8_Zn8KN.js} +2 -2
  79. package/dist/{fileContextMenu-BBo91omq.js → fileContextMenu-DW94DZj4.js} +54 -54
  80. package/dist/{fileExplorerLabel-AikEChiS.js → fileExplorerLabel-Cfz-3q1U.js} +507 -507
  81. package/dist/{fileSurfaceChrome-Cqkvn8RQ.js → fileSurfaceChrome-BDyKklTq.js} +26 -26
  82. package/dist/{hanzoWebAnalytics-CCxpTzcI.js → hanzoWebAnalytics-B1eETW-7.js} +1 -1
  83. package/dist/index.css +1 -1
  84. package/dist/{input-group-DEJEuwc9.js → input-group-BZ_QN-y7.js} +1 -1
  85. package/dist/{keybindings-C5tK_GAk.js → keybindings-D0pBlT1k.js} +7812 -7806
  86. package/dist/keymap.js +1 -1
  87. package/dist/{lucideIconByName-DUaXKH0V.js → lucideIconByName-CXY44V8P.js} +6835 -6848
  88. package/dist/{mediaReference-Bt_mh-ag.js → mediaReference-3wc4ZfY8.js} +95 -95
  89. package/dist/mediaSource-jW5c7b4r.js +70 -0
  90. package/dist/{modelPickerVisibility-Jue3CLfc.js → modelPickerVisibility-DBTc5r1G.js} +1 -1
  91. package/dist/{network-BbwqRm8c.js → network-wuXD7-is.js} +1 -1
  92. package/dist/{popover-anNQdce7.js → popover-BAyP2Tdr.js} +1 -1
  93. package/dist/{presentation-D9mVPBHm.js → presentation-68y8EAuH.js} +299 -299
  94. package/dist/{previewFailureMessages-BKpsSGX5.js → previewFailureMessages-CFguipaK.js} +3 -3
  95. package/dist/query-BPk2W3QN.js +63 -0
  96. package/dist/{readBinaryPreview-BAQ4fFjm.js → readBinaryPreview-CjZdBNVR.js} +2 -2
  97. package/dist/{refresh-icon-BYx64to1.js → refresh-icon-Vo5ImiQL.js} +1 -1
  98. package/dist/{scroll-area-ChvX8uOh.js → scroll-area-CEoyjC7h.js} +1 -1
  99. package/dist/{select-DumYjny_.js → select-DLFnkZsI.js} +2 -2
  100. package/dist/{session-_kmiSv2A.js → session-Decc4Fo5.js} +1063 -1063
  101. package/dist/{skeleton-CJqwfMSF.js → skeleton-BOKpAZv6.js} +1 -1
  102. package/dist/{switch-COwevwaq.js → switch-DjpPjtQN.js} +2 -2
  103. package/dist/{themePalette-Dl_7omVL.js → themePalette-C-GtwwqV.js} +977 -977
  104. package/dist/{threadSearch-BHyWwcV3.js → threadSearch-CrtCof6n.js} +162 -162
  105. package/dist/{toggle-CEO6qTxB.js → toggle-B4F0EEtI.js} +1 -1
  106. package/dist/{toggle-group-BHovdMDl.js → toggle-group-l8hRPswr.js} +2 -2
  107. package/dist/{use-atom-command-ByoYq_K6.js → use-atom-command-XemtT1Gv.js} +1 -1
  108. package/dist/{useAriaLabelledBy-DPSISlnL.js → useAriaLabelledBy-CibvSz-b.js} +1 -1
  109. package/dist/{useFileMetadata-e7zsixVX.js → useFileMetadata-PesehDX0.js} +33 -33
  110. package/dist/{useFloatingRootContext-CJ9stHca.js → useFloatingRootContext-ppoGvqar.js} +1 -1
  111. package/dist/{useLiveRefresh-BkKJKXhH.js → useLiveRefresh-aHkPuz6N.js} +172 -172
  112. package/dist/{useNextRenderData-CyUmSAgz.js → useNextRenderData-CNhjWfP0.js} +1 -1
  113. package/dist/{useSettings-DYG9Dmro.js → useSettings-B_MtcTyD.js} +139 -139
  114. package/dist/{useTextFieldSpeech-COa9XcRx.js → useTextFieldSpeech-B1wCgLPO.js} +1404 -1404
  115. package/dist/{useTheme-D2ZM1gvV.js → useTheme-WlXpQRKG.js} +4 -4
  116. package/dist/{utils-515nQ17G.js → utils-DtKQl-D3.js} +6184 -6172
  117. package/dist/{wizard-i86ViMRc.js → wizard-DjD4UNew.js} +3 -3
  118. package/dist/{workspaceFocus-BV1_9KiH.js → workspaceFocus-MR1plm6A.js} +144 -144
  119. package/dist/{zap-e0OsRjBR.js → zap-iwsUKtvA.js} +30 -17
  120. package/package.json +1 -1
  121. package/dist/mediaSource-zI7JWid4.js +0 -70
  122. package/dist/query-BxrrBAp6.js +0 -63
@@ -43,9 +43,9 @@ const SHORTCUTS = 'Control+Shift+B Meta+Shift+B Control+Period Meta+Period';
43
43
  const BLANK = phrase('New tab');
44
44
  /** On an icon that points along the line (Back, Forward): it turns in a right-to-left page. */
45
45
  const MIRROR = { 'data-i18n-mirror': '' };
46
- /** The row heights, px: the strip (the conversation header's row), and a page's bar. */
47
- const STRIP = 56;
48
- const BAR = 48;
46
+ /** The row heights, px: the strip (aligned to the host shell's 40px top-right bar), and a page's bar. */
47
+ const STRIP = 40;
48
+ const BAR = 44;
49
49
  /** A round control in a page's bar, px. */
50
50
  const PILL = 34;
51
51
  /** A press on an icon control of the panel's: quiet until pointed at, lit while its thing is open. */
@@ -322,7 +322,7 @@ function Leaf({ tab, on, side, index, label, icon }) {
322
322
  /** The tab itself, as the strip draws it. */
323
323
  function Strip({ tab, on, side, index, label, icon, ...rest }) {
324
324
  const { t } = useI18n();
325
- return (_jsxs(XStack, { ...rest, "data-slot": "side-tab", "data-tab": tab.id, items: "center", gap: "$1", pl: "$2.5", pr: on || tab.pinned ? '$1' : '$2.5', minH: 32, "$max-md": { minH: 40 },
325
+ return (_jsxs(XStack, { ...rest, "data-slot": "side-tab", "data-tab": tab.id, items: "center", gap: "$1", pl: "$2.5", pr: on || tab.pinned ? '$1' : '$2.5', minH: 28, "$max-md": { minH: 36 },
326
326
  // Keep every tab label legible at narrow viewports; the tablist scrolls horizontally instead of crushing tabs.
327
327
  shrink: 0, maxW: 220, rounded: 8, borderWidth: 1, borderColor: on ? '$borderColor' : 'transparent', bg: on ? '$edge' : 'transparent', hoverStyle: { bg: on ? '$edge' : '$hover' }, style: { flexShrink: 0 }, ...{
328
328
  // A middle press shuts any tab, as a browser's does; the chosen one also has its cross.
@@ -397,7 +397,7 @@ export function Panel({ side, kinds, onHide, sheet = false, bar, menu, label, su
397
397
  const body = (_jsxs(YStack, { role: "complementary", "aria-label": label ?? say('Side panel'), "data-slot": "side", flex: 1, minW: 0, minH: 0, overflow: "hidden", rounded: "inherit", children: [_jsxs(XStack, { "data-slot": "side-strip", height: STRIP, px: "$2", gap: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, minW: 0, style: topRightInset ? { paddingInlineEnd: 'calc(8px + var(--hanzo-shell-top-right-inset, 0px))' } : undefined, children: [column?.hidden && !column.full ? (_jsxs(XStack, { render: "button", "data-slot": "side-show", onPress: column.show, minH: 32, px: "$2", gap: "$1.5", ...quiet(), children: [_jsx(PanelLeftOpen, { size: 16 }), _jsx(SizableText, { fontSize: 13, color: "$ink", children: column.main === 'run' ? say('Show session') : column.main === 'chat' ? say('Show chat') : say('Show {main}', { main: column.main }) })] })) : null, _jsx(XStack, { role: "tablist", "aria-label": say('Tabs'), flex: 1, minW: 0, gap: "$1", items: "center", overflowX: "auto", overflowY: "hidden", "$platform-web": { scrollbarWidth: 'none', msOverflowStyle: 'none', WebkitOverflowScrolling: 'touch' }, children: side.tabs.map((t, i) => (_jsx(Leaf, { tab: t, on: t.id === side.at, side: side, index: i, label: title(t), icon: mark(t) }, t.id))) }), closed.length ? (_jsx(DropdownMenu, { trigger: plus, items: [
398
398
  ...closed.map((k) => ({ key: k.id, label: k.label, onSelect: () => side.open({ kind: k.id, title: k.label }) })),
399
399
  { key: PAGE, label: say('Page'), description: say('An address, framed here'), onSelect: blank },
400
- ] })) : (plus), menu, _jsx(XStack, { render: "button", "aria-label": say('Open this tab in a new window'), ...{ title: say('Open this tab in a new window') }, "aria-disabled": !poppable || undefined, onPress: poppable ? () => popOut(tab) : undefined, width: 28, height: 28, ...quiet(false, !poppable), children: _jsx(ExternalLink, { size: 14 }) }), column ? (_jsx(XStack, { render: "button", "data-slot": "side-full", "aria-label": column.full ? say('Exit full screen') : say('Full screen'), "aria-pressed": column.full, "aria-keyshortcuts": column.full ? 'Escape' : undefined, ...{ title: column.full ? say('Exit full screen ({key})', { key: 'Esc' }) : say('Full screen') }, onPress: () => column.fill(!column.full), width: 28, height: 28, ...quiet(column.full), children: column.full ? _jsx(Minimize2, { size: 14 }) : _jsx(Maximize2, { size: 14 }) })) : null, _jsx(XStack, { render: "button", "data-slot": "side-toggle", "aria-label": say('Hide tabs'), "aria-expanded": true, "aria-keyshortcuts": SHORTCUTS, ...{ title: say('Hide tabs ({keys})', { keys: KEYS }) }, onPress: onHide, width: 32, height: 32, ...quiet(true), children: _jsx(Columns2, { size: 16 }) })] }), bar, _jsx(YStack, { id: "side-body", role: "tabpanel", "aria-labelledby": tab ? `side-tab-${tab.id}` : undefined,
400
+ ] })) : (plus), menu, _jsx(XStack, { render: "button", "aria-label": say('Open this tab in a new window'), ...{ title: say('Open this tab in a new window') }, "aria-disabled": !poppable || undefined, onPress: poppable ? () => popOut(tab) : undefined, width: 28, height: 28, ...quiet(false, !poppable), children: _jsx(ExternalLink, { size: 14 }) }), column ? (_jsx(XStack, { render: "button", "data-slot": "side-full", "aria-label": column.full ? say('Exit full screen') : say('Full screen'), "aria-pressed": column.full, "aria-keyshortcuts": column.full ? 'Escape' : undefined, ...{ title: column.full ? say('Exit full screen ({key})', { key: 'Esc' }) : say('Full screen') }, onPress: () => column.fill(!column.full), width: 28, height: 28, ...quiet(column.full), children: column.full ? _jsx(Minimize2, { size: 14 }) : _jsx(Maximize2, { size: 14 }) })) : null, _jsx(XStack, { render: "button", "data-slot": "side-toggle", "aria-label": say('Hide tabs'), "aria-expanded": true, "aria-keyshortcuts": SHORTCUTS, ...{ title: say('Hide tabs ({keys})', { keys: KEYS }) }, onPress: onHide, width: 28, height: 28, ...quiet(true), children: _jsx(Columns2, { size: 15 }) })] }), bar, _jsx(YStack, { id: "side-body", role: "tabpanel", "aria-labelledby": tab ? `side-tab-${tab.id}` : undefined,
401
401
  // What a tab lays over itself (a door's "Connecting…") stays inside it, under the strip.
402
402
  position: "relative", flex: 1, minH: 0, overflowY: bleed ? 'hidden' : 'auto', overflowX: "hidden", px: bleed ? 0 : '$3', py: bleed ? 0 : '$3', children: !tab ? (_jsx(YStack, { flex: 1, items: "center", justify: "center", p: "$5", children: _jsx(SizableText, { fontSize: 13, color: "$soft", children: say('No tabs open.') }) })) : tab.kind === PAGE ? (_jsx(Page, { tab: tab, onGo: (url) => side.go(tab.id, url), onBack: () => side.back(tab.id), onForward: () => side.forward(tab.id), onTitle: (t) => side.rename(tab.id, t), onPin: (on) => (on ? side.pin(tab.id) : side.unpin(tab.id)), suggested: suggested, ...acts }, tab.id)) : kind ? (_jsx(Fragment, { children: kind.render() }, tab.id)) : (_jsx(SizableText, { size: "$2", color: "$soft", children: say('This tab is not offered here.') })) })] }));
403
403
  if (!sheet || typeof document === 'undefined')
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Fallback preview resolver when no live sandbox preview / published site is serving:
3
+ * session-edited file -> project README.md -> first readable workspace file -> null.
4
+ */
5
+ import type { Target } from './api/call.ts';
6
+ import type { Event } from './api/sessions.ts';
7
+ export type FallbackPreviewFormat = 'markdown' | 'html' | 'svg' | 'image' | 'code';
8
+ export type FallbackPreviewSource = 'session' | 'readme' | 'repo';
9
+ export interface FallbackPreview {
10
+ path: string;
11
+ format: FallbackPreviewFormat;
12
+ source: FallbackPreviewSource;
13
+ /** UTF-8 file text for markdown, html, svg, and code previews. */
14
+ text: string;
15
+ /** Data URL or direct URL for image previews. */
16
+ imageUrl?: string;
17
+ }
18
+ export declare function previewFormatOf(path: string): FallbackPreviewFormat;
19
+ export declare function imageMimeOf(path: string): string;
20
+ /** Minimal sandboxed HTML wrapper for inline `.svg` previews. */
21
+ export declare function svgPreviewDocument(svg: string): string;
22
+ /**
23
+ * Extract the paths created or modified during this session in most-recent-first order.
24
+ * Deleted files are removed from the result unless recreated later.
25
+ */
26
+ export declare function sessionEditedPaths(events: readonly Pick<Event, 'kind' | 'payload' | 'seq'>[]): string[];
27
+ /** Candidate raw GitHub URLs for `path` across the session's ref and default branches. */
28
+ export declare function githubRawUrls(repo: string, refs: readonly string[], path: string): string[];
29
+ export interface ResolveFallbackInput {
30
+ target: Target;
31
+ session: string;
32
+ sandbox: string;
33
+ running: boolean;
34
+ signed: boolean;
35
+ repo: string;
36
+ branch: string;
37
+ base: string;
38
+ events: readonly Pick<Event, 'kind' | 'payload' | 'seq'>[];
39
+ signal?: AbortSignal;
40
+ }
41
+ /**
42
+ * Resolve the best fallback preview when no live dev server or deployed site is serving:
43
+ * 1. Most recently created/modified file in the session (events / changes / artifacts)
44
+ * 2. Project README.md (or first readable root file when no README exists)
45
+ * 3. `null` only when there are genuinely zero files
46
+ */
47
+ export declare function resolveFallbackPreview(input: ResolveFallbackInput): Promise<FallbackPreview | null>;
@@ -0,0 +1,341 @@
1
+ import { blob as sessionBlob, read as readChanges, tree as sessionTree } from './api/changes.js';
2
+ import { artifact, artifacts } from './api/coding.js';
3
+ import { blob as gitBlob, parseGitHubRepo } from './api/git.js';
4
+ import { read as sandboxRead } from './api/sandbox.js';
5
+ import { decode } from './api/turn.js';
6
+ const IMAGE_MIMES = {
7
+ png: 'image/png',
8
+ jpg: 'image/jpeg',
9
+ jpeg: 'image/jpeg',
10
+ gif: 'image/gif',
11
+ webp: 'image/webp',
12
+ avif: 'image/avif',
13
+ ico: 'image/x-icon',
14
+ svg: 'image/svg+xml',
15
+ };
16
+ const MARKDOWN_EXTS = new Set(['md', 'mdx', 'markdown']);
17
+ const HTML_EXTS = new Set(['html', 'htm']);
18
+ const README_NAMES = ['README.md', 'readme.md', 'Readme.md', 'README.MD', 'README.mdx', 'README.txt', 'README'];
19
+ const PREFERRED_FALLBACK_FILES = ['index.html', 'package.json', 'Cargo.toml', 'pyproject.toml', 'go.mod'];
20
+ const str = (v) => (typeof v === 'string' ? v : '');
21
+ const rel = (path) => path.trim().replace(/^\/work\//, '').replace(/^\.\//, '');
22
+ function extOf(path) {
23
+ const base = path.split('/').pop() ?? path;
24
+ const dot = base.lastIndexOf('.');
25
+ return dot > 0 ? base.slice(dot + 1).toLowerCase() : '';
26
+ }
27
+ export function previewFormatOf(path) {
28
+ const ext = extOf(path);
29
+ if (MARKDOWN_EXTS.has(ext))
30
+ return 'markdown';
31
+ if (HTML_EXTS.has(ext))
32
+ return 'html';
33
+ if (ext === 'svg')
34
+ return 'svg';
35
+ if (ext in IMAGE_MIMES)
36
+ return 'image';
37
+ return 'code';
38
+ }
39
+ export function imageMimeOf(path) {
40
+ return IMAGE_MIMES[extOf(path)] ?? 'application/octet-stream';
41
+ }
42
+ /** Minimal sandboxed HTML wrapper for inline `.svg` previews. */
43
+ export function svgPreviewDocument(svg) {
44
+ return `<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:16px;height:100%;box-sizing:border-box;display:flex;align-items:center;justify-content:center;background:transparent;}svg{max-width:100%;max-height:100%;height:auto;}</style></head><body>${svg}</body></html>`;
45
+ }
46
+ /**
47
+ * Extract the paths created or modified during this session in most-recent-first order.
48
+ * Deleted files are removed from the result unless recreated later.
49
+ */
50
+ export function sessionEditedPaths(events) {
51
+ const ordered = [];
52
+ const touch = (rawPath) => {
53
+ const p = rel(rawPath);
54
+ if (!p)
55
+ return;
56
+ const idx = ordered.indexOf(p);
57
+ if (idx >= 0)
58
+ ordered.splice(idx, 1);
59
+ ordered.push(p);
60
+ };
61
+ const remove = (rawPath) => {
62
+ const p = rel(rawPath);
63
+ const idx = ordered.indexOf(p);
64
+ if (idx >= 0)
65
+ ordered.splice(idx, 1);
66
+ };
67
+ for (const e of [...events].sort((a, b) => a.seq - b.seq)) {
68
+ const body = decode(e.payload);
69
+ if (!body || typeof body === 'string')
70
+ continue;
71
+ if (e.kind === 'event') {
72
+ const item = body.item && typeof body.item === 'object' ? body.item : null;
73
+ if (item && str(item.type) === 'file_change' && Array.isArray(item.changes)) {
74
+ for (const c of item.changes) {
75
+ if (!c || typeof c !== 'object')
76
+ continue;
77
+ const change = c;
78
+ const p = str(change.path);
79
+ if (!p)
80
+ continue;
81
+ if (change.kind === 'delete')
82
+ remove(p);
83
+ else
84
+ touch(p);
85
+ }
86
+ }
87
+ }
88
+ else if (e.kind === 'status' && Array.isArray(body.changed)) {
89
+ for (const entry of body.changed) {
90
+ if (typeof entry === 'string')
91
+ touch(entry);
92
+ }
93
+ }
94
+ }
95
+ return ordered.reverse();
96
+ }
97
+ /** Candidate raw GitHub URLs for `path` across the session's ref and default branches. */
98
+ export function githubRawUrls(repo, refs, path) {
99
+ const parsed = parseGitHubRepo(repo);
100
+ if (!parsed)
101
+ return [];
102
+ const encodedPath = path
103
+ .split('/')
104
+ .filter(Boolean)
105
+ .map((segment) => encodeURIComponent(segment))
106
+ .join('/');
107
+ if (!encodedPath)
108
+ return [];
109
+ const uniqueRefs = [];
110
+ for (const ref of [...refs, 'main', 'master']) {
111
+ const trimmed = ref.trim();
112
+ if (trimmed && !uniqueRefs.includes(trimmed))
113
+ uniqueRefs.push(trimmed);
114
+ }
115
+ return uniqueRefs.map((ref) => `https://raw.githubusercontent.com/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.name)}/${encodeURIComponent(ref)}/${encodedPath}`);
116
+ }
117
+ function isReadmeName(name) {
118
+ const lower = name.toLowerCase();
119
+ return lower === 'readme.md' || lower === 'readme.mdx' || lower === 'readme.txt' || lower === 'readme';
120
+ }
121
+ function pickRootFile(names) {
122
+ const readme = names.find((n) => isReadmeName(n));
123
+ if (readme)
124
+ return { name: readme, isReadme: true };
125
+ for (const preferred of PREFERRED_FALLBACK_FILES) {
126
+ const match = names.find((n) => n.toLowerCase() === preferred.toLowerCase());
127
+ if (match)
128
+ return { name: match, isReadme: false };
129
+ }
130
+ const firstVisible = names.find((n) => n && !n.startsWith('.') && !n.endsWith('.lock') && n !== 'node_modules');
131
+ return firstVisible ? { name: firstVisible, isReadme: false } : null;
132
+ }
133
+ async function blobToDataUrl(blob, mime) {
134
+ const bytes = new Uint8Array(await blob.arrayBuffer());
135
+ let binary = '';
136
+ for (let i = 0; i < bytes.length; i++)
137
+ binary += String.fromCharCode(bytes[i]);
138
+ return `data:${mime};base64,${btoa(binary)}`;
139
+ }
140
+ async function fetchRawText(urls, signal) {
141
+ if (typeof fetch !== 'function')
142
+ return null;
143
+ for (const url of urls) {
144
+ if (signal?.aborted)
145
+ return null;
146
+ try {
147
+ const res = await fetch(url, { signal });
148
+ if (res.ok) {
149
+ const text = await res.text();
150
+ if (text.trim())
151
+ return text;
152
+ }
153
+ }
154
+ catch {
155
+ // Try next branch/source.
156
+ }
157
+ }
158
+ return null;
159
+ }
160
+ async function loadPath(path, source, input, artifactNames, changeByPath) {
161
+ if (input.signal?.aborted)
162
+ return null;
163
+ const format = previewFormatOf(path);
164
+ const ref = input.branch || input.base || 'main';
165
+ if (format === 'image') {
166
+ const mime = imageMimeOf(path);
167
+ if (input.running && input.sandbox) {
168
+ const node = await sandboxRead(input.target, input.sandbox, path).catch(() => null);
169
+ if (node && !node.dir && !node.truncated && node.base64) {
170
+ return { path, format, source, text: '', imageUrl: `data:${mime};base64,${node.base64}` };
171
+ }
172
+ }
173
+ if (input.signed && input.session && artifactNames.has(path)) {
174
+ const data = await artifact(input.target, input.session, path).catch(() => null);
175
+ if (data) {
176
+ const imageUrl = await blobToDataUrl(data, mime).catch(() => '');
177
+ if (imageUrl)
178
+ return { path, format, source, text: '', imageUrl };
179
+ }
180
+ }
181
+ const rawUrls = githubRawUrls(input.repo, [input.branch, input.base], path);
182
+ if (rawUrls.length > 0 && typeof fetch === 'function') {
183
+ for (const url of rawUrls) {
184
+ if (input.signal?.aborted)
185
+ return null;
186
+ try {
187
+ const res = await fetch(url, { method: 'HEAD', signal: input.signal });
188
+ if (res.ok)
189
+ return { path, format, source, text: '', imageUrl: url };
190
+ }
191
+ catch {
192
+ // Try next ref.
193
+ }
194
+ }
195
+ }
196
+ return null;
197
+ }
198
+ // 1. Live sandbox file (uncommitted edits included; never wakes a parked sandbox).
199
+ if (input.running && input.sandbox) {
200
+ const node = await sandboxRead(input.target, input.sandbox, path).catch(() => null);
201
+ if (node && !node.dir && !node.binary && !node.truncated && node.text !== '') {
202
+ return { path, format, source, text: node.text };
203
+ }
204
+ }
205
+ // 2. Session branch blob via coding API.
206
+ if (input.signed && input.session) {
207
+ const b = await sessionBlob(input.target, input.session, path).catch(() => null);
208
+ if (b && !b.binary && !b.truncated && b.text !== '') {
209
+ return { path, format, source, text: b.text };
210
+ }
211
+ }
212
+ // 3. Stored session artifact bytes.
213
+ if (input.signed && input.session && artifactNames.has(path)) {
214
+ const data = await artifact(input.target, input.session, path).catch(() => null);
215
+ if (data) {
216
+ const text = await data.text().catch(() => '');
217
+ if (text !== '')
218
+ return { path, format, source, text };
219
+ }
220
+ }
221
+ // 4. Platform git repo blob.
222
+ if (input.signed && input.repo) {
223
+ const b = await gitBlob(input.target, input.repo, ref, path).catch(() => null);
224
+ if (b && !b.binary && !b.truncated && b.text !== '') {
225
+ return { path, format, source, text: b.text };
226
+ }
227
+ }
228
+ // 5. GitHub raw fallback when repo is known.
229
+ if (input.repo) {
230
+ const text = await fetchRawText(githubRawUrls(input.repo, [input.branch, input.base], path), input.signal);
231
+ if (text !== null)
232
+ return { path, format, source, text };
233
+ }
234
+ // 6. Diff patch fallback when a session modified the file but full bytes are unavailable.
235
+ const change = changeByPath.get(path);
236
+ if (change?.patch) {
237
+ return { path, format: 'code', source, text: change.patch };
238
+ }
239
+ return null;
240
+ }
241
+ /**
242
+ * Resolve the best fallback preview when no live dev server or deployed site is serving:
243
+ * 1. Most recently created/modified file in the session (events / changes / artifacts)
244
+ * 2. Project README.md (or first readable root file when no README exists)
245
+ * 3. `null` only when there are genuinely zero files
246
+ */
247
+ export async function resolveFallbackPreview(input) {
248
+ if (input.signal?.aborted)
249
+ return null;
250
+ const [changesResult, artifactsResult] = input.signed && input.session
251
+ ? await Promise.all([
252
+ readChanges(input.target, input.session).catch(() => null),
253
+ artifacts(input.target, input.session).catch(() => null),
254
+ ])
255
+ : [null, null];
256
+ if (input.signal?.aborted)
257
+ return null;
258
+ const changeByPath = new Map();
259
+ const changePaths = [];
260
+ for (const f of changesResult?.files ?? []) {
261
+ if (f.status === 'deleted')
262
+ continue;
263
+ const p = rel(f.path);
264
+ if (!p)
265
+ continue;
266
+ changeByPath.set(p, f);
267
+ changePaths.push(p);
268
+ }
269
+ const artifactNames = new Set();
270
+ const artifactPaths = [];
271
+ for (const a of artifactsResult?.artifacts ?? []) {
272
+ if (a.kind !== 'file')
273
+ continue;
274
+ const p = rel(a.name);
275
+ if (!p)
276
+ continue;
277
+ artifactNames.add(p);
278
+ artifactPaths.push(p);
279
+ }
280
+ const editedCandidates = [];
281
+ const addCandidate = (p) => {
282
+ if (p && !editedCandidates.includes(p))
283
+ editedCandidates.push(p);
284
+ };
285
+ for (const p of sessionEditedPaths(input.events))
286
+ addCandidate(p);
287
+ for (const p of changePaths)
288
+ addCandidate(p);
289
+ for (const p of artifactPaths)
290
+ addCandidate(p);
291
+ // Step 2: Most recently created/modified file in this session.
292
+ for (const path of editedCandidates.slice(0, 5)) {
293
+ const found = await loadPath(path, 'session', input, artifactNames, changeByPath);
294
+ if (found)
295
+ return found;
296
+ }
297
+ if (input.signal?.aborted)
298
+ return null;
299
+ // Step 3: Project README.md (or first readable root file if repo has files without a README).
300
+ if (input.running && input.sandbox) {
301
+ const root = await sandboxRead(input.target, input.sandbox, '').catch(() => null);
302
+ if (root?.dir && root.names.length > 0) {
303
+ const picked = pickRootFile(root.names);
304
+ if (picked) {
305
+ const found = await loadPath(picked.name, picked.isReadme ? 'readme' : 'repo', input, artifactNames, changeByPath);
306
+ if (found)
307
+ return found;
308
+ }
309
+ }
310
+ }
311
+ if (input.signed && input.session) {
312
+ const entries = await sessionTree(input.target, input.session, '').catch(() => []);
313
+ const fileNames = entries.filter((e) => !e.dir).map((e) => e.path);
314
+ if (fileNames.length > 0) {
315
+ const picked = pickRootFile(fileNames);
316
+ if (picked) {
317
+ const found = await loadPath(picked.name, picked.isReadme ? 'readme' : 'repo', input, artifactNames, changeByPath);
318
+ if (found)
319
+ return found;
320
+ }
321
+ }
322
+ }
323
+ if (input.repo) {
324
+ const ref = input.branch || input.base || 'main';
325
+ if (input.signed) {
326
+ for (const readme of README_NAMES.slice(0, 2)) {
327
+ const b = await gitBlob(input.target, input.repo, ref, readme).catch(() => null);
328
+ if (b && !b.binary && !b.truncated && b.text !== '') {
329
+ return { path: readme, format: previewFormatOf(readme), source: 'readme', text: b.text };
330
+ }
331
+ }
332
+ }
333
+ for (const readme of README_NAMES.slice(0, 2)) {
334
+ const text = await fetchRawText(githubRawUrls(input.repo, [input.branch, input.base], readme), input.signal);
335
+ if (text !== null) {
336
+ return { path: readme, format: previewFormatOf(readme), source: 'readme', text };
337
+ }
338
+ }
339
+ }
340
+ return null;
341
+ }
@@ -44,7 +44,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
44
44
  */
45
45
  import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
46
46
  import { useI18n } from '@hanzo/i18n/react';
47
- import { AlertCircle, Check, Clock, ExternalLink, Globe, MousePointerClick, PanelLeft, RefreshCcw, Search, Share2, Square, Upload, } from '@hanzogui/lucide-icons-2';
47
+ import { AlertCircle, Check, Clock, ExternalLink, Github, Globe, MousePointerClick, PanelLeft, RefreshCcw, Search, Share2, Square, Upload, } from '@hanzogui/lucide-icons-2';
48
48
  import { Attachments, CHAT, Console, DEVICES, Feedback, FileTabs, FileTree, PageSelect, PreviewFrame, ProjectChip, VIEWS, Views, Workspace, fold, } from '@hanzo/ui/agents';
49
49
  import { Composer, Message } from '@hanzo/ui/chat';
50
50
  import { Button, Dialog, DialogContent, DialogTitle, Input, Skeleton, toast } from '@hanzo/ui';
@@ -57,7 +57,8 @@ import { RING } from './pane.js';
57
57
  import { read as pushed } from './api/changes.js';
58
58
  import { codebases, one } from './api/codebases.js';
59
59
  import { start, steer as steerCoding } from './api/coding.js';
60
- import { blob, tree } from './api/git.js';
60
+ import { blob, listGitTargets, tree } from './api/git.js';
61
+ import { githubRepoFrom } from './api/github.js';
61
62
  import { limits as readLimits } from './api/models.js';
62
63
  import { declare } from './api/platform.js';
63
64
  import { address, deployments, name as repoName, ours, templates } from './api/projects.js';
@@ -67,6 +68,7 @@ import { decode, followed, outcome, pull, said, scrub, who } from './api/turn.js
67
68
  import { verdict as record } from './api/verdict.js';
68
69
  import { useKept, useProjects, useRead, useRun } from './data.js';
69
70
  import { Merge } from './git.js';
71
+ import { GitHubBadge, SyncToGitHubDialog } from './github-sync.js';
70
72
  import { Gutter } from './gutter.js';
71
73
  import { useHost, useTarget } from './host.js';
72
74
  import { cacheBustUrl, previewRevision, resolvePreviewSource } from './preview-url.js';
@@ -321,6 +323,14 @@ export function Project({ at }) {
321
323
  // Files and Code: native git, at the branch the open run pushed (or the project's own).
322
324
  const repo = named ? named.name : project?.repo ? repoName(project.repo) : '';
323
325
  const ref = run.record?.branch || home;
326
+ // Outbound GitHub mirror targets: shows a GitHub badge when synced, or "Sync to GitHub" when Hanzo Git only.
327
+ const gitTargets = useRead(signed && repo ? () => listGitTargets(target, repo).catch(() => []) : null, [], [target, signed, repo]);
328
+ const [syncDialogOpen, setSyncDialogOpen] = useState(false);
329
+ const [syncedGitHub, setSyncedGitHub] = useState(null);
330
+ useEffect(() => {
331
+ setSyncedGitHub(null);
332
+ }, [repo]);
333
+ const githubInfo = useMemo(() => syncedGitHub ?? githubRepoFrom(project?.repo || clone || '', gitTargets.value), [syncedGitHub, project?.repo, clone, gitTargets.value]);
324
334
  const [files, setFiles] = useState([]);
325
335
  const [file, setFile] = useState(null);
326
336
  useEffect(() => {
@@ -566,7 +576,7 @@ export function Project({ at }) {
566
576
  // So below md they take a row of their own under the bar, in whichever pane
567
577
  // shows (one pane at a time there, so one row).
568
578
  const row = wide ? null : (_jsx(XStack, { "data-slot": "views-row", justify: "center", px: "$3", pb: "$2", shrink: 0, minW: 0, overflowX: "auto", "$platform-web": { scrollbarWidth: 'none' }, children: views }));
569
- return (_jsxs(_Fragment, { children: [_jsxs(Workspace, { start: _jsxs(XStack, { items: "center", gap: "$2", minW: 0, shrink: 1, children: [_jsx(XStack, { render: "button", "aria-label": t('All sessions'), ...{ title: t('All sessions') }, onPress: () => host.go(''), p: "$1", "$max-md": { minW: 40, minH: 40, items: 'center', justify: 'center' }, shrink: 0, children: _jsx(HanzoMark, { size: 20 }) }), _jsx(ProjectChip, { name: title, onPress: () => setSwitcher(true) }), _jsx(XStack, { render: "button", "aria-label": t('History'), ...{ title: t('History') }, onPress: () => setHistory(true), p: "$1.5", "$max-md": { minW: 40, minH: 40, items: 'center', justify: 'center' }, rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, children: _jsx(Clock, { size: 16 }) }), _jsx(XStack, { render: "button", "aria-label": shut ? t('Show the chat') : t('Hide the chat'), ...{ title: shut ? t('Show the chat') : t('Hide the chat') }, "aria-pressed": !shut, onClick: () => (cramped ? setAsked(!asked) : setCollapsed(!collapsed)), minW: 32, minH: 32, items: "center", justify: "center", rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$max-md": { display: 'none' }, children: _jsx(PanelLeft, { size: 16 }) })] }), middle: wide ? views : undefined, end: _jsxs(XStack, { "data-slot": "project-header-actions", items: "center", gap: "$2", shrink: 0, style: { paddingInlineEnd: 'var(--hanzo-shell-top-right-inset, 0px)' }, children: [_jsx(XStack, { display: "none", $md: { display: 'flex' }, shrink: 0, children: _jsxs(Button, { variant: "outline", size: "sm", onPress: () => void share(), children: [_jsx(Share2, { size: 14 }), " ", t('Share')] }) }), _jsxs(Button, { size: "sm", variant: "primary", "aria-label": t('Publish'), disabled: !clone || !slug, onPress: () => setPublish({ repo: clone, title, ref, name: slug, project: slug, preview: project?.live || undefined }), shrink: 0, children: [_jsx(Upload, { size: 14 }), _jsx(SizableText, { size: "$2", color: "inherit", "$max-md": { display: 'none' }, children: t('Publish') })] })] }), chat: _jsxs(_Fragment, { children: [row, chat] }), dock: _jsx(Console, { lines: lines, height: dock, onHeight: setDock, onClear: () => setPageLines([]), status: run.status || end.status || undefined, label: t('Console') }), collapsed: shut, pane: pane, width: across, onLayout: (e) => setRoom(e.nativeEvent.layout.width), children: [row, preview, body] }), _jsx(Dialog, { open: history, onOpenChange: setHistory, children: _jsxs(DialogContent, { maxW: 480, children: [_jsx(DialogTitle, { children: t('Sessions on {title}', { title }) }), _jsx(YStack, { gap: "$1", children: runs.value.length === 0 ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('No sessions yet.') })) : (runs.value.map((r) => {
579
+ return (_jsxs(_Fragment, { children: [_jsxs(Workspace, { start: _jsxs(XStack, { items: "center", gap: "$2", minW: 0, shrink: 1, children: [_jsx(XStack, { render: "button", "aria-label": t('All sessions'), ...{ title: t('All sessions') }, onPress: () => host.go(''), p: "$1", "$max-md": { minW: 40, minH: 40, items: 'center', justify: 'center' }, shrink: 0, children: _jsx(HanzoMark, { size: 20 }) }), _jsx(ProjectChip, { name: title, onPress: () => setSwitcher(true) }), _jsx(XStack, { render: "button", "aria-label": t('History'), ...{ title: t('History') }, onPress: () => setHistory(true), p: "$1.5", "$max-md": { minW: 40, minH: 40, items: 'center', justify: 'center' }, rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, children: _jsx(Clock, { size: 16 }) }), _jsx(XStack, { render: "button", "aria-label": shut ? t('Show the chat') : t('Hide the chat'), ...{ title: shut ? t('Show the chat') : t('Hide the chat') }, "aria-pressed": !shut, onClick: () => (cramped ? setAsked(!asked) : setCollapsed(!collapsed)), minW: 32, minH: 32, items: "center", justify: "center", rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$max-md": { display: 'none' }, children: _jsx(PanelLeft, { size: 16 }) })] }), middle: wide ? views : undefined, end: _jsxs(XStack, { "data-slot": "project-header-actions", items: "center", gap: "$2", shrink: 0, style: { paddingInlineEnd: 'var(--hanzo-shell-top-right-inset, 0px)' }, children: [githubInfo ? (_jsx(GitHubBadge, { fullName: githubInfo.fullName, htmlUrl: githubInfo.htmlUrl, syncedLabel: t('Synced'), compact: true })) : repo ? (_jsxs(Button, { variant: "outline", size: "sm", "data-slot": "project-sync-github", "aria-label": t('Sync to GitHub'), ...{ title: t('Sync to GitHub') }, onPress: () => setSyncDialogOpen(true), shrink: 0, children: [_jsx(Github, { size: 14 }), _jsx(SizableText, { size: "$2", color: "inherit", "$max-md": { display: 'none' }, children: t('Sync to GitHub') })] })) : null, _jsx(XStack, { display: "none", $md: { display: 'flex' }, shrink: 0, children: _jsxs(Button, { variant: "outline", size: "sm", onPress: () => void share(), children: [_jsx(Share2, { size: 14 }), " ", t('Share')] }) }), _jsxs(Button, { size: "sm", variant: "primary", "aria-label": t('Publish'), disabled: !clone || !slug, onPress: () => setPublish({ repo: clone, title, ref, name: slug, project: slug, preview: project?.live || undefined }), shrink: 0, children: [_jsx(Upload, { size: 14 }), _jsx(SizableText, { size: "$2", color: "inherit", "$max-md": { display: 'none' }, children: t('Publish') })] })] }), chat: _jsxs(_Fragment, { children: [row, chat] }), dock: _jsx(Console, { lines: lines, height: dock, onHeight: setDock, onClear: () => setPageLines([]), status: run.status || end.status || undefined, label: t('Console') }), collapsed: shut, pane: pane, width: across, onLayout: (e) => setRoom(e.nativeEvent.layout.width), children: [row, preview, body] }), _jsx(Dialog, { open: history, onOpenChange: setHistory, children: _jsxs(DialogContent, { maxW: 480, children: [_jsx(DialogTitle, { children: t('Sessions on {title}', { title }) }), _jsx(YStack, { gap: "$1", children: runs.value.length === 0 ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('No sessions yet.') })) : (runs.value.map((r) => {
570
580
  const active = r.id === current;
571
581
  return (_jsxs(XStack, { render: "button", "aria-current": active ? 'true' : undefined, onPress: () => {
572
582
  setChosen(r.id);
@@ -587,5 +597,8 @@ export function Project({ at }) {
587
597
  setSwitcher(false);
588
598
  setSwitchQ('');
589
599
  host.go(path({ kind: 'screen', screen: 'projects' }));
590
- }, children: t('All projects') })] }) }), _jsx(Publish, { source: publish, onClose: () => setPublish(null), onLive: fresh })] }));
600
+ }, children: t('All projects') })] }) }), _jsx(Publish, { source: publish, onClose: () => setPublish(null), onLive: fresh }), repo ? (_jsx(SyncToGitHubDialog, { open: syncDialogOpen, onOpenChange: setSyncDialogOpen, repoName: repo, defaultName: slug || repo, defaultDescription: forge.value?.description || '', onSynced: (info) => {
601
+ setSyncedGitHub(info);
602
+ gitTargets.reload();
603
+ } })) : null] }));
591
604
  }
@@ -15,8 +15,8 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
15
15
  */
16
16
  import { SizableText, XStack, YStack } from '@hanzo/gui';
17
17
  import { useI18n } from '@hanzo/i18n/react';
18
- import { Check, ChevronLeft, ChevronRight, Plus, X } from '@hanzogui/lucide-icons-2';
19
- import { Button, Input } from '@hanzo/ui';
18
+ import { Check, ChevronLeft, ChevronRight, GitFork, Plus, X } from '@hanzogui/lucide-icons-2';
19
+ import { Button, Input, toast } from '@hanzo/ui';
20
20
  import { useEffect, useMemo, useState } from 'react';
21
21
  import { here, useBack } from './back.js';
22
22
  import { Refusal } from './api/call.js';
@@ -24,6 +24,7 @@ import { accounts, added, bring, grants } from './api/github.js';
24
24
  import { authorize } from './api/provider.js';
25
25
  import { pinHub, readPending, writePending } from './choice.js';
26
26
  import { useRead } from './data.js';
27
+ import { CreateGitHubRepoForm, ForkGitHubRepoForm } from './github-sync.js';
27
28
  import { useHost, useTarget } from './host.js';
28
29
  import { path } from './route.js';
29
30
  const EMPTY = { repos: [], unread: [] };
@@ -115,6 +116,26 @@ export function Sync() {
115
116
  const back = () => {
116
117
  host.go(path({ kind: 'screen', screen: 'projects' }));
117
118
  };
119
+ const openCreatedOrForked = async (created, verb) => {
120
+ const [repoOwner = '', repoName = created.full_name] = created.full_name.split('/');
121
+ try {
122
+ const queued = await bring(target, [created.full_name]);
123
+ const codebaseName = queued.codebases[created.full_name.toLowerCase()] || repoName;
124
+ const next = [
125
+ ...readPending(host.org).filter((p) => p.fullName.toLowerCase() !== created.full_name.toLowerCase()),
126
+ { fullName: created.full_name, name: codebaseName },
127
+ ];
128
+ writePending(host.org, next);
129
+ }
130
+ catch {
131
+ /* direct GitHub editing via pinHub still works */
132
+ }
133
+ pinHub(host.org, { owner: repoOwner, name: repoName, private: created.private, branch: created.default_branch || 'main' });
134
+ toast.success(verb === 'created'
135
+ ? t('Created {repo} on GitHub — opening in Dev', { repo: created.full_name })
136
+ : t('Forked {repo} to GitHub — opening in Dev', { repo: created.full_name }));
137
+ host.go('');
138
+ };
118
139
  useEffect(() => {
119
140
  if (!syncing)
120
141
  return;
@@ -143,11 +164,13 @@ export function Sync() {
143
164
  : t('Nothing matches.') })) : (shownOrgs.map((a) => (_jsxs(XStack, { render: "button", "aria-label": a.blocked ? t('{name} needs an organization admin', { name: a.name }) : t('Open {name}', { name: a.name }), disabled: a.blocked, items: "center", gap: "$2", py: "$2", borderTopWidth: 1, borderColor: "$borderColor", onPress: () => {
144
165
  setOwner(a.name);
145
166
  setQ('');
146
- }, children: [_jsx(SizableText, { flex: 1, size: "$2", color: a.blocked ? '$soft' : '$ink', numberOfLines: 1, children: a.name }), a.blocked ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Needs organization admin') })) : (_jsx(ChevronRight, { size: 14, 'data-i18n-mirror': '' }))] }, a.name)))), _jsxs(XStack, { render: "button", "aria-label": t('Add organization'), items: "center", gap: "$2", py: "$2", onPress: () => void addOrg(), disabled: !signed, children: [_jsx(Plus, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Add organization') })] })] })] })) : null, step === 'pick' && owner ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Select repositories') }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Choose repositories to bring into {place}', { place: dest }) })] }), _jsxs(Panel, { children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(XStack, { render: "button", "aria-label": t('All organizations'), onPress: () => setOwner(''), children: _jsx(ChevronLeft, { size: 16, 'data-i18n-mirror': '' }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$ink", numberOfLines: 1, children: owner })] }), _jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Search repositories'), "aria-label": t('Search repositories') }), _jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: ofOwner.length === 1 ? t('1 repository') : t('{n} repositories', { n: ofOwner.length }) }), _jsx(XStack, { render: "button", "aria-label": t('Select all'), onPress: selectShown, disabled: shownRepos.length === 0, children: _jsx(SizableText, { size: "$1", color: "$ink", children: t('Select all') }) })] }), shownRepos.length === 0 ? (_jsx(Soft, { children: t('Nothing matches.') })) : (shownRepos.map((r) => (_jsx(RepoRow, { repo: r, on: picked.includes(r.fullName), onPress: () => toggle(r.fullName) }, r.fullName)))), _jsxs(XStack, { render: "button", "aria-label": t('Grant more repositories'), items: "center", gap: "$2", py: "$2", onPress: () => void addOrg(), children: [_jsx(Plus, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Add repositories') })] })] })] })) : null, step === 'access' ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Repository access') }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Review who can read these repositories') })] }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsxs(XStack, { flex: 1, items: "center", gap: "$2", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(XStack, { render: "button", "aria-label": t('Clear the selection'), onPress: () => { setPicked([]); setStep('pick'); }, children: _jsx(X, { size: 12 }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$ink", numberOfLines: 1, children: more ? t('{name}, +{n} more', { name: lead, n: more }) : lead })] }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => setStep('pick'), children: t('Edit') })] }), _jsxs(XStack, { justify: "space-between", gap: "$4", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Who gets access') }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('{name} · You', { name: host.person?.name || host.person?.email || t('You') }) })] }), _jsxs(YStack, { gap: "$1", items: "flex-end", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Role') }), _jsx(SizableText, { size: "$2", color: "$ink", children: host.admin ? t('Repository admin') : t('Member') })] })] }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Anyone with access to {place}', { place: dest }) })] })) : null, error ? _jsx(Soft, { children: error }) : null, unbound && step === 'access' ? (_jsxs(Button, { width: "100%", variant: "outline", onPress: () => void addOrg(), children: [_jsx(Plus, { size: 14 }), t('Add organization')] })) : null, step === 'pick' ? (_jsx(Button, { width: "100%", disabled: !owner || picked.length === 0, onPress: () => setStep('access'), children: t('Continue') })) : (_jsxs(YStack, { gap: "$3", items: "center", width: "100%", children: [_jsx(Button, { width: "100%", disabled: busy || syncing || picked.length === 0, onPress: () => void send(), children: syncing || busy
167
+ }, children: [_jsx(SizableText, { flex: 1, size: "$2", color: a.blocked ? '$soft' : '$ink', numberOfLines: 1, children: a.name }), a.blocked ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Needs organization admin') })) : (_jsx(ChevronRight, { size: 14, 'data-i18n-mirror': '' }))] }, a.name)))), _jsxs(XStack, { render: "button", "aria-label": t('Add organization'), items: "center", gap: "$2", py: "$2", onPress: () => void addOrg(), disabled: !signed, children: [_jsx(Plus, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Add organization') })] })] })] })) : null, step === 'pick' && owner ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Select repositories') }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Choose repositories to bring into {place}', { place: dest }) })] }), _jsxs(Panel, { children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(XStack, { render: "button", "aria-label": t('All organizations'), onPress: () => setOwner(''), children: _jsx(ChevronLeft, { size: 16, 'data-i18n-mirror': '' }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$ink", numberOfLines: 1, children: owner })] }), _jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Search repositories'), "aria-label": t('Search repositories') }), _jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: ofOwner.length === 1 ? t('1 repository') : t('{n} repositories', { n: ofOwner.length }) }), _jsx(XStack, { render: "button", "aria-label": t('Select all'), onPress: selectShown, disabled: shownRepos.length === 0, children: _jsx(SizableText, { size: "$1", color: "$ink", children: t('Select all') }) })] }), shownRepos.length === 0 ? (_jsxs(YStack, { gap: "$2.5", py: "$1", children: [_jsx(Soft, { children: ofOwner.length === 0
168
+ ? t('No repositories found under {owner} yet. Create a new repository or fork an existing one.', { owner })
169
+ : t('Nothing matches.') }), ofOwner.length === 0 ? (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", children: [_jsxs(Button, { size: "sm", variant: "primary", onPress: () => setStep('create'), children: [_jsx(Plus, { size: 14 }), t('Create a new GitHub repository')] }), _jsxs(Button, { size: "sm", variant: "outline", onPress: () => setStep('fork'), children: [_jsx(GitFork, { size: 14 }), t('Fork a GitHub repository')] })] })) : null] })) : (shownRepos.map((r) => (_jsx(RepoRow, { repo: r, on: picked.includes(r.fullName), onPress: () => toggle(r.fullName) }, r.fullName)))), _jsxs(XStack, { render: "button", "aria-label": t('Grant more repositories'), items: "center", gap: "$2", py: "$2", onPress: () => void addOrg(), children: [_jsx(Plus, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Add repositories') })] })] })] })) : null, step === 'access' ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Repository access') }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Review who can read these repositories') })] }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsxs(XStack, { flex: 1, items: "center", gap: "$2", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(XStack, { render: "button", "aria-label": t('Clear the selection'), onPress: () => { setPicked([]); setStep('pick'); }, children: _jsx(X, { size: 12 }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$ink", numberOfLines: 1, children: more ? t('{name}, +{n} more', { name: lead, n: more }) : lead })] }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => setStep('pick'), children: t('Edit') })] }), _jsxs(XStack, { justify: "space-between", gap: "$4", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Who gets access') }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('{name} · You', { name: host.person?.name || host.person?.email || t('You') }) })] }), _jsxs(YStack, { gap: "$1", items: "flex-end", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Role') }), _jsx(SizableText, { size: "$2", color: "$ink", children: host.admin ? t('Repository admin') : t('Member') })] })] }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Anyone with access to {place}', { place: dest }) })] })) : null, step === 'create' ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Create a new GitHub repository') }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Create a repository on GitHub and open it in Dev.') })] }), _jsx(CreateGitHubRepoForm, { orgs: orgs.filter((a) => !a.blocked).map((a) => a.name), submitLabel: t('Create & edit in /dev'), onCancel: () => setStep('pick'), onCreated: (r) => openCreatedOrForked(r, 'created') })] })) : null, step === 'fork' ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Fork a GitHub repository') }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: t('Fork any public owner/repo to your GitHub and edit it in Dev.') })] }), _jsx(ForkGitHubRepoForm, { orgs: orgs.filter((a) => !a.blocked).map((a) => a.name), submitLabel: t('Fork & edit in /dev'), onCancel: () => setStep('pick'), onForked: (r) => openCreatedOrForked(r, 'forked') })] })) : null, error ? _jsx(Soft, { children: error }) : null, unbound && step === 'access' ? (_jsxs(Button, { width: "100%", variant: "outline", onPress: () => void addOrg(), children: [_jsx(Plus, { size: 14 }), t('Add organization')] })) : null, step === 'pick' ? (_jsxs(YStack, { gap: "$2.5", width: "100%", children: [_jsx(Button, { width: "100%", disabled: !owner || picked.length === 0, onPress: () => setStep('access'), children: t('Continue') }), signed ? (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", justify: "center", children: [_jsxs(Button, { size: "sm", variant: "outline", onPress: () => setStep('create'), children: [_jsx(Plus, { size: 14 }), t('Create new repo')] }), _jsxs(Button, { size: "sm", variant: "outline", onPress: () => setStep('fork'), children: [_jsx(GitFork, { size: 14 }), t('Fork repo')] })] })) : null] })) : step === 'access' ? (_jsxs(YStack, { gap: "$3", items: "center", width: "100%", children: [_jsx(Button, { width: "100%", disabled: busy || syncing || picked.length === 0, onPress: () => void send(), children: syncing || busy
147
170
  ? t('Syncing…')
148
171
  : picked.length === 1
149
172
  ? t('Sync 1 repository to {place}', { place: dest })
150
- : t('Sync {n} repositories to {place}', { n: picked.length, place: dest }) }), syncing ? null : (_jsx(XStack, { render: "button", "aria-label": t('Sync later'), onPress: back, children: _jsx(SizableText, { size: "$2", color: "$soft", children: t('Sync later') }) }))] })), !signed ? (_jsx(Button, { width: "100%", onPress: () => host.signIn?.(), children: t('Sign in') })) : null] })] })] }));
173
+ : t('Sync {n} repositories to {place}', { n: picked.length, place: dest }) }), syncing ? null : (_jsx(XStack, { render: "button", "aria-label": t('Sync later'), onPress: back, children: _jsx(SizableText, { size: "$2", color: "$soft", children: t('Sync later') }) }))] })) : null, !signed ? (_jsx(Button, { width: "100%", onPress: () => host.signIn?.(), children: t('Sign in') })) : null] })] })] }));
151
174
  }
152
175
  function Step({ label, done, current }) {
153
176
  return (_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(YStack, { width: 14, height: 14, rounded: 999, borderWidth: 1, items: "center", justify: "center", children: done ? _jsx(Check, { size: 10, color: "white" }) : null }), _jsx(SizableText, { size: "$1", color: current || done ? '$ink' : '$soft', children: label })] }));
@@ -1,14 +1,14 @@
1
1
  import { c as e, n as t } from "./messages-yqmY7G5x.js";
2
- import { Tf as n, t as r } from "./utils-515nQ17G.js";
3
- import { P as i } from "./keybindings-C5tK_GAk.js";
4
- import { $ as a, E as o, Q as s, Y as c, k as l, l as u, o as d, s as f, u as p } from "./DiffCommentAnnotation-BPTN_2a6.js";
5
- import { $ as m, $t as h, A as g, At as _, B as v, Bt as y, C as b, Ct as x, D as S, Dt as C, E as w, Et as T, F as E, Ft as D, G as O, H as k, Ht as A, I as j, It as ee, J as M, Jt as N, K as P, Kt as F, L as I, Lt as L, M as te, Mt as R, Nt as ne, O as re, Ot as ie, Pt as ae, Q as oe, R as se, Rt as ce, S as le, T as ue, U as de, Ut as fe, V as pe, Vt as me, W as he, Wt as ge, X as _e, Xt as ve, Y as ye, Yt as be, Zt as xe, _ as Se, _t as Ce, at as we, b as Te, bt as Ee, c as De, cn as Oe, ct as ke, d as Ae, dt as je, en as Me, et as Ne, f as z, ft as Pe, g as B, gt as Fe, h as Ie, ht as Le, in as Re, it as ze, jt as Be, k as V, kt as Ve, lt as He, m as Ue, mt as We, nn as H, nt as Ge, o as Ke, on as qe, ot as Je, p as Ye, pt as Xe, q as Ze, qt as Qe, r as $e, rn as et, s as tt, sn as U, st as nt, t as rt, tn as it, tt as at, v as ot, vt as st, w as ct, wt as lt, x as ut, xt as dt, y as ft, yt as pt } from "./DiffWorkerPoolProvider-BwFR-Fc9.js";
2
+ import { Ef as n, t as r } from "./utils-DtKQl-D3.js";
3
+ import { P as i } from "./keybindings-D0pBlT1k.js";
4
+ import { $ as a, E as o, Q as s, Y as c, k as l, l as u, o as d, s as f, u as p } from "./DiffCommentAnnotation-2HD5qiyt.js";
5
+ import { $ as m, $t as h, A as g, At as _, B as v, Bt as y, C as b, Ct as x, D as S, Dt as C, E as w, Et as T, F as E, Ft as D, G as O, H as k, Ht as A, I as j, It as ee, J as M, Jt as N, K as P, Kt as F, L as I, Lt as L, M as te, Mt as R, Nt as ne, O as re, Ot as ie, Pt as ae, Q as oe, R as se, Rt as ce, S as le, T as ue, U as de, Ut as fe, V as pe, Vt as me, W as he, Wt as ge, X as _e, Xt as ve, Y as ye, Yt as be, Zt as xe, _ as Se, _t as Ce, at as we, b as Te, bt as Ee, c as De, cn as Oe, ct as ke, d as Ae, dt as je, en as Me, et as Ne, f as z, ft as Pe, g as B, gt as Fe, h as Ie, ht as Le, in as Re, it as ze, jt as Be, k as V, kt as Ve, lt as He, m as Ue, mt as We, nn as H, nt as Ge, o as Ke, on as qe, ot as Je, p as Ye, pt as Xe, q as Ze, qt as Qe, r as $e, rn as et, s as tt, sn as U, st as nt, t as rt, tn as it, tt as at, v as ot, vt as st, w as ct, wt as lt, x as ut, xt as dt, y as ft, yt as pt } from "./DiffWorkerPoolProvider-CEfiCIGR.js";
6
6
  import { A as W, B as mt, C as ht, E as gt, F as _t, I as vt, L as yt, O as bt, R as xt, T as St, _ as Ct, b as wt, d as Tt, f as Et, g as Dt, h as Ot, j as kt, k as At, l as jt, p as Mt, t as Nt, v as Pt, w as Ft, x as It, y as Lt, z as Rt } from "./diffRendering-tvIuzFsP.js";
7
7
  import { i as zt } from "./themeResolver-n7YLSRSv.js";
8
8
  import { a as Bt, i as Vt, o as Ht, r as G, s as Ut } from "./syntaxHighlighting-CqVs1cUM.js";
9
9
  import { _ as Wt, a as Gt, c as Kt, d as K, f as qt, m as Jt, r as Yt, u as Xt } from "./appendItems-BI9GqZ3O.js";
10
10
  import { r as Zt } from "./getFiletypeFromFileName-DLahV2Rk.js";
11
- import { t as q } from "./skeleton-CJqwfMSF.js";
11
+ import { t as q } from "./skeleton-BOKpAZv6.js";
12
12
  import { forwardRef as Qt, memo as $t, useContext as en, useEffect as tn, useImperativeHandle as nn, useLayoutEffect as rn, useMemo as an, useRef as on, useState as sn, useSyncExternalStore as cn } from "react";
13
13
  import { c as ln } from "react/compiler-runtime";
14
14
  import { Fragment as un, jsx as J, jsxs as Y } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { Ds as e, Es as t, Io as n, No as r, Oo as i, Ss as a, Ya as o, Za as s, _s as c, ao as l, bs as u, co as d, do as f, es as p, go as m, is as h, ko as g, ks as _, mo as v, so as y, t as b, uo as x, wo as S, ys as C } from "./utils-515nQ17G.js";
1
+ import { Ds as e, Es as t, Io as n, No as r, Oo as i, Ss as a, Ya as o, Za as s, _s as c, ao as l, bs as u, co as d, do as f, es as p, go as m, is as h, ko as g, ks as _, mo as v, so as y, t as b, uo as x, wo as S, ys as C } from "./utils-DtKQl-D3.js";
2
2
  import * as w from "react";
3
3
  import { c as T } from "react/compiler-runtime";
4
4
  import { jsx as E } from "react/jsx-runtime";