rvlib-shipkit 2.17.0 → 2.18.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 (52) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.json +1 -1
  3. package/src/checks/SK039-vscode-watch-generated.check.ts +119 -0
  4. package/src/cli/cmd_Review.ts +4 -0
  5. package/src/core/discover-checks.ts +18 -5
  6. package/src/home/beat.ts +30 -0
  7. package/src/home/home-paths.ts +1 -0
  8. package/src/home/pm.ts +3 -1
  9. package/src/home/run-daemon.ts +5 -2
  10. package/src/home/run-web.ts +4 -2
  11. package/src/home/supervise.ts +18 -1
  12. package/src/review/model.ts +11 -0
  13. package/src/scaffold/files/vscode-settings.json +9 -1
  14. package/src/serve/hub-app/auto-text.tsx +6 -1
  15. package/src/serve/hub-app/hub-app.tsx +28 -2
  16. package/src/serve/hub-app/icons.tsx +1 -0
  17. package/src/serve/hub-app/identities-view.tsx +1 -1
  18. package/src/serve/hub-app/kept-cols.tsx +47 -8
  19. package/src/serve/hub-app/layout-st.ts +37 -3
  20. package/src/serve/hub-app/review/review-kit.ts +8 -0
  21. package/src/serve/hub-app/review/review-page.tsx +1 -1
  22. package/src/serve/hub-app/review/review-st.ts +38 -6
  23. package/src/serve/hub-app/review/review-thread.tsx +2 -1
  24. package/src/serve/hub-app/review/review-views.tsx +91 -20
  25. package/src/serve/hub-app/review/thread-st.ts +23 -1
  26. package/src/serve/hub-app/review/trailer-page.tsx +1 -1
  27. package/src/serve/hub-app/review.css +24 -0
  28. package/src/serve/hub-app/social/comms-page.tsx +1 -1
  29. package/src/serve/hub-app/social/kit.tsx +3 -3
  30. package/src/serve/hub-app/social/post-card.tsx +2 -1
  31. package/src/serve/hub-app/social/social-page.tsx +1 -1
  32. package/src/serve/hub-app/social.css +1 -1
  33. package/src/serve/hub-app/stores/stores-page.tsx +5 -4
  34. package/src/serve/hub-app/veille/veille-page.tsx +3 -2
  35. package/src/serve/serve-hub.ts +4 -4
  36. package/src/serve/warm-cell.ts +63 -1
  37. package/src/shot/box.ts +32 -9
  38. package/src/shot/browser-slot.ts +8 -1
  39. package/src/shot/client.ts +9 -4
  40. package/src/shot/clip-encoder.ts +5 -2
  41. package/src/shot/job-store.ts +167 -0
  42. package/src/shot/shooter.ts +31 -4
  43. package/src/social/load.ts +3 -1
  44. package/src/suite/select.ts +32 -6
  45. package/src/trailer/grammar.ts +2 -0
  46. package/src/trailer/graph.ts +9 -3
  47. package/src/trailer/sound/presets.ts +3 -3
  48. package/src/trailer/sound/run.ts +22 -14
  49. package/src/trailer/titles.ts +1 -1
  50. package/src/wiki/lint-md.ts +4 -2
  51. package/src/wiki/run-wiki.ts +11 -5
  52. package/src/wiki/scan-md.ts +3 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 2.18.0
