@hanzo/build 0.2.93 → 0.2.95

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/README.md CHANGED
@@ -145,7 +145,7 @@ One of each, shared with Chat (@hanzo/rooms imports them):
145
145
  | `-/automations/<id>` | one task's editor and runs; `new` writes one |
146
146
  | `-/customize` · `-/customize/connectors` · `/plugins` · `/agents` | Customize: skills, connectors, plugins, agents |
147
147
  | `-/mcp` | Connectors → Browse with the fleet's native MCP servers listed |
148
- | `-/projects` | the org's projects: its repositories on the forge |
148
+ | `-/projects` | the org's projects: its repositories on the forge; Remove takes one away |
149
149
  | `-/sync` | link repositories from GitHub onto the forge |
150
150
  | `-/issues` | every project's issues, merged: the forge's and the task index's |
151
151
  | `-/artifacts` | the Library: everything you made in Chat, Dev and Studio; `?item=<id>` opens one; the org's sites at its foot |
@@ -324,8 +324,8 @@ picker and open-in-tab; Share and Publish; the console dock under it.
324
324
  | `POST /v1/sandbox/{id}/screen/ticket` · `…/terminal/ticket` | the run's desktop and shell, framed with a single-use ticket |
325
325
  | `POST /v1/sandbox/read` | the run's working tree, live |
326
326
  | `GET /v1/provider/github/repos` · `POST /v1/provider/github/repos/import` | granted repositories, and bringing them onto the forge |
327
- | `GET /v1/git/repos` · `GET /v1/git/repos/{name}` | the codebase chip, and its branches |
328
- | `GET /v1/sync` | the repositories linked from GitHub, each with its forge copy and when it last synced |
327
+ | `GET /v1/git/repos` · `GET`/`DELETE /v1/git/repos/{name}` | the codebase chip, and its branches; a repository removed from Projects |
328
+ | `GET /v1/sync` · `DELETE /v1/sync/{id}` | the repositories linked from GitHub, each with its forge copy and when it last synced; a link dropped by Remove |
329
329
  | `GET /v1/task/projects` · `GET /v1/task/board` · `GET /v1/task/projects/{key}/issues` | boards, and every issue and pull request: the forge's and the task index's |
330
330
  | `GET /v1/provider/github/repos` · `…/{owner}/{repo}/branches` | kept for a host that still asks GitHub |
331
331
  | `POST /v1/provider/github/user/connect` | connect a person's GitHub |
