@stacksjs/defaults 0.75.571 → 0.75.573

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 (63) hide show
  1. package/ai/skills/stacks-actions/SKILL.md +1 -1
  2. package/ai/skills/stacks-browse/scripts/chrome.ts +107 -4
  3. package/ai/skills/stacks-cms/SKILL.md +1 -1
  4. package/ai/skills/stacks-dashboard/SKILL.md +283 -12
  5. package/ai/skills/stacks-database/SKILL.md +3 -1
  6. package/ai/skills/stacks-native/CATALOG.md +2 -2
  7. package/ai/skills/stacks-orm/SKILL.md +5 -1
  8. package/ai/skills/stacks-testing/SKILL.md +11 -1
  9. package/app/Actions/Dashboard/Content/CommentUpdateAction.ts +1 -1
  10. package/app/Actions/Dashboard/Content/PostStoreAction.ts +1 -1
  11. package/app/Actions/Dashboard/Content/PostUpdateAction.ts +1 -1
  12. package/app/Actions/Dashboard/Marketing/marketing-list-records.test.ts +2 -2
  13. package/app/Actions/Dashboard/Marketing/marketing-list-records.ts +4 -4
  14. package/app/Actions/Dashboard/Models/ModelShowAction.ts +42 -43
  15. package/app/Actions/Dashboard/Models/ModelUpdateAction.ts +17 -3
  16. package/app/Actions/Dashboard/Models/model-filters.ts +429 -0
  17. package/app/Actions/Dashboard/Models/model-switches.ts +159 -0
  18. package/app/Actions/Dashboard/Models/model-write.ts +6 -0
  19. package/app/Models/Comment.ts +3 -3
  20. package/app/Models/Content/Post.ts +3 -3
  21. package/app/Models/EmailList.ts +8 -6
  22. package/app/Models/Subscriber.ts +2 -0
  23. package/app/Models/Team.ts +2 -0
  24. package/app/Models/User.ts +3 -0
  25. package/functions/dashboard-model-filters.ts +219 -0
  26. package/functions/dashboard-model-record.ts +42 -8
  27. package/ide/vscode/package.json +1 -1
  28. package/package.json +3 -3
  29. package/resources/components/Dashboard/Commerce/CommerceCategoryDialog.stx +3 -1
  30. package/resources/components/Dashboard/Commerce/CommerceCouponDialog.stx +3 -1
  31. package/resources/components/Dashboard/Commerce/CommerceGiftCardDialog.stx +9 -3
  32. package/resources/components/Dashboard/Commerce/CommerceManufacturerDialog.stx +3 -4
  33. package/resources/components/Dashboard/Commerce/CommerceProductDialog.stx +3 -1
  34. package/resources/components/Dashboard/Commerce/CommerceReviewEditDialog.stx +6 -8
  35. package/resources/components/Dashboard/Commerce/CommerceTaxDialog.stx +6 -14
  36. package/resources/components/Dashboard/Commerce/CommerceUnitDialog.stx +3 -7
  37. package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveryDialog.stx +6 -2
  38. package/resources/components/Dashboard/Content/BlogPostEditorDialog.stx +2 -8
  39. package/resources/components/Dashboard/Content/PageEditorDialog.stx +3 -7
  40. package/resources/components/Dashboard/Content/PostEditorDialog.stx +3 -4
  41. package/resources/components/Dashboard/Data/DataModelRecords.stx +12 -75
  42. package/resources/components/Dashboard/Data/DataStatCards.stx +110 -0
  43. package/resources/components/Dashboard/Email/InboxSettingsDashboard.stx +20 -36
  44. package/resources/components/Dashboard/Marketing/MarketingListDialog.stx +7 -14
  45. package/resources/components/Dashboard/Marketing/MarketingListsDashboard.stx +3 -2
  46. package/resources/components/Dashboard/Models/ModelFieldInputs.stx +10 -13
  47. package/resources/components/Dashboard/Models/ModelFilterPanel.stx +166 -0
  48. package/resources/components/Dashboard/Models/ModelRecordDetail.stx +18 -0
  49. package/resources/components/Dashboard/Models/ModelRecordEdit.stx +3 -2
  50. package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +96 -29
  51. package/resources/components/Dashboard/Models/ModelRegion.stx +25 -0
  52. package/resources/components/Dashboard/Models/ModelRegionFor.stx +31 -0
  53. package/resources/components/Dashboard/Operations/RecoveryDestinationDialog.stx +2 -2
  54. package/resources/components/Dashboard/Operations/RecoveryPolicyDialog.stx +3 -1
  55. package/resources/components/Dashboard/Operations/RecoveryRestoreDialog.stx +3 -1
  56. package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +11 -14
  57. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +6 -9
  58. package/resources/components/Dashboard/UI/Toggle.stx +16 -12
  59. package/resources/functions/dashboard/regions.ts +113 -0
  60. package/resources/functions/dashboard/sidebar.ts +2 -0
  61. package/views/dashboard/composables/useModelList.ts +52 -0
  62. package/views/dashboard/composables/useModelRecord.ts +46 -0
  63. package/views/dashboard/stores/model-page.ts +105 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: stacks-actions
3
- description: Use when working with Stacks server actions - creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the 756 default framework actions (auth, dashboard, commerce, content, deployment, jobs), action request/response handling, or action registration. Covers @stacksjs/actions and storage/framework/defaults/app/Actions/.
3
+ description: Use when working with Stacks server actions - creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the 758 default framework actions (auth, dashboard, commerce, content, deployment, jobs), action request/response handling, or action registration. Covers @stacksjs/actions and storage/framework/defaults/app/Actions/.
4
4
  license: MIT