2
+
3
+ - **SK039: VS Code watches none of shipkit's generated folders.** `.vscode/settings.json` excludes `**/.shipkit/cache/**`, `**/.shipkit/tmp/**`, `**/.shipkit/review/**` and `**/trailer/**/out/**` from `files.watcherExclude`, so the files a build, a film or a test writes never wake the extension host. It warns, and the fix pass of every `sk ci` inserts the missing globs into the hand written jsonc, every other byte kept, or writes a settings file holding the exclusion alone. A glob set to `false` stays; a root published to npm or a linked `.vscode/` is left alone. The scaffold's template carries the block.
4
+ - **The hubs' background warms share one budget of the loop.** Every background recompute of every hub waits its turn in one process wide queue, so however many repos the daemon serves, they hold its loop a quarter of the time at most; a first read or a fresh one never queues. The home page with every repo watched stalled the daemon for over a minute at a time.
5
+ - **A verdict shows the moment it is clicked.** The card and its row draw the chosen verdict while it is sent, and show the error and the truth again if the send fails.
6
+ - **The test selection lists an ignored folder as one entry.** With `tests.select` on, the suite listing asked git for every ignored file (700k in one repo, 16 s); it now names an ignored folder once and walks only the folders bun would search.
7
+ - **A note box grows to show its whole placeholder.** `AutoText` sizes an empty box to its hint, and every multi line field of the hub is now `AutoText`.
8
+ - **A stalled browser can no longer hold a slot for hours.** A browser close and a cookie read get 5 s, the slot frees whatever happened, a call to the shot service waits at most twice the ask's cap, and a waiter names how long each holder has held its slot.
9
+ - **A page that reloads mid film fails with its reason** (a dev server's reload on a save) instead of a TypeError.
10
+ - **A slow `push` glides.** The push is drawn with `perspective` at sub pixel positions; `zoompan` stepped by whole pixels and shook.
11
+ - **A shot or a film on a box starts from an empty store of its own.** Each context of the box's warm browser sees only its own `localStorage` and IndexedDB, kept across a reload inside it and removed when it closes, so no value another job left on the origin changes the page. The HTTP cache stays shared and warm. `openBrowser(pw, { store: 'shared' })` keeps the old shared store.
12
+
13
+ ## 2.17.1
14
+
15
+ - **A `big` title keeps the cut's line breaks.** Each `\n` starts a line, and a line wider than the frame still wraps; the lines used to be joined and wrapped wherever the width fell.
16
+ - **A sound made on another machine never waits on the local load.** A `SoundRun` says `remote: true` when its work runs elsewhere; the voice, sfx and music presets set it, so an ElevenLabs line or a comfy box generation starts at once. FluidSynth and a hand written run still wait while the load is over 16.
17
+ - **A sign in survives the warm shooter's context swaps.** The cookies of a closed context (another viewport, a clip, the idle close) pass to the next one, in memory only.
18
+ - **The md scan skips a link to nothing** instead of crashing `sk wiki lint`.
19
+ - **`sk wiki lint` no longer calls `agent/global-contribution.md` an orphan**: the house index lists it.
20
+ - **A draft for an identity with no account yet loads.** `## short` and `## vertical` are always valid headings; the draft waits and posts nowhere.
21
+ - **`sk review add` warns when no watch hears the new card**, and names the one that would (`--mine`, `--lane <id>`). Only a watch of the card's own session or lane counts.
22
+
1
23
  ## 2.17.0
2
24
 
3
25
  - **`sk secret` lists the secrets of the repo you stand in.** `sk secret list` reads the house's creds and the repo's own, keeps the ones whose new `for` scope (`{ repos, identities }`, absent for every repo) names this repo, by its config name or its folder, or the identity it speaks as, and marks each `ok` or `MISS` through `credsReadCommand`, never printing a value; `--all` keeps the rest, marked `out`. `sk secret get|account <name>` and `sk secret set <name> [account]` go through the same `credsReadCommand` and `credsCommand` templates. A list, not an access control.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rvlib-shipkit",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "funding": "https://github.com/sponsors/rvion",
5
5
  "description": "All-in-one repo companion: ci gate (task DAG), auto-discovered health checks, release-contract fulfillness, asks queue, md-wiki tools, asset atelier, live tui",
6
6
  "license": "MIT",
@@ -0,0 +1,119 @@
1
+ // SK039 vscode watch generated (patterns/vscode-tasks/index.md): VS Code watches no folder shipkit writes for itself.
2
+ // Its file watcher walks the whole workspace, so every file a gate, a shot, a film or a review card writes under
3
+ // these folders woke the editor's extension host, for every repo open in a window.
4
+ //
5
+ // the file is hand-written jsonc: the repair inserts the missing keys after the last one and leaves every other byte,
6
+ // and writes a settings file of its own only where the repo has none
7
+ import { check } from '../check.ts'
8
+ import type { CheckCtx } from '../core/check-ctx.ts'
9
+ import { rootPublishesNpm } from '../core/repo-facts.ts'
10
+ import { indentAt, parseSpans, type Node } from '../scaffold/jsonc-spans.ts'
11
+
12
+ const SETTINGS = '.vscode/settings.json'
13
+ const KEY = 'files.watcherExclude'
14
+
15
+ /** the folders shipkit writes in a repo that no person edits: the gate's cache, scratch, the review store's media,
16
+ * a trailer's built cuts */
17
+ export const GENERATED_GLOBS = ['**/.shipkit/cache/**', '**/.shipkit/tmp/**', '**/.shipkit/review/**', '**/trailer/**/out/**'] as const
18
+
19
+ type Obj = Extract<Node, { kind: 'object' }>
20
+
21
+ /** where new props go in `o`: after its last prop (a comma added when it has none, past a comment ending its line),
22
+ * else right after its brace; the indent of its props */
23
+ function insertPoint(text: string, o: Obj, outer: string): { at: number; comma: number | null; indent: string } {
24
+ const last = o.props.at(-1)
25
+ if (last == null) return { at: o.start + 1, comma: null, indent: `${outer} ` }
26
+ const indent = indentAt(text, last.keyStart)
27
+ let j = last.value.end
28
+ while (j < o.end && /[ \t]/.test(text[j]!)) j++
29
+ const hasComma = text[j] === ','
30
+ const from = hasComma ? j + 1 : last.value.end
31
+ // the rest of the line, a trailing comment included, stays with the prop it follows
32
+ const eol = text.indexOf('\n', from)
33
+ const rest = eol < 0 ? '' : text.slice(from, eol)
34
+ const at = eol >= 0 && eol < o.end && /^\s*(\/\/.*)?$/.test(rest) ? eol : from
35
+ return { at, comma: hasComma ? null : last.value.end, indent }
36
+ }
37
+
38
+ const splice = (text: string, edits: { at: number; put: string }[]): string =>
39
+ edits.sort((a, b) => b.at - a.at).reduce((t, e) => t.slice(0, e.at) + e.put + t.slice(e.at), text)
40
+
41
+ /** the settings text with every generated folder excluded from VS Code's watcher, and the globs it added; null when
42
+ * the file is not one object */
43
+ export function withWatchExcludes(text: string): { text: string; added: string[] } | null {
44
+ const root = parseSpans(text)
45
+ if (root.kind !== 'object') return null
46
+ const prop = root.props.find((p) => p.key === KEY)
47
+ if (prop != null && prop.value.kind !== 'object') return null
48
+ const have = prop == null ? new Map<string, unknown>() : new Map((prop.value as Obj).props.map((p) => [p.key, p.value.kind === 'scalar' ? p.value.value : null]))
49
+ // a glob the repo set to false is its own decision, kept
50
+ const added = GENERATED_GLOBS.filter((g) => !have.has(g))
51
+ if (added.length === 0) return { text, added }
52
+ if (prop != null) {
53
+ const o = prop.value as Obj
54
+ const p = insertPoint(text, o, indentAt(text, prop.keyStart))
55
+ const lines = added.map((g) => `\n${p.indent}"${g}": true`).join(',')
56
+ // an empty object gets its closing brace back on a line of its own
57
+ const close = o.props.length === 0 ? `\n${indentAt(text, prop.keyStart)}` : ''
58
+ const edits = [{ at: p.at, put: `${lines}${close}` }, ...(p.comma != null ? [{ at: p.comma, put: ',' }] : [])]
59
+ return { text: splice(text, edits), added }
60
+ }
61
+ const p = insertPoint(text, root, '')
62
+ const inner = added.map((g) => `${p.indent} "${g}": true`).join(',\n')
63
+ const block = `\n\n${p.indent}// shipkit's generated folders: never watched (SK039)\n${p.indent}"${KEY}": {\n${inner}\n${p.indent}}`
64
+ const edits = [{ at: p.at, put: block }, ...(p.comma != null ? [{ at: p.comma, put: ',' }] : [])]
65
+ return { text: splice(text, edits), added }
66
+ }
67
+
68
+ /** a settings file holding the exclusion alone, for a repo that has none */
69
+ export const freshSettings = (): string =>
70
+ `{\n // shipkit's generated folders: never watched (SK039)\n "${KEY}": {\n${GENERATED_GLOBS.map((g) => ` "${g}": true`).join(',\n')}\n }\n}\n`
71
+
72
+ const PUBLIC_SKIP = `the root unit publishes to npm: ${SETTINGS} belongs to every contributor, so it is never written`
73
+
74
+ function ownSettings(c: CheckCtx): { text: string } | 'none' | 'linked' {
75
+ if (c.isLink('.vscode')) return 'linked'
76
+ if (!c.exists(SETTINGS)) return 'none'
77
+ const text = c.read(SETTINGS)
78
+ return text == null ? 'none' : { text }
79
+ }
80
+
81
+ export const vscodeWatchGenerated = check({
82
+ id: 'SK039',
83
+ // an editor setting behind is waste, not a broken repo: it warns, and the fix pass of every gate repairs it
84
+ blocking: false,
85
+ title: 'vscode watch generated',
86
+ description: "VS Code watches none of shipkit's generated folders: cache, tmp, review, trailer cuts",
87
+ owner: 'patterns/vscode-tasks/index.md',
88
+ runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: false, onHealth: true, onSave: 'moved', onClock: false },
89
+ cache: { by: 'reads' },
90
+ fix: 'ci',
91
+ applies: 'always',
92
+ run: (c) => {
93
+ if (rootPublishesNpm(c.config)) return c.ok(PUBLIC_SKIP)
94
+ const own = ownSettings(c)
95
+ if (own === 'linked') return c.ok('.vscode/ is a link to a shared dir, left alone')
96
+ if (own === 'none') return c.fail(`no ${SETTINGS}: VS Code watches every generated folder (${GENERATED_GLOBS.join(', ')})`)
97
+ let r: ReturnType<typeof withWatchExcludes>
98
+ try { r = withWatchExcludes(own.text) }
99
+ catch (e) { return c.warn(`${SETTINGS} does not parse (${(e as Error).message}), so its watcher exclusions were not checked`) }
100
+ if (r == null) return c.warn(`${SETTINGS}: no object, or ${KEY} is no object, so its exclusions were not checked`)
101
+ if (r.added.length === 0) return c.ok(`${SETTINGS}: VS Code watches no generated folder`)
102
+ c.fail(`${SETTINGS}: ${KEY} misses ${r.added.join(', ')}`)
103
+ },
104
+ repair: (c) => {
105
+ if (rootPublishesNpm(c.config)) return { changed: false, summary: PUBLIC_SKIP }
106
+ const own = ownSettings(c)
107
+ if (own === 'linked') return { changed: false, summary: '.vscode/ is a link, left alone' }
108
+ if (own === 'none') {
109
+ c.write(SETTINGS, freshSettings())
110
+ return { changed: true, summary: `${SETTINGS}: written, VS Code watches no generated folder` }
111
+ }
112
+ const r = withWatchExcludes(own.text)
113
+ if (r == null || r.added.length === 0) return { changed: false, summary: `${SETTINGS} already current, or not one object` }
114
+ c.write(SETTINGS, r.text)
115
+ return { changed: true, summary: `${SETTINGS}: ${KEY} gained ${r.added.join(', ')}` }
116
+ },
117
+ })
118
+
119
+ export default vscodeWatchGenerated
@@ -252,6 +252,10 @@ export class ReviewAddCommand extends Command {
252
252
  const item = await addItem(h.dir, input)
253
253
  h.out(item.id)
254
254
  if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the card: pass --lane <id> (or SK_AGENT), so the hub colours it')
255
+ const { unheardLine } = await import('../review/model.ts')
256
+ const { liveWatchers } = await import('../review/watchers.ts')
257
+ const unheard = unheardLine(item, liveWatchers(h.dir))
258
+ if (unheard) h.err(unheard)
255
259
  return 0
256
260
  })