@@ -0,0 +1,11 @@
1
+ /** A repository on GitHub, by its account and its name. */
2
+ export interface At {
3
+ owner: string;
4
+ name: string;
5
+ }
6
+ /** What a pasted address may be, said when it is something else. */
7
+ export declare const ADDRESS: string;
8
+ /** The GitHub repository a pasted address names, or null when it names none. */
9
+ export declare function onGitHub(text: string): At | null;
10
+ /** The https address a project's repository is cloned from: what the sync app writes for a GitHub repository too. */
11
+ export declare const clone: (at: At) => string;
package/lib/address.js ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * A repository's address, as a person pastes it: what GitHub's page, its Code
3
+ * button or a terminal hands them.
4
+ *
5
+ * https://github.com/owner/name the page; with .git, the clone address
6
+ * git@github.com:owner/name.git the SSH clone address
7
+ * ssh://git@github.com/owner/name.git the same, as a URL
8
+ * github.com/owner/name the address without its scheme
9
+ *
10
+ * It is read to the repository it names, and the platform is handed that in
11
+ * the form each place takes: a coding run `github.com/owner/name` (choice.ts
12
+ * `asHub`; apps/coding start.go reads it with forge.GitHub), a project its https
13
+ * clone address (`clone`; PATCH /v1/project/{slug} takes `repo.url` as one).
14
+ *
15
+ * GitHub only. A run on a repository on GitHub alone is admitted by GitHub
16
+ * itself, while another host's `owner/name` is read by the platform as the org's
17
+ * own namespace on the forge and refused — so taking it here would only move the
18
+ * refusal to after the ask was typed. Anything else is refused here, in a
19
+ * sentence that says what is taken.
20
+ */
21
+ import { phrase } from '@hanzo/i18n';
22
+ /** What a pasted address may be, said when it is something else. */
23
+ export const ADDRESS = phrase('Paste a GitHub repository’s address, like https://github.com/owner/name, github.com/owner/name or git@github.com:owner/name.git.');
24
+ /** GitHub's shape for an account or a repository name, as the platform checks it (forge/github.go `ghName`). */
25
+ const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
26
+ /**
27
+ * The address as a URL, or without its scheme: any scheme git speaks, a user in
28
+ * front of the host (`git@`, or a token a clone address was copied with, which
29
+ * goes no further than this), and a page's query or fragment (`?tab=readme`)
30
+ * after the path. The host is github.com itself, so `github.com.example` or a
31
+ * `github.com@` user in front of another host is no address of GitHub's.
32
+ */
33
+ const URL_FORM = /^(?:(?:https?|ssh|git|git\+ssh):\/\/)?(?:[^\s/@]+@)?(?:www\.)?github\.com\/([^\s?#]*)(?:[?#]\S*)?$/i;
34
+ /** The SSH clone address, as GitHub's Code button gives it: `git@github.com:owner/name.git`. */
35
+ const SCP_FORM = /^(?:[^\s/@:]+@)?github\.com:([^\s?#]*)$/i;
36
+ /** The GitHub repository a pasted address names, or null when it names none. */
37
+ export function onGitHub(text) {
38
+ const s = text.trim();
39
+ const m = URL_FORM.exec(s) ?? SCP_FORM.exec(s);
40
+ if (!m)
41
+ return null;
42
+ // A trailing slash, then `.git`, are the clone address's and not the name's.
43
+ const parts = m[1].replace(/\/+$/, '').replace(/\.git$/i, '').split('/');
44
+ if (parts.length !== 2)
45
+ return null;
46
+ const [owner, name] = parts;
47
+ return NAME.test(owner) && NAME.test(name) ? { owner, name } : null;
48
+ }
49
+ /** The https address a project's repository is cloned from: what the sync app writes for a GitHub repository too. */
50
+ export const clone = (at) => `https://github.com/${at.owner}/${at.name}.git`;
@@ -39,3 +39,8 @@ export declare function create(t: Target, name: string, description?: string): P
39
39
  export declare function codebases(t: Target, q?: string): Promise<Codebase[]>;
40
40
  /** One codebase, so the branch chip can list what HEAD can point at. */
41
41
  export declare function one(t: Target, name: string): Promise<Codebase | null>;
42
+ /**
43
+ * Delete a codebase from the forge, and its history with it. Nothing else goes:
44
+ * a link that syncs into it, or a project built from it, is dropped on its own.
45
+ */
46
+ export declare function remove(t: Target, name: string): Promise<void>;
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Codebases on the forge, the org's own git.
3
3
  *
4
- * GET /v1/git/repos {data: [repo]} most recently updated first
5
- * GET /v1/git/repos/{name} one repo, with its branch names
4
+ * GET /v1/git/repos {data: [repo]} most recently updated first
5
+ * GET /v1/git/repos/{name} one repo, with its branch names
6
+ * DELETE /v1/git/repos/{name} the repo and its history, gone
6
7
  *
7
8
  * A coding run addresses a repository by its name. The org is the tenant on
8
9
  * the request, so the name is the whole address — `owner/name` is a path the
@@ -90,3 +91,10 @@ export async function one(t, name) {
90
91
  const raw = await call(t, 'GET', `/v1/git/repos/${seg(name)}`);
91
92
  return codebase(raw, t.org ?? '');
92
93
  }
94
+ /**
95
+ * Delete a codebase from the forge, and its history with it. Nothing else goes:
96
+ * a link that syncs into it, or a project built from it, is dropped on its own.
97
+ */
98
+ export async function remove(t, name) {
99
+ await call(t, 'DELETE', `/v1/git/repos/${seg(name)}`);
100
+ }
@@ -3,7 +3,8 @@
3
3
  * holds them: one link per repository (an account link declares one for every
4
4
  * repository its account holds), each with its copy on the forge.
5
5
  *
6
- * GET /v1/sync {data: [syncView]} apps/sync sync_api.go
6
+ * GET /v1/sync {data: [syncView]} apps/sync sync_api.go
7
+ * DELETE /v1/sync/{id} drop one link
7
8
  *
8
9
  * A repository link's source is GitHub's https clone address; its target is the
9
10
  * forge, by the bare name the copy has there. `updatedAt` is bumped by every
@@ -14,9 +15,15 @@
14
15
  *
15
16
  * Every link the sync app holds is also a row of GET /v1/project (apps/sync
16
17
  * project.go), so this list is the org's linked projects and not a copy of them.
18
+ *
19
+ * Dropping a link stops the sync both ways: the sync app withdraws the push
20
+ * back to GitHub as it deletes the link. The copy on the forge and the project
21
+ * are left as they are, so a removal that wants them gone asks for each.
17
22
  */
18
23
  import { type Target } from './call.ts';
19
24
  export interface Link {
25
+ /** The link's handle, which dropping it takes. */
26
+ id: string;
20
27
  /** The GitHub account. */
21
28
  owner: string;
22
29
  /** The repository; '' for an account link. */
@@ -40,3 +47,5 @@ export declare function github(locator: string): {
40
47
  export declare function link(raw: unknown): Link | null;
41
48
  /** Every repository link the org has; account links are left out, as each declares its repositories' own. */
42
49
  export declare function links(t: Target, signal?: AbortSignal): Promise<Link[]>;
50
+ /** Drop one link: GitHub stops syncing into its copy, and its copy stops pushing back. */
51
+ export declare function unlink(t: Target, id: string): Promise<void>;
package/lib/api/links.js CHANGED
@@ -3,7 +3,8 @@
3
3
  * holds them: one link per repository (an account link declares one for every
4
4
  * repository its account holds), each with its copy on the forge.
5
5
  *
6
- * GET /v1/sync {data: [syncView]} apps/sync sync_api.go
6
+ * GET /v1/sync {data: [syncView]} apps/sync sync_api.go
7
+ * DELETE /v1/sync/{id} drop one link
7
8
  *
8
9
  * A repository link's source is GitHub's https clone address; its target is the
9
10
  * forge, by the bare name the copy has there. `updatedAt` is bumped by every
@@ -14,8 +15,12 @@
14
15
  *
15
16
  * Every link the sync app holds is also a row of GET /v1/project (apps/sync
16
17
  * project.go), so this list is the org's linked projects and not a copy of them.
18
+ *
19
+ * Dropping a link stops the sync both ways: the sync app withdraws the push
20
+ * back to GitHub as it deletes the link. The copy on the forge and the project
21
+ * are left as they are, so a removal that wants them gone asks for each.
17
22
  */
18
- import { call } from './call.js';
23
+ import { call, seg } from './call.js';
19
24
  const str = (v) => (typeof v === 'string' ? v : '');
20
25
  const obj = (v) => (v && typeof v === 'object' ? v : {});
21
26
  /** `owner` and `name` of a GitHub https address, `name` '' for an account; null for any other host. */
@@ -47,6 +52,7 @@ export function link(raw) {
47
52
  return null;
48
53
  const native = o.native ? obj(o.native) : null;
49
54
  return {
55
+ id: str(o.id),
50
56
  owner: at.owner,
51
57
  name: str(o.scope) === 'account' ? '' : at.name,
52
58
  forge: str(target.provider) === 'hanzo-git' ? str(target.locator) : '',
@@ -63,3 +69,7 @@ export async function links(t, signal) {
63
69
  .map(link)
64
70
  .filter((l) => l !== null && l.name !== '');
65
71
  }
72
+ /** Drop one link: GitHub stops syncing into its copy, and its copy stops pushing back. */
73
+ export async function unlink(t, id) {
74
+ await call(t, 'DELETE', `/v1/sync/${seg(id)}`);
75
+ }
@@ -27,10 +27,24 @@ export type Visibility = 'public' | 'private';
27
27
  export declare function safe(url: string, local?: boolean): string;
28
28
  export declare function project(raw: unknown): Project;
29
29
  export declare function projects(t: Target): Promise<Project[]>;
30
- /** Change a project's name or who can see it; what is not sent is left as it is. */
30
+ /**
31
+ * Change a project's name, who can see it, or the repository it builds from;
32
+ * what is not sent is left as it is.
33
+ *
34
+ * `repo` is the repository's address as a person gives it (../address.ts) and
35
+ * the branch whose pushes rebuild it — left out, the platform takes `main`. It
36
+ * is a GitHub repository, by any address GitHub hands out, and goes as its https
37
+ * clone address; any other is refused before anything is sent. The platform may
38
+ * still refuse to move a site that a repository in another account would serve
39
+ * from elsewhere (409), and says why.
40
+ */
31
41
  export declare function change(t: Target, slug: string, what: {
32
42
  name?: string;
33
43
  visibility?: Visibility;
44
+ repo?: {
45
+ url: string;
46
+ branch?: string;
47
+ };
34
48
  }): Promise<Project>;
35
49
  /** Delete a project. Its site stops answering and its slug is free again. */
36
50
  export declare function remove(t: Target, slug: string): Promise<void>;
@@ -2,7 +2,7 @@
2
2
  * The org's projects: what it has built, and where each one is served.
3
3
  *
4
4
  * GET /v1/project → Project[]
5
- * PATCH /v1/project/{slug} rename it, or make it public or private
5
+ * PATCH /v1/project/{slug} rename it, make it public or private, or change its repository
6
6
  * DELETE /v1/project/{slug} delete it and take its site down
7
7
  * GET /v1/project/{slug}/deployments → Deployment[], newest first
8
8
  *
@@ -13,6 +13,7 @@
13
13
  * public without being told.
14
14
  */
15
15
  import { phrase } from '@hanzo/i18n';
16
+ import { ADDRESS, clone, onGitHub } from '../address.js';
16
17
  import { call, seg } from './call.js';
17
18
  const str = (v) => (typeof v === 'string' ? v : '');
18
19
  const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
@@ -59,7 +60,17 @@ export async function projects(t) {
59
60
  .filter((p) => p.slug)
60
61
  .sort((a, b) => b.updated - a.updated);
61
62
  }
62
- /** Change a project's name or who can see it; what is not sent is left as it is. */
63
+ /**
64
+ * Change a project's name, who can see it, or the repository it builds from;
65
+ * what is not sent is left as it is.
66
+ *
67
+ * `repo` is the repository's address as a person gives it (../address.ts) and
68
+ * the branch whose pushes rebuild it — left out, the platform takes `main`. It
69
+ * is a GitHub repository, by any address GitHub hands out, and goes as its https
70
+ * clone address; any other is refused before anything is sent. The platform may
71
+ * still refuse to move a site that a repository in another account would serve
72
+ * from elsewhere (409), and says why.
73
+ */
63
74
  export async function change(t, slug, what) {
64
75
  const body = {};
65
76
  if (what.name !== undefined) {
@@ -70,6 +81,13 @@ export async function change(t, slug, what) {
70
81
  }
71
82
  if (what.visibility !== undefined)
72
83
  body.visibility = what.visibility;
84
+ if (what.repo !== undefined) {
85
+ const at = onGitHub(what.repo.url);
86
+ if (!at)
87
+ throw new Error(ADDRESS);
88
+ const branch = what.repo.branch?.trim();
89
+ body.repo = branch ? { url: clone(at), branch } : { url: clone(at) };
90
+ }
73
91
  return project(await call(t, 'PATCH', `/v1/project/${seg(slug)}`, body));
74
92
  }
75
93
  /** Delete a project. Its site stops answering and its slug is free again. */
package/lib/api/work.d.ts CHANGED
@@ -21,7 +21,8 @@
21
21
  */
22
22
  import { type Target } from './call.ts';
23
23
  import { type Repo } from './github.ts';
24
- import { type Held, type Issue, type Linked, type Site } from '../merge.ts';
24
+ import { type Held, type Issue, type Site } from '../merge.ts';
25
+ import { type Link } from './links.ts';
25
26
  export interface Board {
26
27
  id: string;
27
28
  key: string;
@@ -38,8 +39,8 @@ export declare function everything(t: Target, signal?: AbortSignal): Promise<Iss
38
39
  export interface Sources {
39
40
  /** GitHub's grants to the org's connection, every page read so far: empty for anyone it does not answer. */
40
41
  hub: Repo[];
41
- /** The repositories linked from GitHub. */
42
- linked: Linked[];
42
+ /** The repositories linked from GitHub, each with the id dropping its link takes. */
43
+ linked: Link[];
43
44
  /** The forge's repositories. */
44
45
  held: Held[];
45
46
  /** The org's projects that build from a repository. */
@@ -53,6 +54,16 @@ export interface Sources {
53
54
  /** Sources that did not answer, as a reader names them. */
54
55
  missing: string[];
55
56
  }
57
+ /**
58
+ * What `missing` calls each source. A reader that cannot stand without one — a
59
+ * removal that missed a link would leave a copy that comes back — asks by these.
60
+ */
61
+ export declare const UNREAD: {
62
+ readonly hub: 'GitHub';
63
+ readonly linked: 'the linked repositories';
64
+ readonly forge: 'the forge';
65
+ readonly sites: 'the projects';
66
+ };
56
67
  export interface SourceQuery {
57
68
  /** Searched by GitHub; the rest are searched where they are drawn. */
58
69
  q?: string;
package/lib/api/work.js CHANGED
@@ -110,6 +110,11 @@ const issuesOf = (raw) => merged(rows(raw)
110
110
  export async function everything(t, signal) {
111
111
  return issuesOf(await call(t, 'GET', '/v1/task/board', undefined, { signal }));
112
112
  }
113
+ /**
114
+ * What `missing` calls each source. A reader that cannot stand without one — a
115
+ * removal that missed a link would leave a copy that comes back — asks by these.
116
+ */
117
+ export const UNREAD = { hub: 'GitHub', linked: 'the linked repositories', forge: 'the forge', sites: 'the projects' };
113
118
  /**
114
119
  * What the org's projects are made from, each read on its own: the links (GET
115
120
  * /v1/sync), the forge's repositories, the org's projects, and GitHub's grants
@@ -127,10 +132,10 @@ export async function sources(t, p = {}, signal) {
127
132
  });
128
133
  const first = !p.after;
129
134
  const [hub, linked, forge, sites, accounts] = await Promise.all([
130
- soft('GitHub', granted(t, { q: p.q, owner: p.owner, limit: 100, after: p.after }, signal)),
131
- first ? soft('the linked repositories', links(t, signal)) : null,
132
- first ? soft('the forge', codebases(t)) : null,
133
- first ? soft('the projects', built(t)) : null,
135
+ soft(UNREAD.hub, granted(t, { q: p.q, owner: p.owner, limit: 100, after: p.after }, signal)),
136
+ first ? soft(UNREAD.linked, links(t, signal)) : null,
137
+ first ? soft(UNREAD.forge, codebases(t)) : null,
138
+ first ? soft(UNREAD.sites, built(t)) : null,
134
139
  first ? installations(t).catch(() => []) : [],
135
140
  ]);
136
141
  return {
package/lib/ask.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type At } from './address.ts';
1
2
  export declare function Confirm({ open, onOpenChange, title, says, act, run, }: {
2
3
  open: boolean;
3
4
  onOpenChange: (o: boolean) => void;
@@ -16,3 +17,23 @@ export declare function Rename({ open, onOpenChange, title, name, run, }: {
16
17
  name: string;
17
18
  run: (next: string) => Promise<void>;
18
19
  }): import("react").JSX.Element;
20
+ /**
21
+ * The repository something works on, by the address a person has for it:
22
+ * GitHub's page, its clone address, or either without the scheme (address.ts).
23
+ * Anything else is refused here, in the dialog, with the forms it takes, before
24
+ * anything is sent. With a `branch`, the branch is asked beside it.
25
+ */
26
+ export declare function Address({ open, onOpenChange, title, says, act, address, branch, run, }: {
27
+ open: boolean;
28
+ onOpenChange: (o: boolean) => void;
29
+ title: string;
30
+ /** What the address decides, stated plainly. */
31
+ says: string;
32
+ /** The button's word: Use, Save. */
33
+ act: string;
34
+ /** The address it has now, or ''. */
35
+ address: string;
36
+ /** The branch it has now. Left out, no branch is asked. */
37
+ branch?: string;
38
+ run: (at: At, branch: string) => Promise<void>;
39
+ }): import("react").JSX.Element;
package/lib/ask.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
- * Asking one thing before an act: to confirm one that cannot be undone, or the
4
- * new name for something. A refusal is said in the dialog, which stays open, so
5
- * the reason is read where the act was asked for.
3
+ * Asking one thing before an act: to confirm one that cannot be undone, the
4
+ * new name for something, or the address of the repository it works on. A
5
+ * refusal is said in the dialog, which stays open, so the reason is read where
6
+ * the act was asked for.
6
7
  */
7
- import { SizableText, XStack } from '@hanzo/gui';
8
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
8
9
  import { useI18n } from '@hanzo/i18n/react';
9
10
  import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
10
- import { useEffect, useState } from 'react';
11
+ import { useEffect, useId, useState } from 'react';
12
+ import { ADDRESS, onGitHub } from './address.js';
11
13
  /** One act in flight, and what refused it. */
12
14
  function useAct(onDone) {
13
15
  const [working, setWorking] = useState(false);
@@ -70,3 +72,44 @@ export function Rename({ open, onOpenChange, title, name, run, }) {
70
72
  save();
71
73
  } }), _jsx(Said, { note: note }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: () => close(false), children: t('Cancel') }), _jsx(Button, { size: "sm", disabled: working, onPress: save, children: t('Save') })] })] }) }));
72
74
  }
75
+ /**
76
+ * The repository something works on, by the address a person has for it:
77
+ * GitHub's page, its clone address, or either without the scheme (address.ts).
78
+ * Anything else is refused here, in the dialog, with the forms it takes, before
79
+ * anything is sent. With a `branch`, the branch is asked beside it.
80
+ */
81
+ export function Address({ open, onOpenChange, title, says, act, address, branch, run, }) {
82
+ const { t } = useI18n();
83
+ const id = useId();
84
+ const [value, setValue] = useState(address);
85
+ const [ref, setRef] = useState(branch ?? '');
86
+ const { working, note, setNote, go } = useAct(() => onOpenChange(false));
87
+ useEffect(() => {
88
+ if (!open)
89
+ return;
90
+ setValue(address);
91
+ setRef(branch ?? '');
92
+ }, [open, address, branch]);
93
+ const close = (o) => {
94
+ if (working)
95
+ return;
96
+ setNote('');
97
+ onOpenChange(o);
98
+ };
99
+ const save = () => {
100
+ const text = value.trim();
101
+ const next = ref.trim();
102
+ // Nothing changed is nothing to send.
103
+ if (text && text === address.trim() && next === (branch ?? '').trim())
104
+ return close(false);
105
+ const at = onGitHub(text);
106
+ if (!at)
107
+ return setNote(t(ADDRESS));
108
+ void go(() => run(at, next));
109
+ };
110
+ const enter = (e) => {
111
+ if (e.key === 'Enter')
112
+ save();
113
+ };
114
+ return (_jsx(Dialog, { open: open, onOpenChange: close, children: _jsxs(DialogContent, { maxW: 480, showCloseButton: false, children: [_jsx(DialogTitle, { children: title }), _jsx(SizableText, { size: "$2", color: "$soft", children: says }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-address`, children: t('Repository') }), _jsx(Input, { id: `${id}-address`, autoFocus: true, value: value, onChangeText: setValue, placeholder: t('https://github.com/owner/name'), "aria-label": t('Repository'), onKeyDown: enter })] }), branch !== undefined ? (_jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-branch`, children: t('Branch') }), _jsx(Input, { id: `${id}-branch`, value: ref, onChangeText: setRef, placeholder: "main", "aria-label": t('Branch'), onKeyDown: enter })] })) : null, _jsx(Said, { note: note }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: () => close(false), children: t('Cancel') }), _jsx(Button, { size: "sm", disabled: working, onPress: save, children: act })] })] }) }));
115
+ }
package/lib/choice.d.ts CHANGED
@@ -42,6 +42,19 @@ export declare function pinBoard(org: string | null, key: string): void;
42
42
  * cannot be worked on, and is refused here rather than handed to the platform.
