rvlib-shipkit 2.34.0 → 2.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +7 -0
  3. package/package.json +1 -1
  4. package/src/agent-time/accounts-usage.ts +5 -0
  5. package/src/agent-time/render.ts +4 -2
  6. package/src/cli/cmd_Commands.ts +3 -2
  7. package/src/cli/cmd_Init.ts +1 -1
  8. package/src/cli/cmd_Orchestrator.ts +3 -3
  9. package/src/cli/cmd_Setup.ts +11 -2
  10. package/src/cli/cmd_Shot.ts +1 -1
  11. package/src/cli/cmd_Start.ts +4 -4
  12. package/src/cli/cmd_Time.ts +4 -2
  13. package/src/cli/family-pages.ts +11 -1
  14. package/src/cli/house-pages.ts +34 -0
  15. package/src/home/backup-status.ts +21 -8
  16. package/src/home/backup-verdict.ts +1 -1
  17. package/src/home/configuration-route.ts +281 -0
  18. package/src/home/configuration-shape.ts +167 -0
  19. package/src/home/home-routes.ts +6 -0
  20. package/src/home/serve-web.ts +1 -1
  21. package/src/http/owner-word.ts +1 -0
  22. package/src/scaffold/starter-house.ts +8 -6
  23. package/src/secrets/read.ts +1 -1
  24. package/src/serve/hub-app/backups-view.tsx +4 -2
  25. package/src/serve/hub-app/columns.ts +5 -0
  26. package/src/serve/hub-app/configuration-st.ts +102 -0
  27. package/src/serve/hub-app/configuration-view.tsx +145 -0
  28. package/src/serve/hub-app/configuration.css +27 -0
  29. package/src/serve/hub-app/configure-link.tsx +16 -0
  30. package/src/serve/hub-app/database-view.tsx +3 -3
  31. package/src/serve/hub-app/home-pages.ts +2 -0
  32. package/src/serve/hub-app/home-st.ts +15 -4
  33. package/src/serve/hub-app/home.html +1 -0
  34. package/src/serve/hub-app/hub-app.tsx +2 -0
  35. package/src/serve/hub-app/icons.tsx +2 -0
  36. package/src/serve/hub-app/identities-view.tsx +2 -1
  37. package/src/serve/hub-app/index.html +1 -0
  38. package/src/serve/hub-app/machines-view.tsx +2 -0
  39. package/src/serve/hub-app/place-path.ts +1 -1
  40. package/src/serve/hub-app/projects-svc.ts +2 -1
  41. package/src/serve/hub-app/secrets-page.tsx +2 -0
  42. package/src/serve/hub-app/space-view.tsx +2 -0
  43. package/src/serve/hub-app/vault-view.tsx +2 -0
  44. package/src/setup-house.ts +8 -2