257
261
  }
@@ -25,6 +25,8 @@ import { check, type CheckDef, type CheckFrom } from '../check.ts'
25
25
  import { CHECK_SUFFIX as SUFFIX, fallbackNames, isLegacyCheckSource, SKIPPED_DIRS as IGNORED_DIRS, UNIT_SUFFIX, unitBase } from './check-file-names.ts'
26
26
  import { unitKind } from '../shipkit-files.ts'
27
27
  import { readVendored } from './vendored-read.ts'
28
+ import { gitBin } from './git-bin.ts'
29
+ import { keptOnTree } from './tree-rev.ts'
28
30
 
29
31
  export { fallbackNames, isLegacyCheckSource } from './check-file-names.ts'
30
32
 
@@ -101,15 +103,26 @@ function walkKept(dir: string, out: string[], suffix: string, dirs: string[] | u
101
103
  dirs?.push(...seen)
102
104
  }
103
105
 
104
- /** the absolute vendored dirs of a repo, which no repo walk enters */
105
- const vendoredPrune = (root: string): ReadonlySet<string> => new Set(readVendored(root).map((d) => join(root, d)))
106
+ /** the absolute dirs no repo walk enters: the vendored ones, and every one git ignores. A folder of captures or a
107
+ * build output holds thousands of dirs, and a walk through them holds the daemon's loop for seconds */
108
+ const prunedDirs = (root: string): ReadonlySet<string> => new Set([...readVendored(root).map((d) => join(root, d)), ...ignoredDirs(root)])
109
+
110
+ /** the dirs git ignores under `root`, absolute, read again once the tree moved (one git spawn); none outside git */
111
+ function ignoredDirs(root: string): string[] {
112
+ return keptOnTree(ignoredLists, root, () => {
113
+ const p = Bun.spawnSync([gitBin(), 'ls-files', '--others', '--ignored', '--exclude-standard', '--directory', '-z'], { cwd: root, stdout: 'pipe', stderr: 'ignore' })
114
+ if (p.exitCode !== 0) return []
115
+ return p.stdout.toString().split('\0').filter((f) => f.endsWith('/')).map((f) => join(root, f.slice(0, -1)))
116
+ })
117
+ }
118
+ const ignoredLists = new Map<string, { rev: number; value: string[] }>()
106
119
 