43
43
  */
44
44
  export declare function pinRepo(org: string | null, p: Project, ask?: string, issue?: number, where?: 'github' | 'forge' | null): void;
45
+ /**
46
+ * Point New at a repository on GitHub, by GitHub's address: the one Sync just
47
+ * brought in (sync.tsx), so the next run works on it and not on whatever was
48
+ * chosen before. It is GitHub's address and not its forge copy's, because the
49
+ * copy is still on its way there. A draft or an issue handed over with the
50
+ * last choice was that repository's, and goes with it.
51
+ */
52
+ export declare function pinHub(org: string | null, r: {
53
+ owner: string;
54
+ name: string;
55
+ private: boolean;
56
+ branch: string;
57
+ }): void;
45
58
  /**
46
59
  * A repository on GitHub, chosen from the org's installation: the run works there.
47
60
  * Its `full_name` is GitHub's address, `github.com/owner/name` — what the list
@@ -57,6 +70,13 @@ export interface HubRepo {
57
70
  pushed_at: string;
58
71
  installation_id: number;
59
72
  github: true;
73
+ /**
74
+ * Given by its address (address.ts), not chosen from a list. It is the
75
+ * person's word for where the run works, so no list is asked whether it is
76
+ * still there: a public repository is on no list, and GitHub admits a run on
77
+ * it all the same.
78
+ */
79
+ given?: boolean;
60
80
  }