5
5
  compatibility: Bun >= 1.3.0, TypeScript
6
6
  allowed-tools: Read Edit Write Bash Grep Glob
@@ -1,5 +1,6 @@
1
1
  // Shared Chrome executable preparation for the standalone skill and testing package.
2
- import { existsSync, mkdirSync, mkdtempSync, readdirSync, renameSync, rmSync } from 'node:fs'
2
+ import { createHash } from 'node:crypto'
3
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, renameSync, rmSync, writeFileSync } from 'node:fs'
3
4
  import { tmpdir } from 'node:os'
4
5
  import { basename, join } from 'node:path'
5
6
  import process from 'node:process'
@@ -72,17 +73,111 @@ function frameworkVersions(directory: string): { path: string, identifier: strin
72
73
  return result
73
74
  }
74
75
 
76
+ /**
77
+ * The framework versions a private copy has no use for: every one that
78
+ * `Versions/Current` does not point at.
79
+ *
80
+ * Chrome's updater keeps the version it replaced beside the new one, for the
81
+ * browser that is still running it, and keeps it until that browser is
82
+ * relaunched. Each is some 700 MB of code. A private copy is always started
83
+ * fresh and only ever loads `Current`, yet every one of them was signed when
84
+ * the copy was made and verified again before each reuse: with two updates
85
+ * pending that was 2.1 GB and 20 to 28 seconds before a browser could start,
86
+ * which is longer than a test waits. A framework with no `Current` link is
87
+ * left whole, since nothing says which of its versions is the one in use.
88
+ */
89
+ function supersededFrameworkVersions(directory: string): string[] {
90
+ const result: string[] = []
91
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
92
+ if (!entry.isDirectory()) continue
93
+ const child = join(directory, entry.name)
94
+ result.push(...supersededFrameworkVersions(child))
95
+ const versions = join(child, 'Versions')
96
+ if (!entry.name.endsWith('.framework') || !existsSync(versions)) continue
97
+ let current: string
98
+ try { current = basename(readlinkSync(join(versions, 'Current'))) }
99
+ catch { continue }
100
+ if (!existsSync(join(versions, current))) continue
101
+ for (const version of readdirSync(versions, { withFileTypes: true })) {
102
+ if (version.isDirectory() && version.name !== current)
103
+ result.push(join(versions, version.name))
104
+ }
105
+ }
106
+ return result
107
+ }
108
+
75
109
  function validSignature(app: string): boolean {
76
110
  return Bun.spawnSync(['codesign', '--verify', '--deep', '--strict', app], { stdout: 'pipe', stderr: 'pipe' }).exitCode === 0
77
111
  }
78
112
 