107
120
  /** every `*.shipkit.ts` file under a repo root, by the same walk. Sorted.
108
121
  * `dirs` collects every dir the walk read: a file added to one moves its
109
122
  * mtime, which is how a reader tells the list moved without walking again */
110
123
  export function repoUnitFiles(root: string, dirs?: string[]): string[] {
111
124
  const out: string[] = []
112
- walkKept(root, out, UNIT_SUFFIX, dirs, vendoredPrune(root))
125
+ walkKept(root, out, UNIT_SUFFIX, dirs, prunedDirs(root))
113
126
  return out.sort()
114
127
  }
115
128
 
@@ -134,7 +147,7 @@ export async function importFresh(path: string): Promise<unknown> {
134
147
  * Sorted. */
135
148
  export function repoCheckFiles(root: string): string[] {
136
149
  const out: string[] = []
137
- walkKept(root, out, SUFFIX, undefined, vendoredPrune(root))
150
+ walkKept(root, out, SUFFIX, undefined, prunedDirs(root))
138
151
  return out.sort()
139
152
  }
140
153
 
@@ -229,7 +242,7 @@ export async function discoverChecks(root: string, o: DiscoverOpts = {}): Promis
229
242
  const builtins: string[] = []
230
243
  walk(builtinDir, builtins)
231
244
  const found: string[] = []
232
- walkKept(root, found, SUFFIX, undefined, vendoredPrune(root))
245
+ walkKept(root, found, SUFFIX, undefined, prunedDirs(root))
233
246
  const units = repoUnitFiles(root)
234
247
  // the repo that HOSTS the toolkit walks over `src/checks/` too, and a file
235
248
  // discovered twice is a duplicate id rather than a second check. Real paths,
@@ -0,0 +1,30 @@
1
+ // a child's heartbeat on disk: its loop touches `<role>.beat` once a second, the file holding its pid. pm reads it
2
+ // before it kills a child that does not answer its probe: a beat this young says the loop still turns between long
3
+ // steps (a starved child on a loaded machine), where a hung one never turns again (home/supervise.ts, killIfHung)
4
+ import { readFileSync, statSync, utimesSync, writeFileSync } from 'fs'
5
+
6
+ export const BEAT_EVERY_MS = 1_000
7
+
8
+ /** starts the beat of this process; the function it returns stops it */
9
+ export function startBeat(file: string, pid = process.pid): () => void {
10
+ const write = (): void => {
11
+ try { writeFileSync(file, String(pid)) } catch { /* a read only home: pm then kills on the probe alone */ }
12
+ }
13
+ write()
14
+ const t = setInterval(() => {
15
+ const now = new Date()
16
+ try { utimesSync(file, now, now) } catch { write() }
17
+ }, BEAT_EVERY_MS)
18
+ t.unref?.()
19
+ return () => clearInterval(t)
20
+ }
21
+
22
+ /** the last beat a file holds: its pid and when, or null when there is none */
23
+ export function readBeat(file: string): { pid: number; at: number } | null {
24
+ try {
25
+ const pid = Number(readFileSync(file, 'utf8').trim())
26
+ return Number.isInteger(pid) && pid > 0 ? { pid, at: statSync(file).mtimeMs } : null
27
+ } catch {
28
+ return null
29
+ }
30
+ }
@@ -67,6 +67,7 @@ export const pmLog = (dir = homeDir()): string => join(dir, 'pm.log')
67
67
  * the pid record the next pm adopts (supervise.ts pidKey) */
68
68
  export const childLog = (dir: string, role: string): string => join(dir, `${role}.log`)
69
69
  export const childPid = (dir: string, role: string): string => join(dir, `${role}.pid`)
70
+ export const childBeat = (dir: string, role: string): string => join(dir, `${role}.beat`)
70
71
  export const resourceLog = (dir: string, id: string): string => join(dir, 'resources', `${id}.log`)
71
72
  export const resourcePid = (dir: string, id: string): string => join(dir, 'resources', `${id}.pid`)
72
73
  export const stateFile = (dir: string): string => join(dir, 'state.json')
package/src/home/pm.ts CHANGED
@@ -12,7 +12,8 @@ import { join } from 'path'
12
12
  import { LIB_VERSION } from '../core/lib-version.ts'
13
13
  import { iconImageType } from '../shipkit-files.ts'
14
14
  import { sameOrigin } from '../serve/same-origin.ts'
15
- import { childLog, childPid, daemonPort, homePort, pmLog, pmPort } from './home-paths.ts'
15
+ import { readBeat } from './beat.ts'
16
+ import { childBeat, childLog, childPid, daemonPort, homePort, pmLog, pmPort } from './home-paths.ts'
16
17
  import type { Resources, ResourceView } from './resources.ts'
17
18
  import { capLog, Proc, realDeps, tailLines, type ProcView, type SuperviseDeps } from './supervise.ts'
18
19
 
@@ -86,6 +87,7 @@ export class Pm {
86
87
  // a crash loop while its code is being edited heals itself
87
88
  neverGiveUp: true,
88
89
  hangMs: CHILD_HANG_MS,
90
+ beat: () => readBeat(childBeat(d.dir, role)),
89
91
  say: d.say,
90
92
  }, d.deps ?? realDeps)]))