61
81
  export declare const isHub: (repo: {
62
82
  github?: boolean;
@@ -68,6 +88,43 @@ export declare const isForge: (repo: {
68
88
  forge?: boolean;
69
89
  name?: string;
70
90
  } | null) => repo is ForgeRepo;
91
+ /**
92
+ * What New can offer now, read to judge the repository it kept. Each is null
93
+ * when it was not read — refused, let go, or still being read — and null
94
+ * judges nothing.
95
+ */
96
+ export interface Offered {
97
+ /** Every name a run can address on the forge: the forge's own repositories (GET /v1/git/repos) and every linked copy (GET /v1/sync). */
98
+ forge: readonly string[] | null;
99
+ /** A page of GitHub's listing (GET /v1/provider/github/repos), with what it says stands behind it. */
100
+ github: {
101
+ repos: readonly {
102
+ owner: string;
103
+ name: string;
104
+ }[];
105
+ next: string;
106
+ unread: readonly string[];
107
+ } | null;
108
+ }
109
+ /**
110
+ * Whether the repository New kept is gone from what it can offer: a GitHub
111
+ * repository GitHub no longer lists — let go there, or GitHub disconnected,
112
+ * which lists nothing — or a codebase the forge no longer holds. Left kept, it
113
+ * is where every next run would go, whatever was linked or synced since.
114
+ *
115
+ * Only a WHOLE answer says a repository is missing. A GitHub page with another
116
+ * after it, or with an installation it could not read, is not the whole list,
117
+ * and a list that was not read is no list, so a refused or slow read never
118
+ * loses a good choice. An address the person gave is theirs, and no list is
119
+ * asked about it.
120
+ */
121
+ export declare function gone(repo: {
122
+ forge?: boolean;
123
+ github?: boolean;
124
+ name?: string;
125
+ full_name?: string;
126
+ given?: boolean;
127
+ } | null, now: Offered): boolean;
71
128
  /** A repository queued onto the forge and not reported landed yet. */
72
129
  export interface Pending {
73
130
  fullName: string;
package/lib/choice.js CHANGED
@@ -80,10 +80,52 @@ export function pinRepo(org, p, ask = '', issue = 0, where = p.forge ? 'forge' :
80
80
  }
81
81
  write(org, { ...read(org), repo, branch, ask, issue });
82
82
  }
83
+ /**
84
+ * Point New at a repository on GitHub, by GitHub's address: the one Sync just
85
+ * brought in (sync.tsx), so the next run works on it and not on whatever was
86
+ * chosen before. It is GitHub's address and not its forge copy's, because the
87
+ * copy is still on its way there. A draft or an issue handed over with the
88
+ * last choice was that repository's, and goes with it.
89
+ */
90
+ export function pinHub(org, r) {
91
+ const repo = asHub({ owner: r.owner, name: r.name, full_name: `${r.owner}/${r.name}`, private: r.private, default_branch: r.branch, pushed_at: '', installation_id: 0 });
92
+ write(org, { ...read(org), repo, branch: repo.default_branch, ask: '', issue: 0 });
93
+ }
83
94
  export const isHub = (repo) => Boolean(repo && repo.github === true && repo.full_name?.startsWith('github.com/'));
84
95
  /** A GitHub listing row as the composer offers it. */
85
96
  export const asHub = (r) => ({ ...r, full_name: `github.com/${r.owner}/${r.name}`, github: true });
86
97
  export const isForge = (repo) => Boolean(repo && repo.forge === true && repo.name);
98
+ /**
99
+ * Whether the repository New kept is gone from what it can offer: a GitHub
100
+ * repository GitHub no longer lists — let go there, or GitHub disconnected,
101
+ * which lists nothing — or a codebase the forge no longer holds. Left kept, it
102
+ * is where every next run would go, whatever was linked or synced since.
103
+ *
104
+ * Only a WHOLE answer says a repository is missing. A GitHub page with another
105
+ * after it, or with an installation it could not read, is not the whole list,
106
+ * and a list that was not read is no list, so a refused or slow read never
107
+ * loses a good choice. An address the person gave is theirs, and no list is
108
+ * asked about it.
109
+ */
110
+ export function gone(repo, now) {
111
+ if (!repo || repo.given)
112
+ return false;
113
+ if (isHub(repo)) {
114
+ const listed = now.github;
115
+ if (!listed || listed.next || listed.unread.length)
116
+ return false;
117
+ // Each row by the address `asHub` gives it, which is the one New keeps.
118
+ const want = repo.full_name.toLowerCase();
119
+ return !listed.repos.some((r) => `github.com/${r.owner}/${r.name}`.toLowerCase() === want);
120
+ }
121
+ if (isForge(repo)) {
122
+ if (!now.forge)
123
+ return false;
124
+ const want = repo.name.toLowerCase();
125
+ return !now.forge.some((n) => n.toLowerCase() === want);
126
+ }
127
+ return false;
128
+ }
87
129
  const syncingKey = (org) => `hanzo.build.sync.${org ?? 'none'}`;
88
130
  export function readPending(org) {
89
131
  try {
package/lib/forge.js CHANGED
@@ -17,13 +17,15 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
17
17
  import { SizableText, XStack, YStack } from '@hanzo/gui';
18
18
  import { phrase } from '@hanzo/i18n';
19
19
  import { useI18n } from '@hanzo/i18n/react';
20
- import { ArrowRight, Check, ChevronDown, CircleCheck, CircleDot, CircleSlash, ExternalLink, FolderGit2, GitBranch, Github, GitPullRequest, LayoutTemplate, RefreshCw, } from '@hanzogui/lucide-icons-2';
20
+ import { ArrowRight, Check, ChevronDown, CircleCheck, CircleDot, CircleSlash, ExternalLink, FolderGit2, GitBranch, Github, GitPullRequest, LayoutTemplate, RefreshCw, Trash2, } from '@hanzogui/lucide-icons-2';
21
21
  import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, Input } from '@hanzo/ui';
22
22
  import { useEffect, useMemo, useState } from 'react';
23
23
  import { ago } from './ago.js';
24
- import { codebases } from './api/codebases.js';
24
+ import { codebases, remove as removeRepo } from './api/codebases.js';
25
+ import { unlink as removeLink } from './api/links.js';
26
+ import { remove as removeProject } from './api/projects.js';
25
27
  import { Scheduled } from './scheduled.js';
26
- import { boards, everything, sources } from './api/work.js';
28
+ import { boards, everything, sources, UNREAD } from './api/work.js';
27
29
  import { boardKey, pinRepo, readPending, writePending } from './choice.js';
28
30
  import { useKept, useRead } from './data.js';
29
31
  import { useHost, useTarget } from './host.js';
@@ -35,6 +37,7 @@ import { disconnect } from './api/provider.js';
35
37
  import { here, useBack } from './back.js';
36
38
  import { Out } from './out.js';
37
39
  import { ask, assemble, attach, closes, facets, handle, home, keyOf, matches, pickProjects, place } from './merge.js';
40
+ import { removal, stopped } from './removal.js';
38
41
  function Note({ children }) {
39
42
  return (_jsx(SizableText, { size: "$2", color: "$soft", children: children }));
40
43
  }
@@ -63,6 +66,10 @@ const PAGE = 25;
63
66
  * of two ways — linked from GitHub, or started from a template. A project is a
64
67
  * repository; opening one opens its workspace at `<org>/<repo>`, and every run
65
68
  * there works on that repository. There is no project without one.
69
+ *
70
+ * Remove takes one away (../removal.ts): Hanzo's copy of a GitHub repository
71
+ * stops syncing and goes, with its project, and GitHub's is never touched; the
72
+ * forge's own goes with its history. It asks once, on the row, saying which.
66
73
  */
67
74
  function Projects() {
68
75
  const host = useHost();
@@ -137,9 +144,54 @@ function Projects() {
137
144
  const open = (c) => host.go(path({ kind: 'repo', org: c.org || host.org || '', name: c.name }));
138
145
  const link = () => host.go(path({ kind: 'screen', screen: 'sync' }));
139
146
  const template = () => host.go(path({ kind: 'screen', screen: 'templates' }));
147
+ // What each repository is tied to on Hanzo — the links into it, GitHub's names
148
+ // for the copies it made, the projects built from it — read for Remove alone.
149
+ const made = useRead(signed ? () => sources(target) : null, NONE, [target, signed, landed]);
150
+ const [asking, setAsking] = useState('');
151
+ const [removing, setRemoving] = useState(false);
152
+ const [said, setSaid] = useState('');
153
+ // A plan stands on the links, the forge and the projects all having answered:
154
+ // one that missed a link leaves a copy that syncs back, and one that missed a
155
+ // project leaves its site up. GitHub's grants only say which copies GitHub made.
156
+ const whole = !made.loading && made.value.missing.every((m) => m === UNREAD.hub);
157
+ // Any member may: the sync app, the forge and the projects app each confine a
158
+ // delete to the caller's own org and ask no more (cloud apps/sync delete,
159
+ // apps/git deleteRepo, apps/projects del). A row still syncing in is not
160
+ // offered, since its import would bring it back.
161
+ const plan = (c) => signed && whole && !syncing.has(c.name)
162
+ ? removal(c.name, { granted: made.value.hub, linked: made.value.linked, held: made.value.held, sites: made.value.sites }, t)
163
+ : null;
164
+ const drop = (s) => s.kind === 'link' ? removeLink(target, s.id) : s.kind === 'mirror' ? removeRepo(target, s.name) : removeProject(target, s.slug);
165
+ // One step at a time, in order, stopping at the first refusal: nothing is left half-removed unsaid.
166
+ const remove = async (r) => {
167
+ setRemoving(true);
168
+ setSaid('');
169
+ let at = 0;
170
+ try {
171
+ for (; at < r.steps.length; at++)
172
+ await drop(r.steps[at]);
173
+ setSaid(t('{repo} is removed from Hanzo.', { repo: r.repo }));
174
+ }
175
+ catch (e) {
176
+ setSaid(stopped(r, at, e.message, t));
177
+ }
178
+ finally {
179
+ setRemoving(false);
180
+ setAsking('');
181
+ // Read again either way: what went leaves the list, and the next plan names only what is left.
182
+ list.reload();
183
+ made.reload();
184
+ }
185
+ };
140
186
  return (_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$6", py: "$6", "$max-md": { px: '$4' }, children: _jsxs(YStack, { width: "100%", maxW: 1040, mx: "auto", gap: "$4", children: [_jsxs(XStack, { justify: "space-between", items: "flex-start", gap: "$4", flexWrap: "wrap", children: [_jsxs(YStack, { gap: "$1", flex: 1, minW: 240, children: [_jsx(SizableText, { render: "h1", size: "$6", fontWeight: "500", color: "$ink", children: t('Projects') }), _jsx(SizableText, { size: "$2", color: "$soft", children: host.org
141
187
  ? t('{org}’s repositories on the forge. Open one to work on it.', { org: host.org })
142
- : t('This organization’s repositories on the forge. Open one to work on it.') })] }), _jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [_jsxs(Button, { size: "sm", variant: "outline", onPress: template, children: [_jsx(LayoutTemplate, { size: 14 }), t('Create from template')] }), _jsxs(Button, { size: "sm", variant: "primary", onPress: link, children: [_jsx(Github, { size: 14 }), t('Link a GitHub repo')] })] })] }), signed ? _jsx(GitHubLink, { onSync: link }) : null, list.error ? (_jsx(Note, { children: list.error.message })) : !signed ? (_jsx(Note, { children: t("Sign in to see this organization's projects.") })) : list.loading && list.value.length === 0 && pending.length === 0 ? (_jsx(Note, { children: t('Reading the forge…') })) : none ? (_jsxs(YStack, { gap: "$3", py: "$2", children: [_jsx(Note, { children: t('No projects yet. A project is a repository: link one from GitHub, or start one from a template.') }), _jsxs(XStack, { gap: "$3", flexWrap: "wrap", children: [_jsx(Choice, { label: t('Link a GitHub repo'), icon: _jsx(Github, { size: 20 }), says: t('Mirror repositories you already have. They stay in step with GitHub, and their issues can come too.'), onPress: link }), _jsx(Choice, { label: t('Create from template'), icon: _jsx(LayoutTemplate, { size: 20 }), says: t('Start from a finished product — a site, an app, a store — and make it yours.'), onPress: template })] })] })) : (_jsxs(_Fragment, { children: [_jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(YStack, { flex: 1, "$max-md": { display: 'none' } }), _jsx(YStack, { width: 320, minW: 0, shrink: 1, "$max-md": { width: 'auto', flex: 1 }, children: _jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Find a project…'), "aria-label": t('Find a project') }) })] }), shown.length === 0 ? (_jsx(Note, { children: t('Nothing matches.') })) : (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", children: [_jsxs(XStack, { px: "$3", py: "$2", gap: "$3", items: "center", bg: "$panel", children: [_jsxs(XStack, { flex: 1, render: "button", "aria-label": t('Sort by name'), items: "center", gap: "$1", onPress: () => setSort('name'), children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Name') }), sort === 'name' ? _jsx(ChevronDown, { size: 12 }) : null] }), _jsx(SizableText, { size: "$1", color: "$soft", width: 120, "$max-md": { display: 'none' }, children: t('Branch') }), _jsxs(XStack, { render: "button", "aria-label": t('Sort by last updated'), items: "center", justify: "flex-end", gap: "$1", width: 120, onPress: () => setSort('updated'), children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Updated') }), sort === 'updated' ? _jsx(ChevronDown, { size: 12 }) : null] })] }), slice.map((c) => (_jsxs(XStack, { render: "button", "aria-label": t('Open {repo}', { repo: `${c.org ? `${c.org}/` : ''}${c.name}` }), onPress: () => open(c), "$platform-web": { textAlign: 'start' }, items: "center", gap: "$3", px: "$3", py: "$2.5", borderTopWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: [_jsx(FolderGit2, { size: 15, color: "$soft" }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsxs(XStack, { minW: 0, items: "baseline", self: "flex-start", 'data-i18n-ltr': '', children: [c.org ? (_jsx(SizableText, { size: "$2", color: "$soft", numberOfLines: 1, shrink: 0, children: `${c.org}/` })) : null, _jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "500", numberOfLines: 1, shrink: 1, children: c.name })] }), c.description ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: c.description })) : null] }), _jsxs(XStack, { width: 120, items: "center", gap: "$1.5", minW: 0, "$max-md": { display: 'none' }, children: [_jsx(GitBranch, { size: 12, color: "$soft" }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: c.branch })] }), _jsx(SizableText, { size: "$1", color: "$soft", width: 120, text: "end", children: syncing.has(c.name) ? t('Syncing…') : ago(c.updated) })] }, `${c.org}/${c.name}`))), _jsxs(XStack, { px: "$3", py: "$2", justify: "space-between", items: "center", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Showing {from}–{to} of {total}', { from, to, total: shown.length }) }), _jsxs(XStack, { gap: "$3", items: "center", children: [_jsx(XStack, { render: "button", "aria-label": t('Previous page'), disabled: safePage === 0, onPress: () => setPage(safePage - 1), children: _jsx(SizableText, { size: "$1", color: safePage === 0 ? '$soft' : '$ink', children: t('Prev') }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${safePage + 1} / ${pages}` }), _jsx(XStack, { render: "button", "aria-label": t('Next page'), disabled: safePage >= pages - 1, onPress: () => setPage(safePage + 1), children: _jsx(SizableText, { size: "$1", color: safePage >= pages - 1 ? '$soft' : '$ink', children: t('Next') }) })] })] })] }))] }))] }) }));
188
+ : t('This organization’s repositories on the forge. Open one to work on it.') })] }), _jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [_jsxs(Button, { size: "sm", variant: "outline", onPress: template, children: [_jsx(LayoutTemplate, { size: 14 }), t('Create from template')] }), _jsxs(Button, { size: "sm", variant: "primary", onPress: link, children: [_jsx(Github, { size: 14 }), t('Link a GitHub repo')] })] })] }), signed ? _jsx(GitHubLink, { onSync: link }) : null, said ? _jsx(Note, { children: said }) : null, list.error ? (_jsx(Note, { children: list.error.message })) : !signed ? (_jsx(Note, { children: t("Sign in to see this organization's projects.") })) : list.loading && list.value.length === 0 && pending.length === 0 ? (_jsx(Note, { children: t('Reading the forge…') })) : none ? (_jsxs(YStack, { gap: "$3", py: "$2", children: [_jsx(Note, { children: t('No projects yet. A project is a repository: link one from GitHub, or start one from a template.') }), _jsxs(XStack, { gap: "$3", flexWrap: "wrap", children: [_jsx(Choice, { label: t('Link a GitHub repo'), icon: _jsx(Github, { size: 20 }), says: t('Mirror repositories you already have. They stay in step with GitHub, and their issues can come too.'), onPress: link }), _jsx(Choice, { label: t('Create from template'), icon: _jsx(LayoutTemplate, { size: 20 }), says: t('Start from a finished product — a site, an app, a store — and make it yours.'), onPress: template })] })] })) : (_jsxs(_Fragment, { children: [_jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(YStack, { flex: 1, "$max-md": { display: 'none' } }), _jsx(YStack, { width: 320, minW: 0, shrink: 1, "$max-md": { width: 'auto', flex: 1 }, children: _jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Find a project…'), "aria-label": t('Find a project') }) })] }), shown.length === 0 ? (_jsx(Note, { children: t('Nothing matches.') })) : (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", children: [_jsxs(XStack, { px: "$3", py: "$2", gap: "$3", items: "center", bg: "$panel", children: [_jsxs(XStack, { flex: 1, render: "button", "aria-label": t('Sort by name'), items: "center", gap: "$1", onPress: () => setSort('name'), children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Name') }), sort === 'name' ? _jsx(ChevronDown, { size: 12 }) : null] }), _jsx(SizableText, { size: "$1", color: "$soft", width: 120, "$max-md": { display: 'none' }, children: t('Branch') }), _jsxs(XStack, { render: "button", "aria-label": t('Sort by last updated'), items: "center", justify: "flex-end", gap: "$1", width: 120, onPress: () => setSort('updated'), children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Updated') }), sort === 'updated' ? _jsx(ChevronDown, { size: 12 }) : null] }), _jsx(YStack, { width: 28, shrink: 0 })] }), slice.map((c) => {
189
+ const key = `${c.org}/${c.name}`;
190
+ const named = `${c.org ? `${c.org}/` : ''}${c.name}`;
191
+ const r = plan(c);
192
+ const asked = r !== null && asking === key;
193
+ return (_jsxs(YStack, { borderTopWidth: 1, borderColor: "$borderColor", children: [_jsxs(XStack, { items: "center", gap: "$3", paddingInlineEnd: "$3", hoverStyle: { bg: '$hover' }, children: [_jsxs(XStack, { render: "button", "aria-label": t('Open {repo}', { repo: named }), onPress: () => open(c), "$platform-web": { textAlign: 'start' }, flex: 1, minW: 0, items: "center", gap: "$3", paddingInlineStart: "$3", py: "$2.5", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: [_jsx(FolderGit2, { size: 15, color: "$soft" }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsxs(XStack, { minW: 0, items: "baseline", self: "flex-start", 'data-i18n-ltr': '', children: [c.org ? (_jsx(SizableText, { size: "$2", color: "$soft", numberOfLines: 1, shrink: 0, children: `${c.org}/` })) : null, _jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "500", numberOfLines: 1, shrink: 1, children: c.name })] }), c.description ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: c.description })) : null] }), _jsxs(XStack, { width: 120, items: "center", gap: "$1.5", minW: 0, "$max-md": { display: 'none' }, children: [_jsx(GitBranch, { size: 12, color: "$soft" }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: c.branch })] }), _jsx(SizableText, { size: "$1", color: "$soft", width: 120, text: "end", children: syncing.has(c.name) ? t('Syncing…') : ago(c.updated) })] }), _jsx(XStack, { width: 28, shrink: 0, justify: "center", children: r && !asked ? (_jsx(XStack, { render: "button", "aria-label": t('Remove {repo}', { repo: named }), disabled: removing, onPress: () => setAsking(key), width: 28, height: 28, items: "center", justify: "center", rounded: "$2", hoverStyle: { bg: '$raised' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: _jsx(Trash2, { size: 14, color: "$soft" }) })) : null })] }), asked && r ? (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", pb: "$2.5", flexWrap: "wrap", children: [_jsx(SizableText, { flex: 1, minW: 200, size: "$2", color: "$ink", children: r.says }), _jsxs(XStack, { gap: "$2", children: [_jsx(Button, { size: "sm", variant: "outline", disabled: removing, onPress: () => setAsking(''), children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "destructive", disabled: removing, onPress: () => void remove(r), children: removing ? t('Removing…') : t('Remove') })] })] })) : null] }, key));
194
+ }), _jsxs(XStack, { px: "$3", py: "$2", justify: "space-between", items: "center", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Showing {from}–{to} of {total}', { from, to, total: shown.length }) }), _jsxs(XStack, { gap: "$3", items: "center", children: [_jsx(XStack, { render: "button", "aria-label": t('Previous page'), disabled: safePage === 0, onPress: () => setPage(safePage - 1), children: _jsx(SizableText, { size: "$1", color: safePage === 0 ? '$soft' : '$ink', children: t('Prev') }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${safePage + 1} / ${pages}` }), _jsx(XStack, { render: "button", "aria-label": t('Next page'), disabled: safePage >= pages - 1, onPress: () => setPage(safePage + 1), children: _jsx(SizableText, { size: "$1", color: safePage >= pages - 1 ? '$soft' : '$ink', children: t('Next') }) })] })] })] }))] }))] }) }));
143
195
  }