@@ -0,0 +1,102 @@
1
+ // the configuration page's state: `GET /api/home/configuration` while the page shows, the topic picked (in the address,
2
+ // `/configuration#secrets`), and the acts of his click, each asked of the daemon and then read again.
3
+ //
4
+ // The constraint a reader breaks first: a secret's value is the argument of one call. It is never a field of this
5
+ // store, of the address or of the browser's storage: the form that typed it empties its field first
6
+ import { makeAutoObservable, runInAction } from 'mobx'
7
+ import { CONFIG_TOPICS, type ConfigPage, type ConfigTopic, type ConfigTopicId } from '../../home/configuration-shape.ts'
8
+ import { EntryPick } from './entry-pick.ts'
9
+ import type { HomeSt } from './home-st.ts'
10
+ import { PolledResource } from './polled.ts'
11
+ import { ownTrouble, reach } from './reach.ts'
12
+
13
+ /** each read asks the stores whether the named secrets are held: the settings move by hand, so rarely is enough */
14
+ export const CONFIGURATION_POLL_MS = 5 * 60_000
15
+
16
+ /** what the last act of a topic answered */
17
+ export type Said = { topic: ConfigTopicId; words: string; bad: boolean }
18
+
19
+ export class ConfigurationSt {
20
+ readonly res: PolledResource<ConfigPage>
21
+ readonly pick = new EntryPick<ConfigTopicId>('/configuration', CONFIG_TOPICS)
22
+ said: Said | null = null
23
+ acting = false
24
+
25
+ constructor(private st: HomeSt) {
26
+ this.res = new PolledResource({
27
+ read: async () => {
28
+ const r = await reach('/api/home/configuration', { signal: AbortSignal.timeout(15_000) })
29
+ const j = (await r.json()) as ConfigPage | { refused: string }
30
+ if ('refused' in j) throw new Error(j.refused)
31
+ return j
32
+ },
33
+ everyMs: CONFIGURATION_POLL_MS,
34
+ trouble: (e) => ownTrouble(e, this.st.machine),
35
+ })
36
+ makeAutoObservable<this, 'st'>(this, { st: false, res: false, pick: false })
37
+ }
38
+
39
+ get data(): ConfigPage | null {
40
+ return this.res.value ?? null
41
+ }
42
+
43
+ get error(): string {
44
+ return this.res.error
45
+ }
46
+
47
+ get topic(): ConfigTopicId {
48
+ return this.pick.entry
49
+ }
50
+
51
+ get shown(): ConfigTopic | null {
52
+ return this.data?.topics.find((t) => t.id === this.topic) ?? null
53
+ }
54
+
55
+ get address(): string {
56
+ return this.pick.address
57
+ }
58
+
59
+ fromHash(hash: string): void {
60
+ this.pick.fromHash(hash)
61
+ this.said = null
62
+ }
63
+
64
+ open(id: ConfigTopicId, how: 'push' | 'replace' = 'push'): void {
65
+ this.pick.open(id, how)
66
+ this.said = null
67
+ }
68
+
69
+ /** one act: true when it was taken. `done` is what the page then says */
70
+ async act(path: 'secret' | 'bucket' | 'machine' | 'switch' | 'try', body: Record<string, unknown>, done: string): Promise<boolean> {
71
+ const topic = this.topic
72
+ this.acting = true
73
+ this.said = null
74
+ let words = done
75
+ let bad = false
76
+ try {
77
+ const r = await reach(`/api/home/configuration/${path}`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), signal: AbortSignal.timeout(60_000) })
78
+ const j = (await r.json()) as { refused?: string }
79
+ if (j.refused != null) {
80
+ words = j.refused
81
+ bad = true
82
+ }
83
+ } catch (e) {
84
+ words = ownTrouble(e, this.st.machine) || 'the daemon did not answer: nothing is known to have changed'
85
+ bad = true
86
+ }
87
+ runInAction(() => {
88
+ this.acting = false
89
+ this.said = { topic, words, bad }
90
+ })
91
+ await this.res.refresh()
92
+ return !bad
93
+ }
94
+
95
+ start(): void {
96
+ this.res.run(true)
97
+ }
98
+
99
+ stop(): void {
100
+ this.res.run(false)
101
+ }
102
+ }
@@ -0,0 +1,145 @@
1
+ // `/configuration`: everything a person can set on this machine. A narrow bar of topics on the left (a phone: one row
2
+ // of tabs), the topic picked alone on the right: where it stands, what is set, the form or the command that sets it.
3
+ //
4
+ // The constraint a reader breaks first: a secret's field is uncontrolled. Its value is read once at the submit, passed
5
+ // to the one request, and its field is emptied before that request leaves. Colour is state only
6
+ import { observer } from 'mobx-react-lite'
7
+ import { useState, type FormEvent, type ReactNode } from 'react'
8
+ import { CONFIG_TOPICS, type ConfigState, type ConfigTopic, type ConfigTopicId } from '../../home/configuration-shape.ts'
9
+ import type { ConfigurationSt } from './configuration-st.ts'
10
+ import { EntryBar, EntryCols, type EntryMark } from './entry-bar.tsx'
11
+ import type { HomeSt } from './home-st.ts'
12
+ import { CopyButton } from './review/copy-button.tsx'
13
+ import { tip } from './tips.ts'
14
+ import { FactRow } from './vault-view.tsx'
15
+
16
+ const WORD: Record<ConfigState, string> = { set: 'set', missing: 'not set', optional: 'optional', broken: 'needs a look' }
17
+ const TONE: Record<ConfigState, string> = { set: 'ok', missing: 'warn', optional: 'dim', broken: 'danger' }
18
+
19
+ /** no spell check, no password manager of the hub's own origin */
20
+ const PLAIN = { spellCheck: false, autoCorrect: 'off', autoCapitalize: 'off', autoComplete: 'off', 'data-1p-ignore': '', 'data-lpignore': 'true' } as const
21
+
22
+ const Field = ({ label, name, placeholder, secret, optional }: { label: string; name: string; placeholder?: string; secret?: boolean; optional?: boolean }) => (
23
+ <label className="cffield">
24
+ <span>{label}</span>
25
+ <input name={name} type={secret === true ? 'password' : 'text'} placeholder={placeholder} required={optional !== true} {...PLAIN} />
26
+ </label>
27
+ )
28
+
29
+ /** a form whose fields are read once, at the submit, then emptied when the act was taken */
30
+ const ActForm = observer(({ st, label, button, send, children }: { st: ConfigurationSt; label: string; button: string; send: (f: FormData) => Promise<boolean>; children: ReactNode }) => {
31
+ const submit = async (e: FormEvent<HTMLFormElement>): Promise<void> => {
32
+ e.preventDefault()
33
+ const form = e.currentTarget
34
+ const typed = new FormData(form)
35
+ // a secret leaves its field before the request: neither a slow answer nor a refused act leaves one on the page
36
+ for (const i of form.querySelectorAll<HTMLInputElement>('input[type=password]')) i.value = ''
37
+ if (await send(typed)) form.reset()
38
+ }
39
+ return (
40
+ <form className="cfform" aria-label={label} onSubmit={(e) => void submit(e)}>
41
+ {children}
42
+ <div className="cfbtns"><button type="submit" className="primary" disabled={st.acting} {...tip(`${label}: what you typed goes to this machine once, a secret field emptied as it leaves`)}>{button}</button></div>
43
+ </form>
44
+ )
45
+ })
46
+
47
+ const word = (f: FormData, name: string): string => String(f.get(name) ?? '')
48
+
49
+ const BucketForm = observer(({ st }: { st: ConfigurationSt }) => (
50
+ <ActForm st={st} label="add a bucket" button="add the bucket" send={(f) => st.act('bucket', { id: word(f, 'id'), endpoint: word(f, 'endpoint'), bucket: word(f, 'bucket'), region: word(f, 'region'), keyId: word(f, 'keyId'), keySecret: word(f, 'keySecret') }, 'the bucket is added and its key stored: try it, then the next look of the daemon sends to it')}>
51
+ <Field label="name" name="id" placeholder="my-backups" />
52
+ <Field label="endpoint" name="endpoint" placeholder="https://s3.example.com" />
53
+ <Field label="bucket" name="bucket" placeholder="my-backups" />
54
+ <Field label="region" name="region" placeholder="auto" optional />
55
+ <Field label="access key id" name="keyId" secret />
56
+ <Field label="secret access key" name="keySecret" secret />
57
+ </ActForm>
58
+ ))
59
+
60
+ const MachineForm = observer(({ st }: { st: ConfigurationSt }) => (
61
+ <ActForm st={st} label="add a machine over ssh" button="add the machine" send={(f) => st.act('machine', { id: word(f, 'id'), host: word(f, 'host'), folder: word(f, 'folder') }, 'the machine is added: the next look of the daemon sends to it')}>
62
+ <Field label="name" name="id" placeholder="nas" />
63
+ <Field label="ssh host" name="host" placeholder="nas" />
64
+ <Field label="folder" name="folder" placeholder="~/backups" />
65
+ </ActForm>
66
+ ))
67
+
68
+ const Targets = observer(({ st }: { st: ConfigurationSt }) => {
69
+ const [kind, setKind] = useState<'bucket' | 'machine' | null>(null)
70
+ const all = st.data?.targets
71
+ if (all == null) return null
72
+ return (
73
+ <>
74
+ {all.length === 0 ? null : (
75
+ <ul className="cfrows" aria-label="targets">
76
+ {all.map((t) => (
77
+ <li key={t.id}>
78
+ <i className={`mcdot vtd-${t.on ? 'ok' : 'dim'}`} />
79
+ <span className="cfname"><b>{t.label}</b> <span className="mcdim">{t.where}{t.on ? '' : ' · off'}</span></span>
80
+ {t.own ? <button type="button" className="ghost" disabled={st.acting} {...tip('writes one small object to it and reads it back')} onClick={() => void st.act('try', { id: t.id }, `${t.label} took one object and gave the same bytes back`)}>try it</button> : null}
81
+ <button type="button" className="ghost" disabled={st.acting} {...tip(t.on ? 'nothing is sent to it until it is on again; what it holds stays' : 'the next look of the daemon sends to it')} onClick={() => void st.act('switch', { id: t.id, on: !t.on }, `${t.label} is ${t.on ? 'off' : 'on'}`)}>{t.on ? 'turn off' : 'turn on'}</button>
82
+ </li>
83
+ ))}
84
+ </ul>
85
+ )}
86
+ <div className="cfadd">
87
+ <button type="button" className="ghost" aria-expanded={kind === 'bucket'} {...tip('any S3 server: its address, its bucket and its key')} onClick={() => setKind(kind === 'bucket' ? null : 'bucket')}>+ a bucket</button>
88
+ <button type="button" className="ghost" aria-expanded={kind === 'machine'} {...tip('a folder of another machine you reach over ssh')} onClick={() => setKind(kind === 'machine' ? null : 'machine')}>+ a machine over ssh</button>
89
+ </div>
90
+ {kind === 'bucket' ? <BucketForm st={st} /> : kind === 'machine' ? <MachineForm st={st} /> : null}
91
+ </>
92
+ )
93
+ })
94
+
95
+ const SecretForm = observer(({ st }: { st: ConfigurationSt }) => (
96
+ <ActForm st={st} label="store a secret" button="store" send={(f) => st.act('secret', { name: word(f, 'name'), value: word(f, 'value'), replace: f.get('replace') != null }, `${word(f, 'name')} is stored`)}>
97
+ <Field label="name" name="name" placeholder="backup/key" />
98
+ <Field label="value" name="value" secret />
99
+ <label className="cfcheck" {...tip('with no tick, a name that is stored already is refused')}><input type="checkbox" name="replace" /> <span>replace a stored value</span></label>
100
+ </ActForm>
101
+ ))
102
+
103
+ /** the acts of the console, each with its command and a copy button */
104
+ const Acts = ({ acts }: { acts: ConfigTopic['acts'] }) => (acts.length === 0 ? null : (
105
+ <ul className="cfacts" aria-label="in the console">
106
+ {acts.map((a) => (
107
+ <li key={a.command}>
108
+ <span className="mcdim">{a.what}</span>
109
+ <span className="cfcmd"><code>{a.command}</code><CopyButton text={a.command} label="copy" says="copy this, to paste in your terminal or your config" /></span>
110
+ </li>
111
+ ))}
112
+ </ul>
113
+ ))
114
+
115
+ const Topic = observer(({ app, st, t }: { app: HomeSt; st: ConfigurationSt; t: ConfigTopic }) => (
116
+ <section className="vtsecrets cftopic" aria-label={t.id}>
117
+ <div className="vthead"><b>{t.id}</b><span className={`cfstate vt-${TONE[t.state]}`}><i className={`mcdot vtd-${TONE[t.state]}`} /> {WORD[t.state]}</span><span className="mcdim">{t.line}</span></div>
118
+ {/* the targets are rows with acts of their own below */}
119
+ {t.facts.length === 0 || t.id === 'backups' ? null : <ul className="vtfacts">{t.facts.map((f) => <FactRow key={f.text} app={app} f={f} />)}</ul>}
120
+ {t.id === 'backups' ? <Targets st={st} /> : t.id === 'secrets' ? <SecretForm st={st} /> : null}
121
+ {st.said?.topic === t.id ? <div className={`cfsaid${st.said.bad ? ' bad' : ''}`} role="status">{st.said.words}</div> : null}
122
+ <Acts acts={t.acts} />
123
+ </section>
124
+ ))
125
+
126
+ const mark = (t: ConfigTopic | undefined): EntryMark => (t?.state === 'broken' ? { tone: 'red', title: t.line } : t?.state === 'missing' ? { tone: 'warn', title: t.line } : { tone: '', title: '' })
127
+
128
+ export const ConfigurationView = observer(({ app }: { app: HomeSt }) => {
129
+ const st = app.configuration
130
+ const d = st.data
131
+ const narrow = app.layout.narrow
132
+ return (
133
+ <div className="vaultpage cfpage">
134
+ <div className="actop vttop">
135
+ <span className="acdim">{d == null ? (st.error !== '' ? '' : 'reading what is set here…') : `${d.machine} · what is set on this machine, and what sets the rest · nothing changes without a click`}</span>
136
+ </div>
137
+ {st.error !== '' ? <div className="hnote mcerr">{st.error}</div> : null}
138
+ {d == null ? null : (
139
+ <EntryCols narrow={narrow} fold={{ layout: app.layout, id: 'configuration' }} bar={<EntryBar label="the topics of the configuration" entries={CONFIG_TOPICS} current={st.topic} open={(e) => st.open(e as ConfigTopicId)} mark={(e) => mark(d.topics.find((t) => t.id === e))} tabs={narrow} />}>
140
+ {st.shown == null ? null : <Topic app={app} st={st} t={st.shown} />}
141
+ </EntryCols>
142
+ )}
143
+ </div>
144
+ )
145
+ })
@@ -0,0 +1,27 @@
1
+ /* the configuration page (configuration-view.tsx): the vault page's frame (vault.css .vaultpage, its heads and facts)
2
+ and the bar of entries (entry-bar.css); here a topic's state, its rows with acts, its forms and its commands */
3
+ .cftopic{display:flex;flex-direction:column;gap:var(--s3);max-width:760px}
4
+ .cfstate{display:inline-flex;align-items:center;gap:var(--s1);white-space:nowrap}
5
+ .cfstate .vtd-ok,.cfrows .vtd-ok{background:var(--ok)}
6
+ .cfstate .vtd-warn{background:var(--warn)}
7
+ .cfstate .vtd-danger{background:var(--red)}
8
+ .cfstate .vtd-dim,.cfrows .vtd-dim{background:var(--line)}
9
+ .cfrows,.cfacts{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:var(--s2)}
10
+ .cfrows li{display:flex;align-items:center;gap:var(--s2);flex-wrap:wrap}
11
+ .cfname{flex:1 1 220px;min-width:0;overflow-wrap:anywhere}
12
+ .cfadd{display:flex;gap:var(--s2);flex-wrap:wrap}
13
+ .cfform{--cflabel:140px;display:flex;flex-direction:column;gap:var(--s2);max-width:520px}
14
+ .cffield{display:grid;grid-template-columns:var(--cflabel) minmax(0,1fr);align-items:center;gap:var(--s2)}
15
+ .cffield input{width:100%;box-sizing:border-box}
16
+ .cfcheck{display:flex;align-items:center;gap:var(--s2);margin-left:calc(var(--cflabel) + var(--s2))}
17
+ .cfbtns{display:flex;justify-content:flex-end}
18
+ .cfsaid{overflow-wrap:anywhere}
19
+ .cfsaid.bad{color:var(--red)}
20
+ .cfacts li{display:flex;flex-direction:column;gap:2px}
21
+ .cfcmd{display:flex;align-items:center;gap:var(--s2);min-width:0}
22
+ .cfcmd code{overflow-wrap:anywhere}
23
+ .cfgo{margin-left:auto;white-space:nowrap}
24
+ /* eleven topics are more than a phone's row holds: they wrap, each name whole */
25
+ .cfpage .enttabs .entrows{flex-wrap:wrap}
26
+ .cfpage .enttabs .lrow{flex:none;width:auto;padding:0 var(--s3)}
27
+ @media (max-width:600px){.cffield{grid-template-columns:minmax(0,1fr);gap:2px}.cfcheck{margin-left:0}}
@@ -0,0 +1,16 @@
1
+ // the way to a topic of the configuration page from the page it configures, at that page's top. A leaf: the pages that
2
+ // draw it are also drawn from by the configuration page
3
+ import { observer } from 'mobx-react-lite'
4
+ import type { MouseEvent } from 'react'
5
+ import type { ConfigTopicId } from '../../home/configuration-shape.ts'
6
+ import { plainClick, type HomeSt } from './home-st.ts'
7
+ import { tip } from './tips.ts'
8
+
9
+ /** nothing on a hub that serves one repo alone: the configuration is the machine's, on its home */
10
+ export const Configure = observer(({ app, topic }: { app: HomeSt; topic: ConfigTopicId }) => (app.machine == null ? null : (
11
+ <a className="cfgo vtlink" href={`/configuration#${topic}`} {...tip(`opens ${topic} on the configuration page`)} onClick={(e: MouseEvent) => {
12
+ if (!plainClick(e)) return
13
+ e.preventDefault()
14
+ app.navigate(`/configuration#${topic}`)
15
+ }}>Configure</a>
16
+ )))
@@ -252,9 +252,9 @@ const SummaryPart = observer(({ st, e, d }: { st: DatabaseSt; e: DbEntry; d: Dat
252
252
  })
253
253
 
254
254
  /** the subject of an entry, alone */
255
- const Subject = observer(({ st, d, e }: { st: DatabaseSt; d: DatabasesPage; e: DbEntry }) => {
255
+ const Subject = observer(({ app, st, d, e }: { app: HomeSt; st: DatabaseSt; d: DatabasesPage; e: DbEntry }) => {
256
256
  const s = e.subject
257
- if (s.t === 'backups') return <BackupsSubject st={st.backups} />
257
+ if (s.t === 'backups') return <BackupsSubject app={app} st={st.backups} />
258
258
  if (s.t === 'summary') return <SummaryPart st={st} e={e} d={d} />
259
259
  if (s.t === 'projects') return <Projects st={st} e={e} d={d} />
260
260
  if (s.t === 'records') return <Records st={st} e={e} dbs={s.dbs} />
@@ -311,7 +311,7 @@ export const DatabaseView = observer(({ app }: { app: HomeSt }) => {
311
311
  const there = d?.dbs.filter((x) => x.live != null).length ?? 0
312
312
  const counted = d == null ? null : oldestCount(d)
313
313
  const cur = st.list.current
314
- const subject = d == null || cur == null ? null : <div className="so-colin dbsubject"><Subject st={st} d={d} e={cur} /></div>
314
+ const subject = d == null || cur == null ? null : <div className="so-colin dbsubject"><Subject app={app} st={st} d={d} e={cur} /></div>
315
315
  return (
316
316
  <div className="database">
317
317
  <div className="actop dbbar">
@@ -6,6 +6,7 @@ import { PLACE_PATH } from './place-path.ts'
6
6
  import { PLACES, type Place } from './projects-svc.ts'
7
7
  import type { Jump, JumpFace } from './repo-st.ts'
8
8
  import { SPACE_ENTRIES } from './space-st.ts'
9
+ import { CONFIG_TOPICS } from '../../home/configuration-shape.ts'
9
10
  import { ENTRIES as TIME_PAGES } from './time-pages.tsx'
10
11
  import { VAULT_ENTRIES } from './vault-st.ts'
11
12
 
@@ -35,6 +36,7 @@ export function homeParts(navigate: (path: string) => void, dbs: readonly DbEntr
35
36
  ...dbs.filter((e) => e.subject.t === 'db').map((e) => part('database', e.name, `a database ${e.note}`, db(e.id), navigate)),
36
37
  ...VAULT_ENTRIES.map((e) => part('vault', e, e === 'backups' ? 'its copies' : '', `${PLACE_PATH.vault}#${e}`, navigate)),
37
38
  ...SPACE_ENTRIES.map((e) => part('space', e, '', `${PLACE_PATH.space}#${e}`, navigate)),
39
+ ...CONFIG_TOPICS.map((e) => part('configuration', e, 'set up configure', `${PLACE_PATH.configuration}#${e}`, navigate)),
38
40
  ...TIME_PAGES.map((e) => part('time', e.label.toLowerCase(), e.group, `${PLACE_PATH.time}#/${e.id}`, navigate)),
39
41
  ]
40
42
  }
@@ -35,6 +35,7 @@ import { SpaceSt } from './space-st.ts'
35
35
  import { HouseWaitingSvc } from './waiting-svc.ts'
36
36
  import { VaultSt } from './vault-st.ts'
37
37
  import { AdvisorsSt } from './advisors-st.ts'
38
+ import { ConfigurationSt } from './configuration-st.ts'
38
39
  import { IdentitiesSt } from './identities-st.ts'
39
40
  import { identityAddress, parseIdentityHash, type IdentitySel } from './identity-address.ts'
40
41
  import { InboxSt } from './inbox-st.ts'
@@ -61,7 +62,7 @@ export const COUNTS_MS = 250
61
62
  export const PREFETCH_WAIT_MS = 10_000
62
63
 
63
64
  /** what the page shows: the house wiki, the machine overview, the inbox, the plan, the activity, the insights, the archived repos, or one repo */
64
- export type Page = 'wiki' | 'overview' | 'inbox' | 'machines' | 'database' | 'vault' | 'space' | 'advisors' | 'planned' | 'activity' | 'insights' | 'time' | 'recordings' | 'identities' | 'archived' | 'repo'
65
+ export type Page = 'wiki' | 'overview' | 'inbox' | 'machines' | 'database' | 'vault' | 'space' | 'advisors' | 'planned' | 'activity' | 'insights' | 'time' | 'recordings' | 'configuration' | 'identities' | 'archived' | 'repo'
65
66
 
66
67
  export { PLACE_PATH }
67
68
 
@@ -92,6 +93,7 @@ export function routeOf(pathname: string): { page: Page; repo: string | null; pa
92
93
  if (/^\/vault\/?$/.test(pathname)) return { page: 'vault', repo: null }
93
94
  if (/^\/space\/?$/.test(pathname)) return { page: 'space', repo: null }
94
95
  if (/^\/advisors\/?$/.test(pathname)) return { page: 'advisors', repo: null }
96
+ if (/^\/configuration\/?$/.test(pathname)) return { page: 'configuration', repo: null }
95
97
  if (/^\/recordings\/?$/.test(pathname)) return { page: 'recordings', repo: null }
96
98
  if (/^\/identities\/?$/.test(pathname)) return { page: 'identities', repo: null }
97
99
  if (/^\/archived\/?$/.test(pathname)) return { page: 'archived', repo: null }
@@ -133,6 +135,8 @@ export class HomeSt {
133
135
  vault: VaultSt
134
136
  /** the people outside the tailnet he defers threads to, their shares and advice (advisors-st.ts) */
135
137
  advisors: AdvisorsSt
138
+ /** what is set on this machine, and the acts that set the rest (configuration-st.ts) */
139
+ configuration: ConfigurationSt
136
140
  /** the Space of the house: what its kept listing holds, folder by folder, read while it is the page (space-st.ts) */
137
141
  space: SpaceSt
138
142
  /** the screen recorder's takes and the editor of one (recordings-st.ts) */
@@ -213,6 +217,7 @@ export class HomeSt {
213
217
  this.vault = new VaultSt(this)
214
218
  this.advisors = new AdvisorsSt(this)
215
219
  this.space = new SpaceSt(this)
220
+ this.configuration = new ConfigurationSt(this)
216
221
  this.recordings = new RecordingsSt(this)
217
222
  this.identities = new IdentitiesSt(this)
218
223
  this.inbox = new InboxSt(this)
@@ -224,7 +229,7 @@ export class HomeSt {
224
229
  this.running = new RunningSt(this)
225
230
  this.machine = o.home ? new MachineSt(this, o) : null
226
231
  this.page = o.home ? 'overview' : 'repo'
227
- makeAutoObservable<this, 'disposers' | 'onUrl' | 'prefetching' | 'base' | 'counts'>(this, { base: false, shell: false, push: false, live: false, counts: false, machine: false, projects: false, planned: false, activity: false, insights: false, time: false, machines: false, database: false, backups: false, vault: false, advisors: false, space: false, recordings: false, identities: false, inbox: false, palette: false, refs: false, layout: false, terminal: false, running: false, theme: false, frames: false, urls: false, dock: false, panes: false, quiet: false, presence: false, repos: observableShallow, disposers: false, onUrl: false, prefetching: false })
232
+ makeAutoObservable<this, 'disposers' | 'onUrl' | 'prefetching' | 'base' | 'counts'>(this, { base: false, shell: false, push: false, live: false, counts: false, machine: false, projects: false, planned: false, activity: false, insights: false, time: false, machines: false, database: false, backups: false, vault: false, advisors: false, space: false, configuration: false, recordings: false, identities: false, inbox: false, palette: false, refs: false, layout: false, terminal: false, running: false, theme: false, frames: false, urls: false, dock: false, panes: false, quiet: false, presence: false, repos: observableShallow, disposers: false, onUrl: false, prefetching: false })
228
233
  const m = this.machine
229
234
  this.projects.shell = this.shell?.repo ?? null
230
235
  if (m != null) {
@@ -314,6 +319,7 @@ export class HomeSt {
314
319
  if (this.page === 'vault') return 'vault'
315
320
  if (this.page === 'space') return 'space'
316
321
  if (this.page === 'advisors') return 'advisors'
322
+ if (this.page === 'configuration') return 'configuration'
317
323
  if (this.page === 'time') return this.time.scope === 'all' ? 'time' : `time · ${this.time.scope}`
318
324
  if (this.page === 'recordings') return this.recordings.current?.name ?? 'recordings'
319
325
  if (this.page === 'identities') return this.identities.shown?.name ?? 'identities'
@@ -565,6 +571,7 @@ export class HomeSt {
565
571
  if (r.page === 'database') this.database.fromHash(u.hash)
566
572
  if (r.page === 'vault') this.vault.fromHash(u.hash)
567
573
  if (r.page === 'space') this.space.fromHash(u.hash)
574
+ if (r.page === 'configuration') this.configuration.fromHash(u.hash)
568
575
  if (r.page === 'overview') this.overviewPart = r.part ?? null
569
576
  this.show(r.page, r.repo, 'push')
570
577
  }
@@ -610,6 +617,7 @@ export class HomeSt {
610
617
  if (r.page === 'database') this.database.fromHash(location.hash)
611
618
  if (r.page === 'vault') this.vault.fromHash(location.hash)
612
619
  if (r.page === 'space') this.space.fromHash(location.hash)
620
+ if (r.page === 'configuration') this.configuration.fromHash(location.hash)
613
621
  if (r.page === 'wiki' && location.hash.length > 1) this.wikiAsked = decodeURIComponent(location.hash.slice(1))
614
622
  if (r.page === 'repo') this.repo(r.repo!).filter = parseFilter(location.search)
615
623
  this.show(r.page, r.repo, 'none')
@@ -629,10 +637,11 @@ export class HomeSt {
629
637
  const prevPage = this.page
630
638
  const next = page === 'repo' && repo != null ? this.repo(repo) : null
631
639
  // the page already shown is never a second history entry
632
- if (how === 'push' && page === this.page && next === prev && page !== 'overview' && page !== 'planned' && page !== 'inbox' && page !== 'identities' && page !== 'recordings' && page !== 'vault' && page !== 'space') how = 'none'
640
+ if (how === 'push' && page === this.page && next === prev && page !== 'overview' && page !== 'planned' && page !== 'inbox' && page !== 'identities' && page !== 'recordings' && page !== 'vault' && page !== 'space' && page !== 'configuration') how = 'none'
633
641
  // the vault on the entry it already shows is never a second entry; from another entry, its names are one
634
642
  if (how === 'push' && page === 'vault' && prevPage === 'vault' && `${location.pathname}${location.hash}` === this.vault.address) how = 'none'
635
643
  if (how === 'push' && page === 'space' && prevPage === 'space' && `${location.pathname}${location.hash}` === this.space.address) how = 'none'
644
+ if (how === 'push' && page === 'configuration' && prevPage === 'configuration' && `${location.pathname}${location.hash}` === this.configuration.address) how = 'none'
636
645
  // the overview and its « running » table are two addresses of one page
637
646
  if (how === 'push' && page === 'overview' && prevPage === 'overview' && location.pathname === this.overviewAddress) how = 'none'
638
647
  if (prev != null && prev !== next) prev.pause()
@@ -647,7 +656,7 @@ export class HomeSt {
647
656
  this.projects.away = next == null
648
657
  this.projects.place = page === 'repo' || page === 'archived' || page === 'identities' ? null : page === 'overview' && this.overviewPart != null ? this.overviewPart : page
649
658
  if (how !== 'none') {
650
- const to = next != null ? `${repoPage(next.key)}${next.search}${next.hash}` : page === 'planned' ? this.planned.address : page === 'inbox' ? this.inbox.address : page === 'identities' ? identityAddress(this.identities.sel) : page === 'recordings' ? this.recordings.address : page === 'time' ? this.time.address : page === 'database' ? this.database.address : page === 'vault' ? this.vault.address : page === 'space' ? this.space.address : page === 'wiki' ? this.wikiAddress : page === 'activity' || page === 'insights' || page === 'machines' || page === 'archived' || page === 'advisors' ? PLACE_PATH[page] : this.overviewAddress
659
+ const to = next != null ? `${repoPage(next.key)}${next.search}${next.hash}` : page === 'planned' ? this.planned.address : page === 'inbox' ? this.inbox.address : page === 'identities' ? identityAddress(this.identities.sel) : page === 'recordings' ? this.recordings.address : page === 'time' ? this.time.address : page === 'database' ? this.database.address : page === 'vault' ? this.vault.address : page === 'space' ? this.space.address : page === 'configuration' ? this.configuration.address : page === 'wiki' ? this.wikiAddress : page === 'activity' || page === 'insights' || page === 'machines' || page === 'archived' || page === 'advisors' ? PLACE_PATH[page] : this.overviewAddress
651
660
  // the identity view picked again is never a second entry
652
661
  if (how === 'push' && page === 'identities' && prevPage === 'identities' && `${location.pathname}${location.hash}` === to) how = 'none'
653
662
  // a walk with ⇧↑ ⇧↓ is one entry, so back returns to where it started
@@ -667,6 +676,8 @@ export class HomeSt {
667
676
  else this.vault.stop()
668
677
  if (page === 'space') this.space.start()
669
678
  else this.space.stop()
679
+ if (page === 'configuration') this.configuration.start()
680
+ else this.configuration.stop()
670
681
  if (page === 'advisors') this.advisors.start()
671
682
  else this.advisors.stop()
672
683
  if (page === 'insights' && prevPage !== 'insights') this.insights.start()
@@ -24,6 +24,7 @@
24
24
  <link rel="stylesheet" href="./vault.css" />
25
25
  <link rel="stylesheet" href="./advisors.css" />
26
26
  <link rel="stylesheet" href="./space.css" />
27
+ <link rel="stylesheet" href="./configuration.css" />
27
28
  <link rel="stylesheet" href="./recordings.css" />
28
29
  <link rel="stylesheet" href="./identities.css" />
29
30
  <link rel="stylesheet" href="./site.css" />
@@ -81,6 +81,7 @@ import { DatabaseView } from './database-view.tsx'
81
81
  import { SpaceView } from './space-view.tsx'
82
82
  import { VaultView } from './vault-view.tsx'
83
83
  import { AdvisorsView, PreviewDialog } from './advisors-view.tsx'
84
+ import { ConfigurationView } from './configuration-view.tsx'
84
85
  import { IdentitiesView } from './identities-view.tsx'
85
86
  import { Palette } from './palette-view.tsx'
86
87
  import { SCREEN_WAIT_MS } from './screen-cache.ts'
@@ -351,6 +352,7 @@ const App = observer(() => {
351
352
  {home.page === 'database' ? <DatabaseView app={home} /> : null}
352
353
  {home.page === 'vault' ? <VaultView app={home} /> : null}
353
354
  {home.page === 'advisors' ? <AdvisorsView app={home} /> : null}
355
+ {home.page === 'configuration' ? <ConfigurationView app={home} /> : null}
354
356
  {home.page === 'space' ? <SpaceView app={home} /> : null}
355
357
  {home.page === 'planned' ? <PlannedView app={home} /> : null}
356
358
  {home.page === 'activity' ? <ActivityView app={home} /> : null}
@@ -23,6 +23,8 @@ export const ICON = {
23
23
  // a padlock: the vault of the machine
24
24
  vault: 'M5 9h10v8H5zM7 9V6.5a3 3 0 0 1 6 0V9M10 12.25v2',
25
25
  // a cloud: the Space, the house's bucket
26
+ // three sliders, each at its own place: the configuration
27
+ configuration: 'M3.5 5.5h7M14 5.5h2.5M3.5 10h2.5M9.5 10h7M3.5 14.5h8M15 14.5h1.5M12.25 3.75v3.5M7.75 8.25v3.5M13.25 12.75v3.5',
26
28
  // two people, the second behind: the advisors
27
29
  advisors: 'M7.5 9.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM3 16c0-2.5 2-4.5 4.5-4.5S12 13.5 12 16M13 9.25a2.25 2.25 0 1 0 0-4.5M14.25 11.6c1.6.45 2.75 2 2.75 3.9',
28
30
  space: 'M6 15.5h8.25a3.25 3.25 0 0 0 .35-6.48A4.75 4.75 0 0 0 5.4 9.3 3.1 3.1 0 0 0 6 15.5z',
@@ -10,6 +10,7 @@ import { Panel, Separator } from 'react-resizable-panels'
10
10
  import { KeptCols, LIST_COL, PANEL } from './kept-cols.tsx'
11
11
  import type { DataPlace, MachineIdentity } from '../../identities/machine-route.ts'
12
12
  import type { HomeSt } from './home-st.ts'
13
+ import { Configure } from './configure-link.tsx'
13
14
  import { plainClick, repoPage } from './home-st.ts'
14
15
  import type { IdentitiesSt } from './identities-st.ts'
15
16
  import { identityAddress, isSection, type AccountTab, type IdentityRow } from './identity-address.ts'
@@ -69,7 +70,7 @@ export const IdentitiesView = observer(({ app }: { app: HomeSt }) => {
69
70
  {st.data?.errors.map((e) => <div key={e} className="hnote">{e}</div>)}
70
71
  {st.data == null && st.error === '' ? <div className="iddim"><span className="spin" />reading the identities folder…</div> : null}
71
72
  {st.data != null && st.sel.id != null ? <div className="hnote">no identity « {st.sel.id} » in {st.data.dir ?? 'the house repo'}: {st.data.identities.map((x) => x.name).join(', ') || 'none'}</div> : null}
72
- {st.data != null && st.data.identities.length === 0 ? <div className="iddim">no identity: write wiki/identities/&lt;id&gt;/identity.md in the house repo</div> : null}
73
+ {st.data != null && st.data.identities.length === 0 ? <div className="iddim">no identity: write wiki/identities/&lt;id&gt;/identity.md in the house repo <Configure app={app} topic="identities" /></div> : null}
73
74
  </div>
74
75
  )
75
76
  return (
@@ -24,6 +24,7 @@
24
24
  <link rel="stylesheet" href="./vault.css" />
25
25
  <link rel="stylesheet" href="./advisors.css" />
26
26
  <link rel="stylesheet" href="./space.css" />
27
+ <link rel="stylesheet" href="./configuration.css" />
27
28
  <link rel="stylesheet" href="./readme.css" />
28
29
  <link rel="stylesheet" href="./dock.css" />
29
30
  <link rel="stylesheet" href="./controls.css" />
@@ -6,6 +6,7 @@
6
6
  // and colour is state only: green on, red silent, orange what a note is about.
7
7
  import { observer } from 'mobx-react-lite'
8
8
  import type { HomeSt } from './home-st.ts'
9
+ import { Configure } from './configure-link.tsx'
9
10
  import { CardHead } from './card-head.tsx'
10
11
  import { tip } from './tips.ts'
11
12
  import { activityLines, countWords, followLine, driftKey, driftWords, gateWords, isMine, type Machine, type MachinesSt, type MNode, nodeFacts, nodeOrder, nodeRest, onOwnBrowser, processLines, reposOf, stateOf, stateWords } from './machines-st.ts'
@@ -243,6 +244,7 @@ export const MachinesView = observer(({ app }: { app: HomeSt }) => {
243
244
  <div className="hall machines">
244
245
  <div className="actop">
245
246
  <span className="acdim">{d == null ? (st.error !== '' ? '' : 'reading the hq…') : `${countWords(d.machines)} · read at ${clock(d.at)} · in the console: sk machines`}</span>
247
+ <Configure app={app} topic="machines" />
246
248
  </div>
247
249
  {st.error !== '' ? <div className="hnote mcerr">{st.error}</div> : null}
248
250
  {st.askError != null ? <div className="hnote mcerr">{st.askError}</div> : null}
@@ -1,4 +1,4 @@
1
1
  // where each page of the home answers. A leaf: a module the root state reads (the picker through a panel source)
2
2
  // takes the paths here, never from home-st.ts, which would close a cycle of imports
3
3
  /** the address of each page of the home that is no repo's */
4
- export const PLACE_PATH = { wiki: '/wiki', overview: '/', running: '/running', inbox: '/inbox', machines: '/machines', database: '/database', vault: '/vault', space: '/space', advisors: '/advisors', planned: '/planned', activity: '/activity', insights: '/insights', time: '/time', recordings: '/recordings', identities: '/identities', archived: '/archived' } as const
4
+ export const PLACE_PATH = { wiki: '/wiki', overview: '/', running: '/running', inbox: '/inbox', machines: '/machines', database: '/database', vault: '/vault', space: '/space', advisors: '/advisors', configuration: '/configuration', planned: '/planned', activity: '/activity', insights: '/insights', time: '/time', recordings: '/recordings', identities: '/identities', archived: '/archived' } as const
@@ -232,7 +232,7 @@ export function cardModel(p: Project, now: number): CardModel {
232
232
  }
233
233
 
234
234
  /** a page of the home that is no repo's */
235
- export type Place = 'wiki' | 'overview' | 'running' | 'inbox' | 'machines' | 'database' | 'vault' | 'space' | 'advisors' | 'planned' | 'activity' | 'insights' | 'time' | 'recordings'
235
+ export type Place = 'wiki' | 'overview' | 'running' | 'inbox' | 'machines' | 'database' | 'vault' | 'space' | 'advisors' | 'planned' | 'activity' | 'insights' | 'time' | 'recordings' | 'configuration'
236
236
 
237
237
  /** the global group's rows, in their order: the picker, the inbox, the overview, then the places, each with its
238
238
  * shortcut (keys.ts); ⌘↑ ⌘↓ walk them in this order, the picker aside (panel-walk.ts) */
@@ -252,6 +252,7 @@ export const PLACES: { id: Place | 'picker'; label: string; title: string }[] =
252
252
  { id: 'insights', label: 'insights', title: 'boxes about every repo: the packages they use and by how many, version drift, script names' },
253
253
  { id: 'time', label: 'time', title: 'where the agents\' time went, for every repo or one: model, tools, waits, turns, slow and failing commands, hooks' },
254
254
  { id: 'recordings', label: 'recordings', title: 'the screen recorder\'s takes of every repo: play, trim, crop, copy a link or the file' },
255
+ { id: 'configuration', label: 'configuration', title: 'everything you can set on this machine: backup targets, secrets, Claude accounts, GitHub, identities, machines; where each stands and what sets it' },
255
256
  ]
256
257
 
257
258
  /** a global entry of the main panel (main-panel.tsx): a page of the home, the picker, the identities */
@@ -23,6 +23,7 @@ import { SectionHead } from './section-head.tsx'
23
23
  import type { SecretsSt } from './secrets-st.ts'
24
24
  import { Age, stampWords } from './time-ago.tsx'
25
25
  import { tip } from './tips.ts'
26
+ import { Configure } from './configure-link.tsx'
26
27
 
27
28
  const TONE = { red: 't-red', warn: 't-warn', dim: 'ldim' } as const
28
29
 
@@ -222,6 +223,7 @@ const Summary = observer(({ app, v }: { app: RepoSt; v: SecretsView }) => {
222
223
  <div className="stagewrap">
223
224
  <div className="sxpage">
224
225
  <Top app={app}><div className="cghead">{v.house ? 'the secrets of the house' : `the secrets ${v.repo} reads`}<span className="cnt">{v.rows.length}</span></div></Top>
226
+ <Configure app={app.home} topic="secrets" />
225
227
  {v.notes.map((n) => <div key={n} className="sxnote t-warn">{n}</div>)}
226
228
  {needs.length === 0 ? <div className="sxcalm ldim">{quietLine(v.rows, v)}: nothing waits on you</div> : (
227
229
  <>
@@ -20,6 +20,7 @@ import { FactRow } from './vault-view.tsx'
20
20
  import { entryMark } from './vault-st.ts'
21
21
  import { ageWords, bytesWords } from '../../core/words.ts'
22
22
  import { tip } from './tips.ts'
23
+ import { Configure } from './configure-link.tsx'
23
24
 
24
25
  /** what each entry of the bar holds, said beside its name on the right */
25
26
  const ABOUT: Record<SpaceEntry, string> = {
@@ -185,6 +186,7 @@ export const SpaceView = observer(({ app }: { app: HomeSt }) => {
185
186
  <span className={`acring${busy || st.asking ? ' on' : ''}`}>↻</span>
186
187
  </button>
187
188
  <span className="acdim">{d == null ? (st.error !== '' ? '' : 'reading what the listing kept…') : v == null ? `${d.machine} · the house config names no Space` : narrow ? `${v.title} · ${shortListed(v, d.at)}` : `${d.machine} · ${v.title}, ${v.role} · ${shortListed(v, d.at)} · a page to read, nothing is changed from here · in the console: sk space`}</span>
189
+ <Configure app={app} topic="media" />
188
190
  </div>
189
191
  {st.error !== '' ? <div className="hnote mcerr">{st.error}</div> : null}
190
192
  {d == null || v == null ? null : (
@@ -19,6 +19,7 @@ import { plainClick, repoPage, type HomeSt } from './home-st.ts'
19
19
  import { type Col, Hint, Table } from './time-charts.tsx'
20
20
  import { entryMark, factsOf, VAULT_ENTRIES, type VaultEntry, type VaultSt } from './vault-st.ts'
21
21
  import { tip } from './tips.ts'
22
+ import { Configure } from './configure-link.tsx'
22
23
 
23
24
  const clock = (at: number): string => new Date(at).toTimeString().slice(0, 5)
24
25
 
@@ -193,6 +194,7 @@ export const VaultView = observer(({ app }: { app: HomeSt }) => {
193
194
  <span className={`acring${st.loading ? ' on' : ''}`}>↻</span>
194
195
  </button>
195
196
  <span className="acdim">{d == null ? (st.error !== '' ? '' : 'reading the vault…') : `${d.machine} · read at ${clock(d.at)} · a page to read, nothing is changed from here · in the console: sk vault status (--secrets for the names)`}</span>
197
+ <Configure app={app} topic="vault" />
196
198
  </div>
197
199
  {st.error !== '' ? <div className="hnote mcerr">{st.error}</div> : null}
198
200
  {d == null ? null : (