91
93
  }
@@ -19,7 +19,8 @@ import { loadRepoConfig } from '../repo-config.ts'
19
19
  import { ensureIdentity } from '../core/identity.ts'
20
20
  import { homedir } from 'os'
21
21
  import { join } from 'path'
22
- import { childLog, daemonPort, homeDir, homePort, homeUp, hubBase, publicHome, WORKER_ENV } from './home-paths.ts'
22
+ import { startBeat } from './beat.ts'
23
+ import { childBeat, childLog, daemonPort, homeDir, homePort, homeUp, hubBase, publicHome, WORKER_ENV } from './home-paths.ts'
23
24
  import { inboxAddress } from './inbox-shape.ts'
24
25
  import { HomeState } from './home-state.ts'
25
26
  import { Hubs } from './hubs.ts'
@@ -120,9 +121,11 @@ export async function runDaemon(root: string, io: HomeIo, o: { port?: number } =
120
121
  const jobs = onlyRepos() == null ? startJobs({ cli: CLI, cwd: root, dir: join(dir, 'jobs'), log: childLog(dir, 'daemon'), printErr: io.printErr }) : null
121
122
  // a job that holds the loop holds every page: each stall is said with the work that overlapped it
122
123
  const stalls = loopWatch.start(io.printErr)
124
+ // pm tells a starved daemon from a hung one by this beat: it turns with the loop
125
+ const beat = startBeat(childBeat(dir, 'daemon'))
123
126
  // its memory as a trend: a line only when it moved by a tenth, at most every 10 minutes
124
127
  const memory = new MemoryWatch().start(io.print)
125
- const code = reloadOnOwnCode({ role: 'daemon', entry: fileURLToPath(import.meta.url), busy: () => hubs.busy(), before: () => { stalls(); memory(); jobs?.stop(); home.stop() }, keep: true, io })
128
+ const code = reloadOnOwnCode({ role: 'daemon', entry: fileURLToPath(import.meta.url), busy: () => hubs.busy(), before: () => { stalls(); beat(); memory(); jobs?.stop(); home.stop() }, keep: true, io })
126
129
  io.print(` ${house.repos.length} repos, state in ${dir}, reloads on ${code.files} lib files`)
127
130
  for (const sig of ['SIGINT', 'SIGTERM'] as const)
128
131
  process.on(sig, () => {
@@ -4,7 +4,8 @@
4
4
  // its own code, the page included, restarts it in place (lib-watch.ts).
5
5
  import homePage from '../serve/hub-app/home.html'
6
6
  import { fileURLToPath } from 'url'
7
- import { daemonPort, daemonUrl, homePort, homeUp, pmUrl } from './home-paths.ts'
7
+ import { startBeat } from './beat.ts'
8
+ import { childBeat, daemonPort, daemonUrl, homeDir, homePort, homeUp, pmUrl } from './home-paths.ts'
8
9
  import { reloadOnOwnCode } from './lib-watch.ts'
9
10
  import { serveWeb } from './serve-web.ts'
10
11
  import type { HomeIo } from './run-daemon.ts'
@@ -13,7 +14,8 @@ export async function runWeb(io: HomeIo, o: { port?: number } = {}): Promise<num
13
14
  const port = o.port ?? homePort()
14
15
  try {
15
16
  const web = serveWeb({ port, daemon: daemonUrl(daemonPort()), pm: pmUrl(), page: homePage })
16
- const code = reloadOnOwnCode({ role: 'web', entry: fileURLToPath(import.meta.url), bundles: true, before: () => web.stop(), io })
17
+ const beat = startBeat(childBeat(homeDir(), 'web'))
18
+ const code = reloadOnOwnCode({ role: 'web', entry: fileURLToPath(import.meta.url), bundles: true, before: () => { beat(); web.stop() }, io })
17
19
  io.print(`home → http://localhost:${web.server.port} (the daemon: ${daemonUrl()}, pm: ${pmUrl()}), reloads on ${code.files} lib files`)
18
20
  for (const sig of ['SIGINT', 'SIGTERM'] as const)
19
21
  process.on(sig, () => {
@@ -33,6 +33,9 @@ export type ProcSpec = {
33
33
  * (a main thread stuck in one synchronous step still holds its port):
34
34
  * killed, then started again after the crash backoff. None = never */
35
35
  hangMs?: number
36
+ /** the child's last heartbeat: its loop touches a file while it turns (home/beat.ts). One of this pid newer than
37
+ * hangMs says the child is starved (slow steps on a loaded machine), not hung: it is kept, up to STARVED_MAX_MS */
38
+ beat?: () => { pid: number; at: number } | null
36
39
  /** a line for every act the supervisor takes on its own */
37
40
  say?: (line: string) => void
38
41
  }
@@ -72,6 +75,9 @@ export const CRASH_LIMIT = 5
72
75
  export const CRASH_WINDOW_MS = 5 * 60_000
73
76
  /** a stop that SIGTERM did not end becomes a SIGKILL after this */
74
77
  export const KILL_AFTER_MS = 5_000
78
+ /** how long a starved child is kept without an answer: past it, a loop that beats but never answers (a wedged
79
+ * server) is killed all the same */
80
+ export const STARVED_MAX_MS = 10 * 60_000
75
81
 
76
82
  /** the process is started by a shell that exits at once: it belongs to init
77
83
  * from its first moment, so a supervisor that restarts in place (execve)
@@ -145,6 +151,8 @@ export class Proc {
145
151
  private probing = false
146
152
  /** why the kill in flight was a hang kill, for the crash note */
147
153
  private hung: string | null = null
154
+ /** the start of the probe silence already said to be starvation, so it is said once */
155
+ private starvedSince: number | null = null
148
156
  /** a restart: start again once the stop landed */
149
157
  private again = false
150
158
  /** it answers its probe with no pid of ours behind it */
@@ -336,7 +344,16 @@ export class Proc {
336
344
  private killIfHung(now: number): void {
337
345
  const hang = this.spec.hangMs
338
346
  if (hang == null || this.status !== 'starting' || this.pid == null || this.want !== 'up' || now - this.since < hang) return
339
- this.hung = `did not answer its probe for ${Math.round((now - this.since) / 1000)}s`
347
+ const silent = Math.round((now - this.since) / 1000)
348
+ const beat = this.spec.beat?.() ?? null
349
+ if (beat != null && beat.pid === this.pid && now - beat.at < hang && now - this.since < STARVED_MAX_MS) {
350
+ if (this.starvedSince !== this.since) {
351
+ this.starvedSince = this.since
352
+ this.spec.say?.(`WARN ${this.spec.id} (pid ${this.pid}) did not answer its probe for ${silent}s, but its loop beat ${Math.round((now - beat.at) / 1000)}s ago: starved, not hung, kept (killed past ${STARVED_MAX_MS / 60_000} min)`)
353
+ }
354
+ return
355
+ }
356
+ this.hung = `did not answer its probe for ${silent}s${beat != null && beat.pid === this.pid && now - beat.at < hang ? ', though its loop beats' : ''}`
340
357
  this.spec.say?.(`WARN ${this.spec.id} (pid ${this.pid}) ${this.hung}: killed, it starts again`)
341
358
  this.d.kill(this.pid, 'SIGTERM')
342
359
  this.killAt = now + KILL_AFTER_MS
@@ -658,6 +658,17 @@ export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
658
658
  /** the live watchers that will read his answer on any of these cards */
659
659
  export const listenersOf = (cards: readonly ReviewItem[], watchers: readonly Watcher[]): Watcher[] => watchers.filter((w) => cards.some((x) => coversCard(w, x)))
660
660
 
661
+ /** what `review add` says when no live watch of the card's own session or lane will read his answer, else null: an
662
+ * unfiltered watch (a dispatcher, another session) hears it for someone else */
663
+ export function unheardLine(item: Item, watchers: readonly Watcher[]): string | null {
664
+ const o = item.origin
665
+ if (o.by !== 'agent') return null
666
+ const own = o.session || o.lane ? watchers.filter((w) => (o.session && w.session === o.session) || (o.lane && w.lane === o.lane)) : watchers
667
+ if (listenersOf([{ item, thread: [] }], own).length > 0) return null
668
+ const watch = o.session ? 'sk review watch --mine' : o.lane ? `sk review watch --lane ${o.lane}` : 'sk review watch'
669
+ return `no watch hears this card: run \`${watch}\` under a monitor now, so his answer reaches you as it lands`
670
+ }
671
+
661
672
  /** a card's own session has this long after its last message to claim it before a watch calls it untaken */
662
673
  export const UNTAKEN_GRACE_MS = 2 * 60 * 1000
663
674
  /** a card nobody takes is told again this often */
@@ -35,5 +35,13 @@
35
35
 
36
36
  // eslint off, and no formatter on save: formatting is a manual `bun fmt`
37
37
  "eslint.enable": false,
38
- "js/ts.format.enabled": false
38
+ "js/ts.format.enabled": false,
39
+
40
+ // shipkit's generated folders: never watched (SK039)
41
+ "files.watcherExclude": {
42
+ "**/.shipkit/cache/**": true,
43
+ "**/.shipkit/tmp/**": true,
44
+ "**/.shipkit/review/**": true,
45
+ "**/trailer/**/out/**": true
46
+ }
39
47
  }
@@ -19,7 +19,12 @@ export function AutoText({ value, onText, rows = 1, el, className, ...rest }: Pr
19
19
  if (t == null) return
20
20
  t.style.height = 'auto'
21
21
  const edge = t.offsetHeight - t.clientHeight
22
- t.style.height = `${t.scrollHeight + edge}px`
22
+ // an empty box is as tall as its placeholder: the hint reads whole, never cut by a scrollbar
23
+ const hint = t.value === '' && t.placeholder !== ''
24
+ if (hint) t.value = t.placeholder
25
+ const h = t.scrollHeight
26
+ if (hint) t.value = ''
27
+ t.style.height = `${h + edge}px`
23
28
  // a sheet's max-height stops it: only then may it scroll
24
29
  t.style.overflowY = t.scrollHeight > t.clientHeight + 1 ? 'auto' : 'hidden'
25
30
  }, [])
@@ -38,7 +38,7 @@ import { CommsPage } from './social/comms-page.tsx'
38
38
  import { SocialPage } from './social/social-page.tsx'
39
39
  import { ProjectList } from './project-list.tsx'
40
40
  import { Group, Panel, Separator, usePanelRef, type Layout } from 'react-resizable-panels'
41
- import { LIST, SIDEBAR } from './layout-st.ts'
41
+ import { FOLD_PAGES, LIST, SIDEBAR, type LayoutSt } from './layout-st.ts'
42
42
  import { ArchivedView, HomeStrip, NotUp, Overview } from './home-strip.tsx'
43
43
  import { PlannedView } from './planned-view.tsx'
44
44
  import { ActivityView } from './activity-view.tsx'
@@ -176,6 +176,16 @@ const leftPx = (el: HTMLElement | null, layout: Layout, id: string): number | nu
176
176
  const Body = observer(({ app }: { app: RepoSt }) => {
177
177
  const l = app.home.layout
178
178
  const el = useRef<HTMLDivElement | null>(null)
179
+ // a page with columns folded on the left (W): no sidebar, the page's own bar stands where it was (kept-cols.tsx)
180
+ if (FOLD_PAGES.has(app.sel?.t ?? '') && l.foldedOn(app.sel?.t, 'left'))
181
+ return (
182
+ <div className="appbody rv-widebody">
183
+ <div className="pmain" style={PANEL} onPointerDownCapture={() => app.tree.leave()}>
184
+ <Main app={app} />
185
+ <PageFrames app={app} />
186
+ </div>
187
+ </div>
188
+ )
179
189
  return (
180
190
  <Group className="appbody" orientation="horizontal" elementRef={el}
181
191
  onLayoutChanged={(layout, meta) => {
@@ -216,6 +226,17 @@ const RepoView = observer(({ app }: { app: RepoSt }) => {
216
226
  })
217
227
 
218
228
  /** the keys of the page: they act on the repo shown, and on nothing else */
229
+ /** W or T, plain and outside a text field: that side of the page folds, or unfolds */
230
+ function foldKey(e: KeyboardEvent, page: string, layout: LayoutSt): boolean {
231
+ const t = e.target as HTMLElement
232
+ if (e.metaKey || e.ctrlKey || e.altKey || t.tagName === 'TEXTAREA' || t.tagName === 'INPUT' || t.isContentEditable) return false
233
+ const k = e.key.toLowerCase()
234
+ if (k !== 'w' && k !== 't') return false
235
+ e.preventDefault()
236
+ layout.toggleFold(page, k === 'w' ? 'left' : 'right')
237
+ return true
238
+ }
239
+
219
240
  function onKey(e: KeyboardEvent): void {
220
241
  // the embed page has its page's own keys and nothing else
221
242
  if (embed != null) {
@@ -247,7 +268,10 @@ function onKey(e: KeyboardEvent): void {
247
268
  return
248
269
  }
249
270
  if (home.palette.open) return // the picker's input owns its keys
250
- if (home.page === 'identities') return identityKey(e)
271
+ if (home.page === 'identities') {
272
+ if (foldKey(e, 'identities', home.layout)) return
273
+ return identityKey(e)
274
+ }
251
275
  const app = home.shown
252
276
  if (app == null) return
253
277
  const t = e.target as HTMLElement
@@ -264,6 +288,8 @@ function onKey(e: KeyboardEvent): void {
264
288
  e.preventDefault()
265
289
  return
266
290
  }
291
+ // W folds the left of a page with columns, T its right; what a page took above stays its own (T on Veille)
292
+ if (FOLD_PAGES.has(app.sel?.t ?? '') && foldKey(e, app.sel!.t, home.layout)) return
267
293
  // a repo's own page, ⌥⇧ and its letter
268
294
  const letter = pageLetterKey(e)
269
295
  if (letter != null) {
@@ -25,6 +25,7 @@ export const ICON = {
25
25
  // fold every cell: two chevrons meeting; unfold every cell: two chevrons apart
26
26
  foldAll: 'M6 3.5l4 4 4-4M6 16.5l4-4 4 4',
27
27
  unfoldAll: 'M6 7.5l4-4 4 4M6 12.5l4 4 4-4',
28
+ wide: 'M3 7V3h4M13 3h4v4M17 13v4h-4M7 17H3v-4',
28
29
  // a repo page's sections, then its two runs and its editor
29
30
  readme: 'M5 2.5h7l3 3v12H5zM12 2.5v3h3M7.5 9h5M7.5 12h5M7.5 15h3',
30
31
  checks: 'M4 10.5 7.5 14 16 5.5',
@@ -70,7 +70,7 @@ export const IdentitiesView = observer(({ app }: { app: HomeSt }) => {
70
70
  )
71
71
  return (
72
72
  <div className="so-page idview">
73
- <KeptCols id="identities">
73
+ <KeptCols id="identities" folds={{ left: 'identity-list' }} layout={app.layout}>
74
74
  <Panel id="identity-list" defaultSize="30%" minSize={260} className="rv-pane" style={PANEL}>
75
75
  <IdentityList app={app} i={i} />
76
76
  </Panel>
@@ -1,8 +1,13 @@
1
1
  // a page's columns (the identities, social, comms, stores, Veille, review and trailer pages): the widths his drags
2
2
  // leave are kept per browser and page, so a reload draws them as he left them from the first paint. One group per
3
- // page id; the panel ids inside must stay the same for a kept layout to apply (useDefaultLayout's own rule).
4
- import type { ReactNode } from 'react'
3
+ // page id; the panel ids inside must stay the same for a kept layout to apply (useDefaultLayout's own rule), so each
4
+ // fold has its own kept layout. A page names the panel W folds (its list, the left) and the one T folds (the right):
5
+ // a folded side leaves a thin bar with a knob where it was, and a click on the bar brings it back. W also folds the
6
+ // repo's sidebar (hub-app.tsx, Body), so a page with no left panel still gives its main column the room.
7
+ import { observer } from 'mobx-react-lite'
8
+ import { Children, isValidElement, type ReactNode } from 'react'
5
9
  import { Group, useDefaultLayout, type LayoutStorage } from 'react-resizable-panels'
10
+ import type { FoldSide, LayoutSt } from './layout-st.ts'
6
11
 
7
12
  /** the browser's storage, or nothing: a private window or blocked site data keeps the layout for the tab only */
8
13
  const STORE: LayoutStorage = {
@@ -20,11 +25,45 @@ const STORE: LayoutStorage = {
20
25
  },
21
26
  }
22
27
 
23
- export const KeptCols = ({ id, children }: { id: string; children: ReactNode }) => {
24
- const kept = useDefaultLayout({ id: `hub:cols:${id}`, storage: STORE, onlySaveAfterUserInteractions: true })
28
+ /** the panel each key folds, by its id */
29
+ export type ColFolds = { left?: string; right?: string }
30
+
31
+ /** the children left once the folded panels go, each with the separator that stood between it and the rest */
32
+ export function unfolded(children: ReactNode, folds: ColFolds, folded: (side: FoldSide) => boolean): ReactNode[] {
33
+ const all = Children.toArray(children)
34
+ const idOf = (c: ReactNode): string | undefined => (isValidElement<{ id?: string }>(c) ? c.props.id : undefined)
35
+ const drop = new Set<number>()
36
+ for (const side of ['left', 'right'] as const) {
37
+ const id = folds[side]
38
+ if (id == null || !folded(side)) continue
39
+ const at = all.findIndex((c) => idOf(c) === id)
40
+ if (at < 0) continue
41
+ drop.add(at)
42
+ // the separator on the side of the rest: after a left panel, before a right one
43
+ drop.add(side === 'left' ? at + 1 : at - 1)
44
+ }
45
+ return all.filter((_, i) => !drop.has(i))
46
+ }
47
+
48
+ /** the bar a folded side leaves: the whole height, a knob at mid height, a click brings the side back */
49
+ const FoldBar = ({ side, onClick }: { side: FoldSide; onClick: () => void }) => (
50
+ <button className={`rv-widebar ${side}`} title={side === 'left' ? 'show the sidebar and the list again (W)' : 'show the right panel again (T)'} aria-label={side === 'left' ? 'unfold the left' : 'unfold the right'} onClick={onClick}>
51
+ <span className="rv-wideknob" aria-hidden="true">{side === 'left' ? '›' : '‹'}</span>
52
+ </button>
53
+ )
54
+
55
+ export const KeptCols = observer(({ id, children, folds, layout }: { id: string; children: ReactNode; folds?: ColFolds; layout?: LayoutSt }) => {
56
+ const folded = (side: FoldSide): boolean => layout?.foldedOn(id, side) === true
57
+ const tag = (['left', 'right'] as const).filter((s) => folds?.[s] != null && folded(s)).map((s) => `:${s}`).join('')
58
+ const kept = useDefaultLayout({ id: `hub:cols:${id}${tag}`, storage: STORE, onlySaveAfterUserInteractions: true })
59
+ const bar = (side: FoldSide): ReactNode => (layout != null && folded(side) && (side === 'left' || folds?.right != null) ? <FoldBar side={side} onClick={() => layout.toggleFold(id, side)} /> : null)
25
60
  return (
26
- <Group className="rv-cols" orientation="horizontal" defaultLayout={kept.defaultLayout} onLayoutChanged={kept.onLayoutChanged}>
27
- {children}
28
- </Group>
61
+ <div className="rv-foldrow">
62
+ {bar('left')}
63
+ <Group key={tag} className="rv-cols" orientation="horizontal" defaultLayout={kept.defaultLayout} onLayoutChanged={kept.onLayoutChanged}>
64
+ {folds == null ? children : unfolded(children, folds, folded)}
65
+ </Group>
66
+ {bar('right')}
67
+ </div>
29
68
  )
30
- }
69
+ })