144
196
  /** One of the two ways in, as a card you press. */
145
197
  function Choice({ label, icon, says, onPress }) {
@@ -214,7 +266,7 @@ function GitHubLink({ onSync }) {
214
266
  ? own
215
267
  ? t('Disconnect your GitHub from Hanzo?')
216
268
  : t('Disconnect @{login}? Hanzo’s GitHub App is removed from it too, unless another organization uses it.', { login: c.login })
217
- : note || (c.connected ? t('Choose repositories to mirror; each stays in step with GitHub.') : t('One step on GitHub, then pick the repositories to sync.')) })] }), c.connected && asking ? (_jsxs(XStack, { gap: "$2", children: [_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => setAsking(false), children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "primary", disabled: busy, onPress: () => void drop(), children: busy ? t('Disconnecting…') : t('Disconnect') })] })) : c.connected ? (_jsxs(XStack, { gap: "$2", children: [_jsxs(Button, { size: "sm", variant: "outline", onPress: onSync, children: [_jsx(RefreshCw, { size: 14 }), t('Sync repositories')] }), leave ? (_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => setAsking(true), children: t('Disconnect') })) : null] })) : (_jsxs(Button, { size: "sm", variant: "primary", disabled: busy, onPress: () => void link(), children: [_jsx(Github, { size: 14 }), busy ? t('Opening GitHub…') : t('Connect GitHub')] }))] }));
269
+ : note || (c.connected ? t('Choose repositories to mirror; each stays in step with GitHub.') : t('One step on GitHub, then pick the repositories to sync.')) })] }), c.connected && asking ? (_jsxs(XStack, { gap: "$2", children: [_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => setAsking(false), children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "primary", disabled: busy, onPress: () => void drop(), children: busy ? t('Disconnecting…') : t('Confirm disconnect') })] })) : c.connected ? (_jsxs(XStack, { gap: "$2", children: [_jsxs(Button, { size: "sm", variant: "outline", onPress: onSync, children: [_jsx(RefreshCw, { size: 14 }), t('Sync repositories')] }), leave ? (_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => setAsking(true), children: t('Disconnect') })) : null] })) : (_jsxs(Button, { size: "sm", variant: "primary", disabled: busy, onPress: () => void link(), children: [_jsx(Github, { size: 14 }), busy ? t('Opening GitHub…') : t('Connect GitHub')] }))] }));
218
270
  }