113
+ /**
114
+ * What a copy looked like when its signature was last verified: every file's
115
+ * path, size and modification time, and every link's target, as one digest.
116
+ *
117
+ * Strict verification reads the whole bundle, about 15 seconds for one Chrome
118
+ * version, and every test process that started a browser paid it again for a
119
+ * copy nothing had touched. A copy whose files are all where they were, the
120
+ * size they were and as old as they were is the copy that was verified, so
121
+ * it is reused without being read again. Anything else, a file rewritten,
122
+ * removed by the temp cleaner or added, changes the digest and the copy is
123
+ * verified in full before it is trusted.
124
+ */
125
+ function bundleFingerprint(app: string): string {
126
+ const lines: string[] = []
127
+ const walk = (directory: string, prefix: string): void => {
128
+ for (const entry of readdirSync(directory, { withFileTypes: true }).sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {
129
+ const path = join(directory, entry.name), relative = `${prefix}${entry.name}`
130
+ if (entry.isSymbolicLink()) { lines.push(`${relative}\tlink\t${readlinkSync(path)}`); continue }
131
+ if (entry.isDirectory()) { walk(path, `${relative}/`); continue }
132
+ const stat = lstatSync(path, { bigint: true })
133
+ lines.push(`${relative}\tfile\t${stat.size}\t${stat.mtimeNs}`)
134
+ }
135
+ }
136
+ walk(app, '')
137
+ return createHash('sha256').update(lines.join('\n')).digest('hex')
138
+ }
139
+
140
+ /** Kept beside the copy, never inside it: a file added to a bundle breaks its seal. */
141
+ const stampOf = (app: string): string => `${app}.verified`
142
+ const STAMP_FORMAT = 'stacks-chrome-verified-1'
143
+
144
+ function verifiedUnchanged(app: string): boolean {
145
+ try { return readFileSync(stampOf(app), 'utf8') === `${STAMP_FORMAT}\n${bundleFingerprint(app)}\n` }
146
+ catch { return false }
147
+ }
148
+
149
+ /** Record that `app`, as it is now, passed strict verification. Written whole or not at all. */
150
+ function recordVerified(app: string): void {
151
+ const pending = `${stampOf(app)}.${process.pid}`
152
+ try {
153
+ writeFileSync(pending, `${STAMP_FORMAT}\n${bundleFingerprint(app)}\n`)
154
+ renameSync(pending, stampOf(app))
155
+ }
156
+ catch {
157
+ // The copy is still valid without its stamp; the next run verifies it again.
158
+ rmSync(pending, { force: true })
159
+ }
160
+ }
161
+
162
+ /** A cached copy that may be launched: unchanged since it was verified, or verified now. */
163
+ function trustedCopy(app: string): boolean {
164
+ if (verifiedUnchanged(app)) return true
165
+ if (!validSignature(app)) return false
166
+ recordVerified(app)
167
+ return true
168
+ }
169
+
79
170
  /**
80
171
  * A private clone of a macOS Chrome that GoogleUpdater leaves alone (see the
81
172
  * module docs): `cp -cR`, the `KS*` keys deleted from `Info.plist`, its own
82
173
  * `CFBundleIdentifier`, and a complete ad-hoc signature. Every framework
83
174
  * version shares an explicit designated requirement, as required for a
84
- * multi-version bundle (Apple TN2206). Kept in `directory` (default a
85
- * per-version temp folder) and reused only after strict signature validation.
175
+ * multi-version bundle (Apple TN2206). Framework versions the updater kept
176
+ * for a browser that is still running are left out of the copy, which only
177
+ * ever runs the current one. Kept in `directory` (default a per-version temp
178
+ * folder) and reused only when it is the copy that passed strict signature
179
+ * validation: unchanged since, by every file's size and age, or validated
180
+ * again now.
86
181
  */
87
182
  export function prepareMacChrome(options: { source?: string, directory?: string } = {}): PreparedChrome {
88
183
  if (process.platform !== 'darwin') throw new Error('prepareMacChrome is for macOS; elsewhere launch Chrome as installed')
@@ -99,8 +194,11 @@ export function prepareMacChrome(options: { source?: string, directory?: string
99
194
  .map(entry => join(directory, entry.name)).sort() : []
100
195
  for (const candidate of candidates) {
101
196
  const executable = join(candidate, 'Contents/MacOS', executableName), info = join(candidate, 'Contents/Info.plist')
197
+ // A copy made before superseded versions were left out still verifies,
198
+ // slowly. It is passed over, not removed: a browser may be running it.
102
199
  if (existsSync(executable) && plist(info, 'Print :CFBundleIdentifier').out === PRIVATE_BUNDLE_ID
103
- && plist(info, 'Print :CFBundleShortVersionString').out === version && validSignature(candidate))
200
+ && plist(info, 'Print :CFBundleShortVersionString').out === version
201
+ && supersededFrameworkVersions(candidate).length === 0 && trustedCopy(candidate))
104
202
  return { executable, app: candidate, reused: true }
105
203
  }
106
204
 
@@ -122,6 +220,9 @@ export function prepareMacChrome(options: { source?: string, directory?: string
122
220
  const stagedInfo = join(staged, 'Contents/Info.plist')
123
221
  for (const key of UPDATER_KEYS) plist(stagedInfo, `Delete :${key}`)
124
222
  run(['/usr/libexec/PlistBuddy', '-c', `Set :CFBundleIdentifier ${PRIVATE_BUNDLE_ID}`, stagedInfo], 'Renaming the Chrome bundle')
223
+ // Before signing, so what is left out is neither signed nor sealed into
224
+ // the copy. Only the clone is touched: the installed app keeps them all.
225
+ for (const superseded of supersededFrameworkVersions(staged)) rmSync(superseded, { recursive: true, force: true })
125
226
  const versions = frameworkVersions(staged)
126
227
  // --deep only signs the current framework version. Prepare the code in
127
228
  // every version first, then seal nested frameworks and their parents.
@@ -138,6 +239,8 @@ export function prepareMacChrome(options: { source?: string, directory?: string
138
239
  destination = join(directory, `Chrome-${basename(staging)}.app`)
139
240
  renameSync(staged, destination)
140
241
  }
242
+ // Verified a moment ago, as the staged copy. Moving it changed no file.
243
+ recordVerified(destination)
141
244
  return { executable: join(destination, 'Contents/MacOS', executableName), app: destination, reused: false }
142
245
  }
143
246
  finally {
@@ -75,7 +75,7 @@ interface CmsNamespace {
75
75
  | views | number | - | 0 |
76
76
  | publishedAt | timestamp | optional | - |
77
77
  | status | enum | published/draft/archived | draft |
78
- | isFeatured | number | 0 or 1 | - |
78
+ | isFeatured | boolean | yes or no | - |
79
79
 
80
80
  ### Author
81
81
  - **Table**: `authors`, **Relationships**: `hasMany(['Post'])`, `belongsTo(['User'])`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: stacks-dashboard
3
- description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the 427 built-in dashboard components. Covers the dashboard system at storage/framework/defaults/.
3
+ description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the 431 built-in dashboard components. Covers the dashboard system at storage/framework/defaults/.
4
4
  license: MIT
5
5
  compatibility: Bun >= 1.3.0, TypeScript
6
6
  allowed-tools: Read Edit Write Bash Grep Glob
@@ -8,7 +8,7 @@ allowed-tools: Read Edit Write Bash Grep Glob
8
8
 
9
9
  # Stacks Dashboard
10
10
 
11
- The Stacks admin dashboard provides a full-featured admin panel with 100+ route views, 427 components, and a multi-section layout.
11
+ The Stacks admin dashboard provides a full-featured admin panel with 100+ route views, 431 components, and a multi-section layout.
12
12
 
13
13
  ## Key Paths
14
14
  - Dashboard components: `storage/framework/defaults/resources/components/Dashboard/`
@@ -600,6 +600,41 @@ Keep semantic controls such as tabs, switches, pagination state, window
600
600
  controls, dialog backdrops, and table row menus in their dedicated components.
601
601
  They are controls, not alternate action-button styles.
602
602
 
603
+ ### On/off settings are the switch
604
+
605
+ An on/off setting is `Dashboard/UI/Toggle.stx`, in a model's form and in every
606
+ hand-built page and dialog (stacksjs/stacks#3297, #3301). Do not write a
607
+ checkbox for one.
608
+
609
+ ```html
610
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
611
+ <Toggle v-model:checked="isActive" label="Enabled for redemption" description="Availability is stored separately from lifecycle status." labelPosition="left" />
612
+ </div>
613
+ ```
614
+
615
+ - `v-model:checked` takes a signal or a key of a reactive object
616
+ (`v-model:checked="drafts[field.key]"`). Where the state is read through a
617
+ function (`isVisible(section.id)`), bind `:checked` and take
618
+ `@update:checked`, which carries the new boolean.
619
+ - `labelPosition="left"` puts the name on the left and the switch on the
620
+ right, the settings-row look. Without it the switch leads, which suits a
621
+ short option in a row of options.
622
+ - `error` shows a refused save's message in place of the description, and
623
+ `disabled` dims only the track, so a reason under a switch that cannot be
624
+ turned stays readable.
625
+ - **Give it a box of its own inside a `space-y-*` stack.** That utility puts
626
+ its margin on the component's scope wrapper, which makes no box, so a
627
+ switch that is a direct child loses its spacing. Wrap it in a `div`, or use
628
+ `flex flex-col gap-*` on the parent. The dev server says so when it sees it.
629
+ - A label that has quotation marks of its own goes in a constant and is bound
630
+ with `:label`.
631
+
632
+ A native checkbox is still right for what is not an on/off setting: picking
633
+ rows, several of many (a post's tags, a token's scopes), an instruction for
634
+ this save only ("Clear stored password"), an acknowledgement, and "remember
635
+ me" or the terms on the sign-in forms. `tests/unit/dashboard-switch-contract.test.ts`
636
+ lists every one by file with its reason and fails on any other.
637
+
603
638
  ### Sidebar-aware overlays
604
639
 
605
640
  The desktop sidebar is fixed and publishes its current width through
@@ -752,7 +787,7 @@ forms draw them with one component, `Dashboard/Models/ModelFieldInputs`:
752
787
  | Rule | Control | Stored as |
753
788
  |---|---|---|
754
789
  | `enum` | select of its allowed values | the value |
755
- | `boolean` | checkbox | true or false |
790
+ | `boolean` | switch (`Dashboard/UI/Toggle`) | true or false |
756
791
  | `number`, `integer`, `float`, `unix` | number box | a number |
757
792
  | `date` | date picker | the calendar day |
758
793
  | `timestamp`, `timestampTz`, `datetime` | date and time, in the visitor's zone | UTC `YYYY-MM-DD HH:MM:SS` (ISO for `timestampTz`) |
@@ -822,6 +857,205 @@ not "Team ID"). The list endpoint returns the names with the rows
822
857
  (`relationNames`), one lookup per related model per page, and a record's page
823
858
  uses the same ones.
824
859
 
860
+ ### Changing a page: declare, extend, replace
861
+
862
+ Three ways, cheapest first. Reach for the next one only when the one before
863
+ cannot say it.
864
+
865
+ 1. **Declare.** The model's `dashboard` block: `columns`, `fields`,
866
+ `filters`, `actions`, `writes`. The dashboard already knows how to draw
867
+ these, and they survive every upgrade.
868
+ 2. **Extend.** `dashboard.regions` places a component of the app's own at a
869
+ named place on the framework's page. The page stays the framework's.
870
+ 3. **Replace.** A file of the same name under the app's
871
+ `resources/views/dashboard/` or `resources/components/Dashboard/` wins
872
+ over the framework's. The app owns that file from then on and gets no
873
+ updates to it.
874
+
875
+ ### A model places its own component on a page
876
+
877
+ ```ts
878
+ // app/Models/Order.ts
879
+ dashboard: {
880
+ regions: { recordTop: 'OrderTimeline', listBottom: 'OrderTotals' },
881
+ }
882
+ ```
883
+
884
+ | Place | Where |
885
+ |---|---|
886
+ | `listTop` | on the model's list, under its title and above its search |
887
+ | `listBottom` | on the model's list, under its table |
888
+ | `recordTop` | on a record's page, under its title and above its fields |
889
+ | `recordBottom` | on a record's page, under the panels of who points at it |
890
+
891
+ Each names one component by the name its file has, under the app's
892
+ `resources/components/Dashboard/` (any folder inside it):
893
+ `resources/components/Dashboard/Orders/OrderTimeline.stx`. No build step and
894
+ no registration. One per place; a component that needs several things
895
+ composes them. It applies on `/models/{model}` and its record pages, and on
896
+ the Users, Teams and Subscribers pages that host the list.
897
+
898
+ A shipped model does the same with a shipped component, which is the one
899
+ place this framework uses a region of its own: `User`, `Team` and
900
+ `Subscriber` each put `Data/DataStatCards.stx`, their row of numbers, at
901
+ `listTop` (stacksjs/stacks#3299). In this repository a region's component
902
+ lives under `storage/framework/defaults/resources/components/Dashboard/`,
903
+ never in the root `resources/`.
904
+
905
+ The component is handed `model` (the slug) and `region` as plain props.
906
+ What the page loads it reads as signals:
907
+
908
+ ```html
909
+ <script client>
910
+ import { useModelRecord } from '@stacksjs/defaults/views/dashboard/composables/useModelRecord'
911
+
912
+ const { record, reload } = useModelRecord()
913
+ const shipped = derived(() => record()?.status === 'shipped')
914
+ </script>
915
+
916
+ <Card :if="record()">
917
+ <p :text="shipped() ? 'Shipped' : 'Not shipped yet'"></p>
918
+ </Card>
919
+ ```
920
+
921
+ - `useModelRecord()`: `record()` is the row's values by column, null until
922
+ it has loaded; `details()` is everything the page was told (column
923
+ labels, the records it points at by name, what may be done); `model()`,
924
+ `id()`; `reload()` asks the page to read the record again.
925
+ - `useModelList()`: `rows()`, `total()`, `search()`, `filters()`,
926
+ `model()`, `reload()`. It follows the list as it is searched, narrowed and
927
+ paged. `changes()` goes up each time the list changes a record (a delete,
928
+ a bulk run that did something, one of the model's actions) and not when it
929
+ is searched or paged: watch it to read numbers of your own again.
930
+
931
+ **Start in `onMount`, stop in `onDestroy`.** A placed component's script
932
+ runs on every model page that has its place, whether or not the component is
933
+ put on that page. Only `onMount` and `onDestroy` belong to the page it is
934
+ actually on. So:
935
+
936
+ ```html
937
+ <script client>
938
+ import { useModelList } from '@stacksjs/defaults/views/dashboard/composables/useModelList'
939
+
940
+ const { changes } = useModelList()
941
+ let stop: (() => void) | null = null
942
+
943
+ onMount(() => {
944
+ void load()
945
+ let seen = changes()
946
+ stop = effect(() => {
947
+ if (changes() === seen)
948
+ return
949
+ seen = changes()
950
+ void load()
951
+ })
952
+ })
953
+ onDestroy(() => stop?.())
954
+ </script>
955
+ ```
956
+
957
+ An `effect` or a request at the top of the script runs for other models'
958
+ pages too and is never stopped: the stat cards, written that way, asked for
959
+ users' and subscribers' numbers each time a team was deleted, once more for
960
+ every page visited (stacksjs/stx#2189). `state`, `derived` and functions at
961
+ the top are fine; they do nothing until read.
962
+
963
+ How it works, and what follows from it:
964
+
965
+ - A dashboard page is the same document at every address: stx draws a view
966
+ that has no script of its own once and serves that to all of them, and the
967
+ page reads its address in the browser. So the server cannot draw "this
968
+ model's component". `Models/ModelRegion.stx` draws the component of
969
+ **every** model that places one at that place
970
+ (`dashboardRegionEntries(place)`), each inside a `ModelRegionFor`, and
971
+ that puts on the page only the one whose model the page is showing. A
972
+ component written for orders is never shown or mounted on a team's page.
973
+ Its script is still set up there, which is why its work starts in
974
+ `onMount` (above).
975
+ - So do not read `params` in a view or a component to decide what to draw:
976
+ it holds the first address that was asked for.
977
+ - The page says which model it is showing through `stores/model-page.ts`,
978
+ before it loads anything, and clears its own when it goes. That is also
979
+ what the composables read, so a component never shows the record of the
980
+ page before.
981
+ - **Props are fixed when the page is drawn**: `model` and `region` only. The
982
+ record's id, like everything else that differs by address, comes from the
983
+ composables (`useModelRecord().id()`).
984
+ - `ModelRegionFor` draws the component in its own template, in the open and
985
+ close form. stx leaves `<component :is>` undrawn inside another
986
+ component's slot, and hands the self-closing form no props.
987
+ - What a model declared reaches the server through the manifest the
988
+ dashboard is started with. The dev server restarts itself when a model
989
+ changes.
990
+ - A place or a name that cannot be used is left out and logged once
991
+ (`[dashboard] Order dashboard.regions: 'sidebar' is not a place...`). A
992
+ name is only ever a component's (`OrderTimeline`), never a path.
993
+
994
+ `tests/unit/dashboard-model-regions.test.ts` renders the shipped wrapper
995
+ through stx and holds stx to what this depends on, so a change there fails a
996
+ test and not an app's page. It also holds every shipped model's region to a
997
+ shipped component that exists and starts its work in `onMount`.
998
+
999
+ ### A list's filters and sort are derived, not declared
1000
+
1001
+ Nothing declares a filter. `Models/model-filters.ts` reads which filters a
1002
+ list offers from what the model already says:
1003
+
1004
+ | Signal | Where | Decides |
1005
+ |---|---|---|
1006
+ | What the field is | its validation rule | whether it is a filter, and its control |
1007
+ | What results are narrowed by | `traits.useSearch.filterable` | offered first; a number or a line of text is only a filter when named here |
1008
+ | What is private | `hidden` | never offered, and never sortable |
1009
+
1010
+ | Field | Asked for as |
1011
+ |---|---|
1012
+ | A few allowed values (`schema.enum`) | pick any of them |
1013
+ | Yes or no (`schema.boolean`) | Yes / No |
1014
+ | `belongsTo` | the record picker the forms use |
1015
+ | A date or a moment | two days, and Today / Last 7 days / This month |
1016
+ | A number the model names | at least / at most |
1017
+ | Text the model names | chosen from the values the table holds when there are 20 or fewer (`withStoredChoices`, remembered for 30 seconds), else an exact value |
1018
+
1019
+ Prose and structures are searched, not filtered. A filter is what the model
1020
+ says the field is, never a guess from its name: a yes-or-no declared
1021
+ `schema.number()` is a number range until the model says `schema.boolean()`.
1022
+
1023
+ ```ts
1024
+ dashboard: { filters: ['status', 'team', 'createdAt'] }
1025
+ ```
1026
+
1027
+ names and orders them instead, in the vocabulary `dashboard.columns` uses (an
1028
+ attribute, a column, or a `belongsTo`). An empty list means no filters. A
1029
+ name that cannot be used is left out and logged once.
1030
+
1031
+ On the page (`Models/ModelFilterPanel.stx`) the Filter button opens a panel
1032
+ of those controls. What narrows the list is always shown as chips ("Channel:
1033
+ Email, SMS"), each with a clear button, and is written to the address
1034
+ (`modelListAddress`), so a narrowed list can be sent to someone.
1035
+
1036
+ On the wire, `filters` is a JSON object by column:
1037
+
1038
+ | Value | Means | For |
1039
+ |---|---|---|
1040
+ | `"3"` | exactly this | any column the page is sent (what a record's panel links with) |
1041
+ | `{ "in": ["a", "b"] }` | any of these | a choice, a relation, named text |
1042
+ | `{ "from": "...", "to": "..." }` | from, up to | a date (days, both included) or a moment (instants, end not included) |
1043
+ | `{ "min": 1, "max": 9 }` | between | a number the model names |
1044
+
1045
+ Each is checked against the field's kind and refused with a 422 in words
1046
+ before the database is asked ("Channel is not a date, so it has no range of
1047
+ days."). For a moment the page sends where the viewer's first day starts and
1048
+ where the day after their last one does (`modelFilterRange`), so "the 5th" is
1049
+ the viewer's 5th.
1050
+
1051
+ The response carries `filterable` (the filters) and `sortable` (the columns a
1052
+ heading orders by). Any stored value can be sorted. Prose, structures and
1053
+ columns that point at another record cannot: the cell shows that record's
1054
+ name, and ordering by its id would look random. Their headings are plain.
1055
+
1056
+ Not built: filters that are not one column ("Overdue"), saved views, and
1057
+ ordering a relation column by the related record's name.
1058
+
825
1059
  ### A model says how a field is called, shown and asked for
826
1060
 
827
1061
  An attribute says what a field is. It cannot say that `amount` is money and
@@ -1218,12 +1452,19 @@ labels, formats and actions on the model's `dashboard` block, not on the page.
1218
1452
  The list takes four props when it is hosted: `model` (the slug, instead of the
1219
1453
  last part of the address), `heading`, `description`, and `home` (where its
1220
1454
  create, invite, view and edit links lead, so `/data/users/7` and not
1221
- `/models/user/7`). It has a `summary` slot above the search, where the page
1222
- puts its stat cards, and it emits `changed` after a delete, a bulk run that
1223
- did something, or one of the model's actions, so the page reads its numbers
1224
- again. The numbers come from the page's old endpoint asked for them alone:
1225
- `GET /api/dashboard/users?only=stats` reads no rows (`statsOnly(request)` in
1226
- `Data/data-records.ts`; `fetchDashboardStats(mode)` on the client).
1455
+ `/models/user/7`). The hosting page adds nothing else.
1456
+
1457
+ The row of numbers above each list is the model's, not the page's: `User`,
1458
+ `Team` and `Subscriber` place `Data/DataStatCards.stx` at
1459
+ `dashboard.regions.listTop`, so the numbers are on `/data/users` and on
1460
+ `/models/user` alike (stacksjs/stacks#3299). They used to be written into
1461
+ the hosting page and handed to the list through a `summary` slot, which is
1462
+ gone. After a delete, a bulk run that did something, or one of the model's
1463
+ actions, the list tells the page store (`modelPageStore.listChanged`) and the
1464
+ cards read their numbers again. The numbers come from the page's old endpoint
1465
+ asked for them alone: `GET /api/dashboard/users?only=stats` reads no rows
1466
+ (`statsOnly(request)` in `Data/data-records.ts`; `fetchDashboardStats(mode)`
1467
+ on the client).
1227
1468
 
1228
1469
  Two stx behaviours shape this, and both fail silently:
1229
1470
 
@@ -1233,9 +1474,9 @@ Two stx behaviours shape this, and both fail silently:
1233
1474
  address ("No ORM model named Users").
1234
1475
  - What a page puts in another component's slot is read against that
1235
1476
  component's names first. A `page` in the hosting page was the list's page
1236
- number and the first card read "Total undefined". The hosting page's names
1237
- are deliberately its own (`recordsPage`, `pageStats`, `loadPageStats`);
1238
- `tests/unit/dashboard-data-pages.test.ts` fails if one collides.
1477
+ number and the first stat card read "Total undefined". The hosting page
1478
+ now puts nothing in a slot of the list, and
1479
+ `tests/unit/dashboard-data-pages.test.ts` fails if it does again.
1239
1480
 
1240
1481
  A status-like column (`status`, `role`, `state`, ... : `MODEL_BADGE_COLUMNS`)
1241
1482
  is a pill in a list as it is on a record's page, both drawn by
@@ -1289,6 +1530,36 @@ is not refused as a duplicate. An address that already has an account is
1289
1530
  refused on the email field. Drop `store` from `dashboard.writes` to turn
1290
1531
  inviting off.
1291
1532
 
1533
+ ### An account's confirmed email and two-factor are switches
1534
+
1535
+ A form asks for a model's own attributes. Whether an account's email is
1536
+ confirmed and whether it signs in with two-factor are not attributes: the
1537
+ `useAuth` trait owns those columns. They used to sit in the edit form's
1538
+ read-only panel, so confirming an address or letting someone back in who lost
1539
+ their device took a database console (stacksjs/stacks#3298).
1540
+
1541
+ On `User`'s edit form they are switches, saved with the rest of the form:
1542
+
1543
+ | Switch | On | Off |
1544
+ |---|---|---|
1545
+ | Email Verified | `setEmailVerified(id, true)` stamps the address as confirmed now | clears it |
1546
+ | Two Factor Enabled | never from here: only the account holder can enroll an authenticator | `disableTwoFactor(id)` removes the secret, the recovery codes and any open challenge |
1547
+
1548
+ The rules, all in `Actions/Dashboard/Models/model-switches.ts`:
1549
+
1550
+ - A switch is changed by the auth package's function, never by writing its
1551
+ column. That is the reason it is not a plain boolean field.
1552
+ - A switch that turns one way only is shown disabled while it cannot be
1553
+ turned, with the reason under it, and the server refuses the direction too.
1554
+ A refused switch refuses the whole save: nothing else is written.
1555
+ - A value that is not a yes or a no is refused, not read as "off".
1556
+ - They ride on the model's `update` permission, like every field of the form.
1557
+ - The create form has none: a new account has nothing to turn.
1558
+
1559
+ They are derived from the trait, not declared. A model cannot yet add a
1560
+ switch of its own for a column its own code keeps; do not fake one with a
1561
+ fillable boolean when changing the value needs more than writing it.
1562
+
1292
1563
  ## Application observability
1293
1564
 
1294
1565
  HTTP capture is opt-in through `config/server.ts: captureRequests: true` (or
@@ -132,7 +132,9 @@ const orderId = db.transaction((tx) => {
132
132
  behind it and is a promise whatever its own callback does. With only
133
133
  synchronous callbacks that cannot happen.
134
134
  - MySQL and Postgres run on a worker thread the caller waits on, sharing one
135
- pool with the models. `models: { execution: 'async' }` in `config/query-builder.ts`
135
+ pool with the models. On [stacksjs/bun](https://github.com/stacksjs/bun),
136
+ whose drivers can wait for a statement themselves, the pool is on the calling
137
+ thread and there is no worker; nothing else differs. `models: { execution: 'async' }` in `config/query-builder.ts`
136
138
  gives promises back for both; every call then has to be awaited.
137
139
 
138
140
  For reads which cannot tolerate replication lag, use `db.primary.selectFrom(...)`.
@@ -92,7 +92,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
92
92
  | `@stacksjs/testing` | [`stacks-testing`](../stacks-testing/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/index.ts) | 24 |
93
93
  | `@stacksjs/tinker` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/index.ts) | 4 |
94
94
  | `@stacksjs/tunnel` | [`stacks-tunnel`](../stacks-tunnel/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tunnel/src/index.ts) | 1 |
95
- | `@stacksjs/types` | [`stacks-types`](../stacks-types/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/index.ts) | 2 |
95
+ | `@stacksjs/types` | [`stacks-types`](../stacks-types/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/index.ts) | 3 |
96
96
  | `@stacksjs/ui` | [`stacks-ui`](../stacks-ui/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ui/src/index.ts) | 6 |
97
97
  | `@stacksjs/utils` | [`stacks-utils`](../stacks-utils/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/utils/src/index.ts) | 28 |
98
98
  | `@stacksjs/validation` | [`stacks-validation`](../stacks-validation/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/validation/src/index.ts) | 26 |
@@ -904,7 +904,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
904
904
 
905
905
  Local source modules: [src/ai.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/ai.ts), [src/analytics.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/analytics.ts), [src/api.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/api.ts), [src/app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/app.ts), [src/auction.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/auction.ts), [src/auth.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/auth.ts), [src/auto-imports.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/auto-imports.ts), [src/binary.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/binary.ts), [src/cache.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cache.ts), [src/cdn.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cdn.ts), [src/chat.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/chat.ts), [src/cli.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cli.ts), [src/cloud.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cloud.ts), [src/cms.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cms.ts), [src/commands.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/commands.ts), [src/commerce.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/commerce.ts), [src/components.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/components.ts), [src/configure.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/configure.ts), [src/cors.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cors.ts), [src/cron-jobs.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cron-jobs.ts), [src/dashboard.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/dashboard.ts), [src/database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/database.ts), [src/dependencies.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/dependencies.ts), [src/deploy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/deploy.ts), [src/desktop.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/desktop.ts), [src/dns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/dns.ts), [src/docs.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/docs.ts), [src/email.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/email.ts), [src/errors.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/errors.ts), [src/events.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/events.ts), [src/exit-code.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/exit-code.ts), [src/feature-flags.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/feature-flags.ts), [src/file-systems.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/file-systems.ts), [src/forms.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/forms.ts), [src/git.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/git.ts), [src/hashing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/hashing.ts), [src/helpers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/helpers.ts), [src/i18n.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/i18n.ts), [src/images.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/images.ts), [src/library.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/library.ts), [src/lint.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/lint.ts), [src/logging.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/logging.ts), [src/manifest.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/manifest.ts), [src/marketing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/marketing.ts), [src/mobile.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/mobile.ts), [src/model-dashboard-augmentation.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/model-dashboard-augmentation.ts), [src/model-names.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/model-names.ts), [src/model.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/model.ts), [src/monitoring.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/monitoring.ts), [src/notifications.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/notifications.ts), [src/oauth.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/oauth.ts), [src/pages.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/pages.ts), [src/payments.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/payments.ts), [src/phone.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/phone.ts), [src/ports.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/ports.ts), [src/promise.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/promise.ts), [src/push.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/push.ts), [src/queue.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/queue.ts), [src/reactivity.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/reactivity.ts), [src/realtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/realtime.ts), [src/request.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/request.ts), [src/response.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/response.ts), [src/router.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/router.ts), [src/saas.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/saas.ts), [src/scheduler.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/scheduler.ts), [src/search-engine.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/search-engine.ts), [src/security.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/security.ts), [src/seo.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/seo.ts), [src/server.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/server.ts), [src/services.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/services.ts), [src/settings-config.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/settings-config.ts), [src/sites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/sites.ts), [src/sms.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/sms.ts), [src/socials.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/socials.ts), [src/stack-extensions.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/stack-extensions.ts), [src/stacks.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/stacks.ts), [src/storage.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/storage.ts), [src/table-names.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/table-names.ts), [src/tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/tables.ts), [src/team.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/team.ts), [src/ui.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/ui.ts), [src/utils.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/utils.ts).
906
906
 
907
- Evidence directory: [2 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
907
+ Evidence directory: [3 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
908
908
 
909
909
  ### @stacksjs/ui
910
910
 
@@ -62,7 +62,11 @@ for (const post of Post.where('published', true).get()) titles.push(post.title)
62
62
  - **How.** SQLite runs a query in place. MySQL and Postgres run on Bun's
63
63
  driver, held by a worker thread the caller waits on, so nothing else runs on
64
64
  the calling thread while a query is in flight (the cost `bun:sqlite` always
65
- had). `models: { execution: 'async' }` in `config/query-builder.ts` makes MySQL and
65
+ had). On a Bun whose drivers can wait for a statement themselves
66
+ ([stacksjs/bun](https://github.com/stacksjs/bun)) there is no worker: the
67
+ connection stays on the calling thread. The runtime is looked at when the
68
+ connection opens, the rules are the same either way, and
69
+ `models: { transport: 'worker' }` keeps the worker. `models: { execution: 'async' }` in `config/query-builder.ts` makes MySQL and
66
70
  Postgres calls promises again for an app that needs the event loop free
67
71
  during queries; every call then has to be awaited.
68
72
  - **The `db` query builder too.** `db.selectFrom(...).get()` is the rows and
@@ -320,9 +320,19 @@ expect(pageAuditClean(report)).toBe(true) // no duplicate /api/ requests, failed
320
320
  Chrome's bundle id while an update is pending; to a test that looks like a hung page. When
321
321
  `CHROME_PATH` is not set, `launch()` runs `prepareMacChrome()`: a `cp -cR` clone in the temp
322
322
  directory with the `KS*` updater keys deleted from `Info.plist`, its own `CFBundleIdentifier`,
323
- and `codesign --force --deep --sign -`, reused per Chrome version. `--use-mock-keychain` is what
323
+ and a complete ad-hoc signature, reused per Chrome version. `--use-mock-keychain` is what
324
324
  keeps that clone from hanging on an invisible "Chrome Safe Storage" Keychain prompt at its first
325
325
  http page. Measured: the installed Chrome closed at 32 s, the clone kept navigating past 60 s.
326
+ - **The clone is made once and then reused in about a tenth of a second** (stacksjs/stacks#3302).
327
+ It leaves out the framework versions the updater keeps for a browser that is still running
328
+ (each about 730 MB; only `Versions/Current` is ever loaded), and a copy that passed
329
+ `codesign --verify --deep --strict` is remembered by a digest of every file's path, size and
330
+ modification time in `Chrome.app.verified` beside it. Unchanged, it is not read again; changed
331
+ in any of those, it is verified in full, and an invalid one gets a replacement generation
332
+ while the old bundle is kept. Before this, strict verification ran before every reuse: 19 to
333
+ 28 s with two updates pending, which a test that gives its page 30 s never survived. The first
334
+ browser test after a Chrome update still pays for the copy, about 15 to 30 s once; if that
335
+ test's own deadline is shorter, it fails once and the next browser test finishes the copy.
326
336
  - The package's own real-Chrome tests (`core/testing/tests/browser.test.ts`) run wherever a Chrome
327
337
  is found, except in CI unless `STACKS_BROWSER_TESTS=1`; `STACKS_BROWSER_TESTS=0` skips them locally.
328
338
 
@@ -89,7 +89,7 @@ export default new Action({
89
89
  .updateTable('comments')
90
90
  .set({
91
91
  status,
92
- is_approved: status === 'approved' ? 1 : 0,
92
+ is_approved: status === 'approved',
93
93
  updated_at: timestamp(),
94
94
  } as any)
95
95
  .where('id', '=', id)
@@ -44,7 +44,7 @@ export default new Action({
44
44
  poster: payload.poster,
45
45
  status: payload.status,
46
46
  author_id: payload.authorId,
47
- is_featured: payload.featured ? 1 : 0,
47
+ is_featured: Boolean(payload.featured),
48
48
  views: 0,
49
49
  published_at: publishedAtFor(payload.status, null, now),
50
50
  created_at: now,