219
271
  /** The menus' words, marked (`phrase`) and drawn through `t`; GitHub and Hanzo are names, drawn as given. */
220
272
  const KINDS = { all: phrase('Issues and pull requests'), issue: phrase('Issues'), pr: phrase('Pull requests') };
package/lib/landing.js CHANGED
@@ -11,7 +11,9 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
11
11
  * repository — the org's on the forge, or one its GitHub grants — so a run
12
12
  * names one, and an ask with none chosen opens the picker rather than making a
13
13
  * project up from its words. The choices a person made here are kept in this
14
- * browser, per org, so the next New starts where the last one did.
14
+ * browser, per org, so the next New starts where the last one did — and a kept
15
+ * repository New can no longer offer is let go, so the next run is not sent
16
+ * back to it. A repository can also be given by its address (Use a git URL).
15
17
  *
16
18
  * Its words are the reader's language (@hanzo/i18n `t`, the target is
17
19
  * `target`); a codebase's, a machine's and a branch's names are drawn as given.
@@ -19,7 +21,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
19
21
  import { SizableText, XStack, YStack } from '@hanzo/gui';
20
22
  import { phrase } from '@hanzo/i18n';
21
23
  import { useI18n } from '@hanzo/i18n/react';
22
- import { CircleDot, Cloud, Code, GitBranch, LayoutTemplate, Monitor, Play } from '@hanzogui/lucide-icons-2';
24
+ import { CircleDot, Cloud, Code, GitBranch, LayoutTemplate, Link2, Monitor, Play } from '@hanzogui/lucide-icons-2';
23
25
  import { Button } from '@hanzo/ui';
24
26
  import { Composer, MEASURE } from '@hanzo/ui/chat';
25
27
  import { BranchSelect, ChipSelect, FooterLink, RepoSelect } from '@hanzo/ui/product';
@@ -28,13 +30,14 @@ import { useDictation, useTalk, useVoice } from '@hanzo/voice';
28
30
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
29
31
  import { start, unhonoured } from './api/coding.js';
30
32
  import { asRepo, chosen, codebases, one } from './api/codebases.js';
31
- import { repos as githubRepos } from './api/github.js';
33
+ import { heard, repos as githubRepos } from './api/github.js';
32
34
  import { plain, read, SETUP, unset } from './api/environment.js';
33
35
  import { homes as readHomes } from './api/work.js';
34
36
  import { SetupDialog } from './environment.js';
35
37
  import { limits as readLimits } from './api/models.js';
36
38
  import { ready, SANDBOX } from './api/places.js';
37
- import { asHub, isForge, isHub, settle } from './choice.js';
39
+ import { Address } from './ask.js';
40
+ import { asHub, gone, isForge, isHub, settle } from './choice.js';
38
41
  import { useCached, useKept, usePlaces, useRead } from './data.js';
39
42
  import { useHost, useTarget } from './host.js';
40
43
  import { level, pacing, useMind } from './mind.js';
@@ -103,6 +106,8 @@ export function Landing({ onStarted }) {
103
106
  const [note, setNote] = useState('');
104
107
  const [adding, setAdding] = useState(null);
105
108
  const [offering, setOffering] = useState(false);
109
+ // Asking for a repository's address, for one the lists do not show.
110
+ const [giving, setGiving] = useState(false);
106
111
  // The repository and branch lists are read again each time they open.
107
112
  const [picking, setPicking] = useState(false);
108
113
  const [branching, setBranching] = useState(false);
@@ -156,6 +161,51 @@ export function Landing({ onStarted }) {
156
161
  // A read kept from the codebase before is not this one's.
157
162
  const env = { ...found, value: found.value && found.value.repo === codebase && !stranger ? found.value : null };
158
163
  const place = places.value.find((p) => p.id === kept.place) ?? SANDBOX;
164
+ // The kept repository is checked against what New can offer now (choice.ts
165
+ // `gone`): on arrival, and again each time the GitHub connection changes
166
+ // anywhere on the page (api/github.ts `heard`). One that is gone is let go with
167
+ // its branch and the issue it would close, so the composer holds none and Send
168
+ // opens the picker — a repository let go on GitHub, or a GitHub disconnected,
169
+ // is not where the next run goes.
170
+ const address = isHub(kept.repo) ? kept.repo.full_name : '';
171
+ const given = kept.repo?.given === true;
172
+ // The choice as it is when an answer lands, so nothing chosen while it was read is written back over.
173
+ const latest = useRef(kept);
174
+ latest.current = kept;
175
+ const drop = useCallback(() => {
176
+ setIssue(0);
177
+ keep({ ...latest.current, repo: null, branch: '' });
178
+ }, [keep]);
179
+ const [looks, look] = useState(0);
180
+ const { reload: readHomesAgain } = homes;
181
+ useEffect(() => heard(() => {
182
+ look((n) => n + 1);
183
+ readHomesAgain();
184
+ }), [readHomesAgain]);
185
+ // A codebase is judged by the org's list above. That list is drawn at once from
186
+ // what this page read before, so only its own answer on this visit judges: read
187
+ // to the end, neither refused nor let go as slow, and from both of its sources.
188
+ const fresh = !homes.loading && homes.error === null && homes.value !== NOHOMES && homes.value.whole;
189
+ const forgeNames = useMemo(() => (fresh ? homes.value.homes.map((h) => h.name) : null), [fresh, homes.value]);
190
+ useEffect(() => {
191
+ if (codebase && gone(latest.current.repo, { forge: forgeNames, github: null }))
192
+ drop();
193
+ }, [codebase, forgeNames, drop]);
194
+ // A GitHub repository, by GitHub's listing narrowed to its own address, so one
195
+ // page is the whole answer for it however many the connection grants. A read
196
+ // refused is no list; one this page has moved on from is not heard.
197
+ useEffect(() => {
198
+ if (!signed || !address || given)
199
+ return;
200
+ const ctl = new AbortController();
201
+ void githubRepos(target, { q: address.slice('github.com/'.length), limit: 100 }, ctl.signal)
202
+ .catch(() => null)
203
+ .then((github) => {
204
+ if (!ctl.signal.aborted && gone(latest.current.repo, { forge: null, github }))
205
+ drop();
206
+ });
207
+ return () => ctl.abort();
208
+ }, [signed, target, address, given, looks, drop]);
159
209
  const known = useRef(new Map());
160
210
  const hubs = useRef(new Map());
161
211
  // The forge's codebases, then the repositories the org's GitHub installation
@@ -305,6 +355,22 @@ export function Landing({ onStarted }) {
305
355
  setIssue(0);
306
356
  set({ repo: row, branch: row.default_branch });
307
357
  };
358
+ /**
359
+ * The repository at an address the person gave, chosen as GitHub's — as a row
360
+ * of the GitHub list is, so the run clones, pushes and proposes there — and
361
+ * kept as given. One the list has shown keeps the branch and privacy it said;
362
+ * any other starts from its default branch.
363
+ */
364
+ const give = (at) => {
365
+ const listed = hubs.current.get(`github.com/${at.owner}/${at.name}`.toLowerCase());
366
+ const row = {
367
+ ...(listed ?? asHub({ owner: at.owner, name: at.name, full_name: `${at.owner}/${at.name}`, private: false, default_branch: '', pushed_at: '', installation_id: 0 })),
368
+ given: true,
369
+ };
370
+ setIssue(0);
371
+ setNote('');
372
+ set({ repo: row, branch: row.default_branch });
373
+ };
308
374
  // Cloud is the sandbox, set up by the chosen codebase's environment; the rest are the org's machines.
309
375
  const placeItems = useMemo(() => (places.value.length ? places.value : [SANDBOX]).map((p) => ({
310
376
  id: p.id || 'sandbox',
@@ -356,6 +422,7 @@ export function Landing({ onStarted }) {
356
422
  { id: 'templates', label: t('Browse templates'), icon: _jsx(LayoutTemplate, { size: 14, color: "$soft" }), run: screen('templates') },
357
423
  { id: 'projects', label: t('Open projects'), icon: _jsx(Code, { size: 14, color: "$soft" }), run: screen('projects') },
358
424
  { id: 'sync', label: t('Bring a repository from GitHub'), icon: _jsx(GitBranch, { size: 14, color: "$soft" }), run: screen('sync') },
425
+ { id: 'address', label: t('Use a git URL'), icon: _jsx(Link2, { size: 14, color: "$soft" }), run: () => setGiving(true) },
359
426
  ];
360
427
  // The machines a run can go to, as the `+` menu's Devices: the same choice as the pill's.
361
428
  const devices = {
@@ -376,7 +443,7 @@ export function Landing({ onStarted }) {
376
443
  plugins: carry.plugins,
377
444
  devices,
378
445
  memory: { on: carry.gear.gear.memory, set: (on) => carry.gear.set({ memory: on }) },
379
- }, carried: [...carry.on, ...carrying(files, setFiles)], slash: carry.skills, at: carry.plugins, pills: pills, chips: chips, commands: commands, starters: _jsx(Suggestions, { rows: hints.rows, onAct: act, onDismiss: hints.dismiss }), mind: mind, effort: pacing(mind), limits: limits, onUpgrade: () => host.go(path({ kind: 'screen', screen: 'plans' })), voice: voice, language: prefs.language ?? null, onLanguage: (id) => void savePrefs({ language: id }), talk: talk })] }) }), _jsx(Publish, { source: adding, onClose: () => setAdding(null) }), carry.dialog, codebase ? (_jsx(SetupDialog, { repo: codebase, homes: homes, open: offering, onOpenChange: setOffering, onStart: setup, onRepo: choose, onSaved: () => {
446
+ }, carried: [...carry.on, ...carrying(files, setFiles)], slash: carry.skills, at: carry.plugins, pills: pills, chips: chips, commands: commands, starters: _jsx(Suggestions, { rows: hints.rows, onAct: act, onDismiss: hints.dismiss }), mind: mind, effort: pacing(mind), limits: limits, onUpgrade: () => host.go(path({ kind: 'screen', screen: 'plans' })), voice: voice, language: prefs.language ?? null, onLanguage: (id) => void savePrefs({ language: id }), talk: talk })] }) }), _jsx(Publish, { source: adding, onClose: () => setAdding(null) }), _jsx(Address, { open: giving, onOpenChange: setGiving, title: t('Use a git URL'), says: t('Runs work on the GitHub repository at this address until you choose another. A private one needs GitHub connected.'), act: t('Use'), address: "", run: async (at) => give(at) }), carry.dialog, codebase ? (_jsx(SetupDialog, { repo: codebase, homes: homes, open: offering, onOpenChange: setOffering, onStart: setup, onRepo: choose, onSaved: () => {
380
447
  setOffering(false);
381
448
  env.reload();
382
449
  } })) : null] }));
@@ -0,0 +1,71 @@
1
+ /**
2
+ * What removing one of the org's projects does, decided before anything is.
3
+ *
4
+ * A project on Projects is a repository the forge holds, and it is one of two
5
+ * things. Hanzo's COPY of a repository on GitHub: removing it drops the link
6
+ * that syncs into it, then the copy, then the project built from it — and the
7
+ * repository on GitHub is never touched. Or the forge's OWN repository, made
8
+ * from a template or created there: removing it deletes the repository and all
9
+ * of its history, which Hanzo knows of nowhere else. A repository GitHub grants
10
+ * that Hanzo never copied has nothing here to remove.
11
+ *
12
+ * Which one it is, is read off what the org's projects are made from (api/work.ts
13
+ * `sources`), and only off what says so of THIS copy: a link that writes into
14
+ * it, GitHub's listing naming it as a repository's forge name, or a project
15
+ * built from that repository on GitHub. A forge repository merely named like a
16
+ * GitHub one is the forge's own and is said to be, since deleting it may be
17
+ * deleting the only history there is.
18
+ *
19
+ * The calls go in that order — link, copy, project — and stop at the first
20
+ * refusal, so what a removal leaves is always the tail of its steps and is said.
21
+ *
22
+ * Pure: the screen asks and the tests ask the same question. Its words take the
23
+ * screen's @hanzo/i18n `t`, English when none is handed.
24
+ */
25
+ import type { Say } from '@hanzo/i18n/react';
26
+ import type { Link } from './api/links.ts';
27
+ import { type Granted, type Held, type Site } from './merge.ts';
28
+ /** One call a removal makes. */
29
+ export type Step =
30
+ /** DELETE /v1/sync/{id}: GitHub stops syncing into the copy, and the copy stops pushing back. */
31
+ {
32
+ kind: 'link';
33
+ id: string;
34
+ }
35
+ /** DELETE /v1/git/repos/{name}: the repository goes from the forge, history and all. */
36
+ | {
37
+ kind: 'mirror';
38
+ name: string;
39
+ }
40
+ /** DELETE /v1/project/{slug}: the project built from it goes, and its site stops answering. */
41
+ | {
42
+ kind: 'project';
43
+ slug: string;
44
+ };
45
+ export interface Removal {
46
+ /** `owner/name` as people know it: GitHub's address for a copy, the org's for the forge's own. */
47
+ repo: string;
48
+ /** `github` for Hanzo's copy of a repository on GitHub; `hanzo` for one whose only copy Hanzo knows of is its own. */
49
+ from: 'github' | 'hanzo';
50
+ /** The calls, in the order they are made. */
51
+ steps: Step[];
52
+ /** What removing it does, in full, for the one question asked before it is done. */
53
+ says: string;
54
+ }
55
+ /** What the org's projects are made from (api/work.ts `sources`), as far as removing one reads it. */
56
+ export interface Made {
57
+ granted: Pick<Granted, 'owner' | 'name' | 'codebase'>[];
58
+ linked: Pick<Link, 'id' | 'owner' | 'name' | 'forge'>[];
59
+ held: Pick<Held, 'org' | 'name'>[];
60
+ sites: Pick<Site, 'slug' | 'repo'>[];
61
+ }
62
+ /**
63
+ * What removing the forge repository `name` does, or null when the forge does
64
+ * not hold it: there is nothing of its own on Hanzo to remove.
65
+ */
66
+ export declare function removal(name: string, made: Made, t?: Say): Removal | null;
67
+ /**
68
+ * What is left when step `at` of `r` was refused, said with the refusal `why`:
69
+ * nothing gone when it was the first step, else what went and what is still here.
70
+ */
71
+ export declare function stopped(r: Removal, at: number, why: string, t?: Say): string;
package/lib/removal.js ADDED
@@ -0,0 +1,73 @@
1
+ import { addressOf, forgeHost } from './merge.js';
2
+ import { english } from './say.js';
3
+ /**
4
+ * The name a GitHub repository's copy has on the forge: its account and its name,
5
+ * folded (`hanzoai_cloud`; cloud forge.Imported). GET /v1/git/repos lists the copy
6
+ * by it and GitHub's listing gives it as `codebase`. A link is declared with the
7
+ * bare name (`cloud`), which a forge repository of the org's own can also have,
8
+ * so the bare name is never taken for the copy.
9
+ */
10
+ const imported = (owner, name) => (owner && name ? `${owner}_${name}`.toLowerCase() : '');
11
+ /**
12
+ * What removing the forge repository `name` does, or null when the forge does
13
+ * not hold it: there is nothing of its own on Hanzo to remove.
14
+ */
15
+ export function removal(name, made, t = english) {
16
+ const n = name.toLowerCase();
17
+ const held = made.held.find((h) => h.name.toLowerCase() === n);
18
+ if (!held)
19
+ return null;
20
+ const links = made.linked.filter((l) => imported(l.owner, l.forge) === n);
21
+ // A project is built from the copy itself, or from the repository on GitHub it is the copy of.
22
+ const sites = made.sites.filter((s) => {
23
+ const at = addressOf(s.repo);
24
+ if (!at)
25
+ return false;
26
+ return at.github ? imported(at.owner, at.name) === n : forgeHost(s.repo) && at.name.toLowerCase() === n;
27
+ });
28
+ // The repository on GitHub this is Hanzo's copy of, where anything says so of this copy.
29
+ const hub = links.at(0) ??
30
+ made.granted.find((g) => g.codebase.toLowerCase() === n) ??
31
+ sites.map((s) => addressOf(s.repo)).find((at) => at?.github);
32
+ const repo = hub ? `${hub.owner}/${hub.name}` : held.org ? `${held.org}/${held.name}` : held.name;
33
+ const steps = [
34
+ ...links.map((l) => ({ kind: 'link', id: l.id })),
35
+ { kind: 'mirror', name: held.name },
36
+ ...sites.map((s) => ({ kind: 'project', slug: s.slug })),
37
+ ];
38
+ const built = sites.length > 0;
39
+ if (hub) {
40
+ return {
41
+ repo,
42
+ from: 'github',
43
+ steps,
44
+ says: built
45
+ ? t('Hanzo stops syncing {repo} and deletes its copy here, with its project and any site published from it. Your repository on GitHub is not touched.', { repo })
46
+ : t('Hanzo stops syncing {repo} and deletes its copy here. Your repository on GitHub is not touched.', { repo }),
47
+ };
48
+ }
49
+ return {
50
+ repo,
51
+ from: 'hanzo',
52
+ steps,
53
+ says: built
54
+ ? t('This deletes {repo} and all of its history from Hanzo, with its project and any site published from it. This cannot be undone.', { repo })
55
+ : t('This deletes {repo} and all of its history from Hanzo. This cannot be undone.', { repo }),
56
+ };
57
+ }
58
+ /**
59
+ * What is left when step `at` of `r` was refused, said with the refusal `why`:
60
+ * nothing gone when it was the first step, else what went and what is still here.
61
+ */
62
+ export function stopped(r, at, why, t = english) {
63
+ const values = { repo: r.repo, why };
64
+ const step = r.steps[at];
65
+ // The links go first: one refused leaves the copy and its project as they were.
66
+ if (at === 0 || !step || step.kind === 'link')
67
+ return t('{repo} was not removed: {why}', values);
68
+ if (step.kind === 'mirror')
69
+ return t('{repo} no longer syncs from GitHub, but its copy is still on Hanzo: {why}', values);
70
+ return r.from === 'github'
71
+ ? t('Hanzo’s copy of {repo} is deleted, but its project is still on Hanzo: {why}', values)
72
+ : t('{repo} is deleted, but its project is still on Hanzo: {why}', values);
73
+ }
package/lib/shelf.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  /**
2
2
  * What this org has deployed: a few starters to make something new from, then
3
3
  * every site under the month it was last edited, whether it is public or
4
- * private, and its rename, visibility and delete. A site belongs to the org and
5
- * names no author, so the list does not split yours from a colleague's — which
6
- * is why it is a section of its own under the Library's items, which are yours.
4
+ * private, and its rename, repository, visibility and delete. A site belongs to
5
+ * the org and names no author, so the list does not split yours from a
6
+ * colleague's — which is why it is a section of its own under the Library's
7
+ * items, which are yours.
8
+ *
9
+ * Its repository is the one its builds are cut from, by a GitHub address in any
10
+ * form GitHub hands out (address.ts), with the branch whose pushes rebuild it.
7
11
  */
8
12
  export declare function Sites(): import("react").JSX.Element;
9
13
  export declare function Templates(): import("react").JSX.Element;
package/lib/shelf.js CHANGED
@@ -13,8 +13,9 @@ import { useI18n } from '@hanzo/i18n/react';
13
13
  import { Boxes, ExternalLink, Globe, Lock, MoreHorizontal } from '@hanzogui/lucide-icons-2';
14
14
  import { Button, DropdownMenu } from '@hanzo/ui';
15
15
  import { useState } from 'react';
16
- import { change, fork, remove, templates } from './api/projects.js';
17
- import { Confirm, Rename } from './ask.js';
16
+ import { clone } from './address.js';
17
+ import { address, change, fork, remove, templates } from './api/projects.js';
18
+ import { Address, Confirm, Rename } from './ask.js';
18
19
  import { useProjects, useRead } from './data.js';
19
20
  import { useHost, useTarget } from './host.js';
20
21
  import { Out } from './out.js';
@@ -73,9 +74,13 @@ function edited(s, say) {
73
74
  /**
74
75
  * What this org has deployed: a few starters to make something new from, then
75
76
  * every site under the month it was last edited, whether it is public or
76
- * private, and its rename, visibility and delete. A site belongs to the org and
77
- * names no author, so the list does not split yours from a colleague's — which
78
- * is why it is a section of its own under the Library's items, which are yours.
77
+ * private, and its rename, repository, visibility and delete. A site belongs to
78
+ * the org and names no author, so the list does not split yours from a
79
+ * colleague's — which is why it is a section of its own under the Library's
80
+ * items, which are yours.
81
+ *
82
+ * Its repository is the one its builds are cut from, by a GitHub address in any
83
+ * form GitHub hands out (address.ts), with the branch whose pushes rebuild it.
79
84
  */
80
85
  export function Sites() {
81
86
  const { t: say } = useI18n();
@@ -85,6 +90,7 @@ export function Sites() {
85
90
  const starters = useRead(() => templates(t), [], [t.api]);
86
91
  const { busy, failed, take } = useFork();
87
92
  const [renaming, setRenaming] = useState(null);
93
+ const [relinking, setRelinking] = useState(null);
88
94
  const [deleting, setDeleting] = useState(null);
89
95
  const [note, setNote] = useState('');
90
96
  const flip = async (p) => {
@@ -104,6 +110,7 @@ export function Sites() {
104
110
  .filter(Boolean)
105
111
  .join(' · ') })] })] }), _jsx(DropdownMenu, { trigger: _jsx(XStack, { render: "button", "aria-label": say('Actions for {name}', { name: p.name }), px: "$1.5", py: "$1", rounded: "$2", hoverStyle: { bg: '$raised' }, children: _jsx(MoreHorizontal, { size: 16 }) }), items: [
106
112
  { key: 'rename', label: say('Rename'), onSelect: () => setRenaming(p) },
113
+ { key: 'repo', label: say('Change repository'), onSelect: () => setRelinking(p) },
107
114
  { key: 'visibility', label: p.visibility === 'private' ? say('Make public') : say('Make private'), onSelect: () => void flip(p) },
108
115
  { type: 'separator' },
109
116
  { key: 'delete', label: say('Delete'), destructive: true, onSelect: () => setDeleting(p) },
@@ -111,6 +118,10 @@ export function Sites() {
111
118
  await change(t, renaming.slug, { name });
112
119
  setNote(say('Renamed to {name}', { name }));
113
120
  list.reload();
121
+ } })) : null, relinking ? (_jsx(Address, { open: true, onOpenChange: (o) => !o && setRelinking(null), title: say('Change repository'), says: say('The GitHub repository {name} is built from. A push to its branch builds it again.', { name: relinking.name }), act: say('Save'), address: relinking.repo, branch: relinking.branch || 'main', run: async (at, branch) => {
122
+ const next = await change(t, relinking.slug, { repo: { url: clone(at), branch } });
123
+ setNote(say('{name} is built from {repo} now', { name: relinking.name, repo: address(next.repo) || `${at.owner}/${at.name}` }));
124
+ list.reload();
114
125
  } })) : null, deleting ? (_jsx(Confirm, { open: true, onOpenChange: (o) => !o && setDeleting(null), title: say('Delete {name}?', { name: deleting.name }), says: `${say('Its site stops answering, its releases are dropped, and its address is released.')} ${say('This cannot be undone.')}`, act: say('Delete'), run: async () => {
115
126
  await remove(t, deleting.slug);
116
127
  setNote(say('{name} is deleted', { name: deleting.name }));
package/lib/sync.js CHANGED
@@ -5,7 +5,8 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
5
5
  * The list is GET /v1/provider/github/repos. The queue is POST
6
6
  * /v1/provider/github/repos/import, which mirrors `owner/name` into this
7
7
  * organization's forge in the background. An account named unread and holding
8
- * no repositories is shown as needing an organization admin.
8
+ * no repositories is shown as needing an organization admin. One repository
9
+ * brought in becomes the one New starts the next run on (choice.ts `pinHub`).
9
10
  *
10
11
  * Its words are the reader's language (@hanzo/i18n `t`); account and
11
12
  * repository names, and Forge, the forge's own name, are drawn as given.
@@ -19,7 +20,7 @@ import { here, useBack } from './back.js';
19
20
  import { Refusal } from './api/call.js';
20
21
  import { accounts, bring, grants } from './api/github.js';
21
22
  import { authorize } from './api/provider.js';
22
- import { readPending, writePending } from './choice.js';
23
+ import { pinHub, readPending, writePending } from './choice.js';
23
24
  import { useRead } from './data.js';
24
25
  import { useHost, useTarget } from './host.js';
25
26
  import { path } from './route.js';
@@ -86,6 +87,10 @@ export function Sync() {
86
87
  ...chosen.map((r) => ({ fullName: r.fullName, name: queued.codebases[r.fullName.toLowerCase()] || r.codebase || r.name })),
87
88
  ];
88
89
  writePending(host.org, next);
90
+ // One repository brought in is the one the person means to work on next, so
91
+ // New opens on it rather than on what it held before. Several say no one.
92
+ if (picked.length === 1 && chosen.length === 1)
93
+ pinHub(host.org, chosen[0]);
89
94
  setSyncing(true);
90
95
  }
91
96
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/build",
3
- "version": "0.2.93",
3
+ "version": "0.2.95",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.",