@floless/app 0.134.1 → 0.134.2

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.
@@ -0,0 +1,120 @@
1
+ /*
2
+ * connection-review-client.js — the client's review watermark: how one observation of the review state
3
+ * is ordered against the one already on screen, and when a refresh cycle is allowed to stop.
4
+ *
5
+ * WHY THIS IS A MODULE AND NOT INLINE IN steel-editor.html
6
+ * Because it is the part that was got wrong repeatedly, and inline code in that file cannot be unit
7
+ * tested. Five successive drafts of this rule shipped a hole during plan review, every one of them the
8
+ * same shape: someone enumerated the cases they could picture and a real one fell through. Pulling the
9
+ * decision out as a pure function makes the totality of it assertable, which is the only thing that
10
+ * actually stops the sixth hole.
11
+ *
12
+ * THE STATE BEING ORDERED IS A PAIR, NOT A COUNTER
13
+ * `reviewRevision` alone cannot order a summary. It moves only when the sidecar rows change
14
+ * (server/connection-review-transition.ts), while the summary is derived from live geometry — so an
15
+ * ordinary member move changes what the summary SAYS without moving the revision at all. Two different
16
+ * summaries can both be revision R. The identity of an observation is therefore the pair
17
+ * (storeRevision, reviewRevision), and ordering is a partial order over that pair, not a comparison.
18
+ */
19
+
20
+ /**
21
+ * One observation's identity. Both axes, always — see the header for why the revision alone cannot order.
22
+ * @typedef {{ storeRevision: number, reviewRevision: number }} ReviewAt
23
+ * @typedef {'equal' | 'advancing' | 'dominated' | 'incomparable'} ReviewShape
24
+ * @typedef {{ state: 'pending' | 'normal' | 'unavailable', retry: boolean, nextCycleBounds: ReviewAt | null }} CycleOutcome
25
+ */
26
+
27
+ /** The server's "could not derive this at all" sentinel. Never an ordinary generation. */
28
+ export const REVIEW_UNAVAILABLE_REVISION = -1;
29
+
30
+ /**
31
+ * How many fetches one dirty cycle may spend before it must conclude something.
32
+ *
33
+ * TWO, and the exact number matters less than the fact that there IS one. An earlier design said "keep
34
+ * trailing until the bounds are satisfied", which is only as terminal as the last enumeration of ways
35
+ * bounds can fail to be satisfied — and three review rounds each found a new one (a retained watermark
36
+ * under the -1 sentinel, a dominated pair after a lost sidecar, an equal pair below a raised bound).
37
+ * A counter is terminal by construction and does not care which of those it is looking at.
38
+ */
39
+ export const REVIEW_MAX_ATTEMPTS = 2;
40
+
41
+ /**
42
+ * True only for the derivation-failure sentinel. Revision 0 is a REAL generation — an empty sidecar.
43
+ * @param {number} reviewRevision
44
+ * @returns {boolean}
45
+ */
46
+ export function isUnavailableRevision(reviewRevision) {
47
+ return reviewRevision === REVIEW_UNAVAILABLE_REVISION;
48
+ }
49
+
50
+ const sign = (n) => (n < 0 ? -1 : n > 0 ? 1 : 0);
51
+
52
+ /**
53
+ * Classify an incoming pair against the one currently held. TOTAL over both axes.
54
+ *
55
+ * The nine (ds, dr) sign combinations partition completely into four shapes, so there is no fifth to
56
+ * discover later:
57
+ *
58
+ * equal (0,0) the same observation — common, because a quiet reconnect returns it
59
+ * advancing neither negative, at least one positive
60
+ * dominated neither positive, at least one negative (ONE OR BOTH axes lower)
61
+ * incomparable (+,-) and (-,+) one axis forward, the other back
62
+ *
63
+ * `dominated` is not hypothetical and is not announced by the -1 sentinel: readReviewFile answers an
64
+ * absent, unreadable or invalid sidecar with a VALID empty generation at revision 0 rather than throwing,
65
+ * so a client holding (S,R5) that loses its sidecar simply starts seeing (S,R0).
66
+ *
67
+ * @param {ReviewAt} incoming
68
+ * @param {ReviewAt} held
69
+ * @returns {ReviewShape}
70
+ */
71
+ export function classifyReviewPair(incoming, held) {
72
+ const ds = sign(incoming.storeRevision - held.storeRevision);
73
+ const dr = sign(incoming.reviewRevision - held.reviewRevision);
74
+ if (ds === 0 && dr === 0) return 'equal';
75
+ if (ds >= 0 && dr >= 0) return 'advancing';
76
+ if (ds <= 0 && dr <= 0) return 'dominated';
77
+ return 'incomparable';
78
+ }
79
+
80
+ /**
81
+ * Does `pair` reach the lower bounds a cycle captured? Both axes, or it has not caught up.
82
+ * @param {ReviewAt} pair
83
+ * @param {ReviewAt} bounds
84
+ * @returns {boolean}
85
+ */
86
+ export function satisfiesBounds(pair, bounds) {
87
+ return pair.storeRevision >= bounds.storeRevision && pair.reviewRevision >= bounds.reviewRevision;
88
+ }
89
+
90
+ /**
91
+ * Decide what a refresh cycle does next: retry, or conclude — and if it concludes, whether the surface
92
+ * it leaves behind is trustworthy.
93
+ *
94
+ * TWO PROPERTIES, TWO MECHANISMS, DELIBERATELY SEPARATE. Termination comes from `attempts` reaching
95
+ * REVIEW_MAX_ATTEMPTS. Not-losing-an-update comes from `arrivedAfterFinalAttempt` being handed to a
96
+ * fresh cycle instead of being cleared with this one. Every earlier draft loaded both properties onto a
97
+ * single rule and failed at one of them: first the satisfaction check (terminated only if the failure
98
+ * enumeration happened to be complete), then a bare counter (always terminated, but could silently drop
99
+ * a sign-off committed in another tab).
100
+ *
101
+ * The bounds check on settlement is what stops the second failure being invisible. A cycle that advanced
102
+ * a little but never reached its bounds has NOT caught up, and rendering its number as if it had is worse
103
+ * than admitting ignorance: nothing on screen would mark it stale, and no further trigger is guaranteed.
104
+ *
105
+ * @param {{ installed: ReviewAt, bounds: ReviewAt, attempts: number, arrivedAfterFinalAttempt?: ReviewAt | null }} input
106
+ * @returns {CycleOutcome}
107
+ */
108
+ export function settleCycle({ installed, bounds, attempts, arrivedAfterFinalAttempt = null }) {
109
+ if (attempts < REVIEW_MAX_ATTEMPTS && !satisfiesBounds(installed, bounds)) {
110
+ return { state: 'pending', retry: true, nextCycleBounds: null };
111
+ }
112
+ // A trigger that landed after the last attempt was already reading belongs to nobody yet. It must
113
+ // start its own cycle: this one cannot go back and look again, and clearing it would lose the event.
114
+ const nextCycleBounds = arrivedAfterFinalAttempt || null;
115
+ return {
116
+ state: satisfiesBounds(installed, bounds) ? 'normal' : 'unavailable',
117
+ retry: false,
118
+ nextCycleBounds,
119
+ };
120
+ }
@@ -574,7 +574,12 @@
574
574
  <span class="menu-label" data-tip="Starts the FloLess server automatically when you sign in, so your browser reconnects on its own">Start on startup</span>
575
575
  <!-- The id sits on the label, not the checkbox it wraps: accessibleNameOf() reads the element
576
576
  the id is on, and the label is what carries the name here. Same shape as the 3D view
577
- toggles in the steel editor and the Drawing Filter's match-on rows (#779). -->
577
+ toggles in the steel editor (#779).
578
+ NOT the Drawing Filter's match-on rows any more: #805 Phase D moved those onto their
579
+ inputs, because Instructor's activate() focuses the carrier it finds and a <label> cannot
580
+ take focus, so pressing Enter from the ? sheet could never reach the control. This one is
581
+ unchanged only because that slice had no business editing this surface; the same move is
582
+ available here whenever someone owns it. -->
578
583
  <label class="rtn-toggle" data-command-id="shell.open-at-startup" aria-label="Start FloLess on startup">
579
584
  <input type="checkbox" id="startup-toggle" role="switch">
580
585
  <span class="rtn-toggle-track"></span>
@@ -91,8 +91,11 @@
91
91
  }
92
92
 
93
93
  // Appended once here rather than repeated on every registration: how you get
94
- // out of an armed command is the producer's business, not each command's.
95
- parts.push('Esc to cancel');
94
+ // out of an armed command is the producer's business. A command whose Esc does
95
+ // something OTHER than cancel (it commits, say) overrides the wording with
96
+ // `escLabel` — the route is still appended here, only its name comes from the
97
+ // registry.
98
+ parts.push(meta.escLabel || 'Esc to cancel');
96
99
 
97
100
  return { tone: 'armed', chip: chip, parts: parts, ask: meta.label, commandId: id, surface: child.surface || 'shell' };
98
101
  }
@@ -586,6 +589,7 @@
586
589
  'In the 3D toolbar', 'In the 3D side panel', 'On the snap bar',
587
590
  'In the grid panel', 'In the Inspect panel',
588
591
  'In the Properties popup', 'In the snap override menu', 'In the dimension value popup', 'In the selection filter',
592
+ 'In the review list', // the connection-review popover — a sibling of the selection filter, and it hangs off the header stats above
589
593
  'In the ⋯ menu',
590
594
  'In the ⋯ menu — Snapping', 'In the ⋯ menu — Display', 'In the ⋯ menu — Detailing',
591
595
  'In the ⋯ menu — Model checks', 'In the ⋯ menu — Coordinate system', 'In the ⋯ menu — Session',
@@ -595,7 +599,7 @@
595
599
  // the drawing filter
596
600
  'In the Drawing Filter header', 'In a Drawing Filter message',
597
601
  'In the Drawing Filter panel', 'On the Drawing Filter canvas',
598
- 'In the Drawing Filter layer approval',
602
+ 'In the Drawing Filter exclusion approval',
599
603
  // the vector editor, and its 3D viewer
600
604
  'In the Trace header', 'In the Trace panel', 'On the Trace canvas',
601
605
  'In the Trace — 3D header', 'On the Trace — 3D view',
@@ -804,10 +808,20 @@
804
808
  /* FALLS THROUGH when the control cannot be described, rather than returning.
805
809
  focusFor() resolves upward through
806
810
  `closest('button, [role="button"], [role="treeitem"], a[href], input, select, textarea')`, and
807
- three registered commands carry their id on a <label> whose <input> is a
808
- DESCENDANT — filter.match-on and vector.show-kind — so the walk finds
809
- nothing and it returns null. (That shape is deliberate: the id sits on the
810
- label because that is what a screen reader names the control from.)
811
+ a registered command can carry its id on a <label> whose <input> is a
812
+ DESCENDANT, and SEVEN carriers across four templates still do:
813
+ shell.open-at-startup and shell.routine-enabled (index.html),
814
+ steel.show-labels and steel.work-plane-show (steel-editor.html),
815
+ vector.show-kind and vector.isolate-weak (vector-editor.html). For every one
816
+ of them `live.focus()` above quietly does nothing — a <label> is not
817
+ focusable — so this fall-through is the ONLY outcome those commands can
818
+ reach, and `?` describes them instead of going to them.
819
+ #805 Phase D moved the two steel-filter ones (filter.match-on,
820
+ filter.facet-toggle) off that shape and left the rest alone: they are other
821
+ surfaces, and moving them is not that slice's to do. Putting the id on the
822
+ input costs no accessible name — `accessibleNameOf` names a form control
823
+ from its wrapping label — and it is what makes Enter here actually go to the
824
+ control. The remaining seven are a known, recorded gap, not a design.
811
825
 
812
826
  Returning here on a null entry would have left the PREVIOUS entry standing,
813
827
  since setFocusEntry declines rather than assigning — reintroducing exactly
@@ -1812,29 +1812,123 @@ export function requiredDepthPin(member, before, after) {
1812
1812
  }
1813
1813
 
1814
1814
  /**
1815
- * A rigid slide of BOTH work points along the member's own axis: the reference line keeps its direction
1816
- * and its length, and simply moves along itself.
1815
+ * A rigid translation of BOTH work points along a unit `axis` by `deltaMm`: the reference line keeps its
1816
+ * direction and its length and simply moves. This is the shared primitive behind all three translate
1817
+ * handles — the member-axis slide (`axis = xAxis`) and, since the gizmo redesign, the depth and width
1818
+ * arrows, which move the LINE sideways rather than sliding the profile off it.
1817
1819
  *
1818
1820
  * It is NOT frame-preserving to the bit — the caller quantises each endpoint independently, which perturbs
1819
1821
  * the direction by ~1e-9 — so a commit must assert that `partFrame`'s BRANCH is stable, never that the
1820
1822
  * frame is unchanged. Near the degeneracy cone that perturbation can move a member OUT of the seeded
1821
1823
  * branch as easily as into it, and leaving the cone rebuilds a different section frame than the rigid
1822
- * preview showed.
1824
+ * preview showed. That is why `commitMemberEndpoints` gives every translate gesture the same
1825
+ * branch-stability policy, not just the axial one.
1823
1826
  *
1824
1827
  * @returns {{from:number[], to:number[]}|null} null on a non-finite input or a zero-length axis.
1825
1828
  */
1826
- export function slideEndpoints(from0, to0, xAxis, deltaMm) {
1827
- if (!finiteVec3(from0) || !finiteVec3(to0) || !finiteVec3(xAxis)) return null;
1829
+ export function translateEndpoints(from0, to0, axis, deltaMm) {
1830
+ if (!finiteVec3(from0) || !finiteVec3(to0) || !finiteVec3(axis)) return null;
1828
1831
  if (typeof deltaMm !== 'number' || !isFinite(deltaMm)) return null;
1829
- const l = len3(xAxis);
1832
+ const l = len3(axis);
1830
1833
  if (!(l > 0)) return null;
1831
- const d = [(xAxis[0] / l) * deltaMm, (xAxis[1] / l) * deltaMm, (xAxis[2] / l) * deltaMm];
1834
+ const d = [(axis[0] / l) * deltaMm, (axis[1] / l) * deltaMm, (axis[2] / l) * deltaMm];
1832
1835
  return {
1833
1836
  from: [from0[0] + d[0], from0[1] + d[1], from0[2] + d[2]],
1834
1837
  to: [to0[0] + d[0], to0[1] + d[1], to0[2] + d[2]],
1835
1838
  };
1836
1839
  }
1837
1840
 
1841
+ /**
1842
+ * The member-axis special case of `translateEndpoints`, kept as its own name because "slide" is the
1843
+ * gesture the tooltip, the readout and the commit's `gesture` field all say.
1844
+ */
1845
+ export function slideEndpoints(from0, to0, xAxis, deltaMm) {
1846
+ return translateEndpoints(from0, to0, xAxis, deltaMm);
1847
+ }
1848
+
1849
+ /**
1850
+ * A gesture that moves the reference line rigidly, so `partFrame`'s BRANCH must merely be KEPT rather
1851
+ * than required to be non-degenerate. Both translate gestures qualify — a translation changes neither the
1852
+ * member's direction nor its length, so a plumb column stays exactly as plumb as it started — while a
1853
+ * swing re-aims the member and must land on the ordinary branch. One predicate, so the editor's commit
1854
+ * policy and the tests can never spell the set two different ways.
1855
+ */
1856
+ export function directionPreservingGesture(gesture) {
1857
+ return gesture === 'slide' || gesture === 'translate';
1858
+ }
1859
+
1860
+ /**
1861
+ * The three handles that move the reference line WITHOUT re-aiming it: the member-axis slide and, since
1862
+ * the redesign, the depth and width arrows. `directionPreservingGesture` names the same property for the
1863
+ * COMMIT (`spec.gesture` is what reaches `commitMemberEndpoints`, and there a lateral move is spelled
1864
+ * 'translate'); this one names it for the DRAG, where the handle is still called by its own axis.
1865
+ */
1866
+ export function isTranslateGesture(gesture) {
1867
+ return gesture === 'depth' || gesture === 'width' || directionPreservingGesture(gesture);
1868
+ }
1869
+
1870
+ /**
1871
+ * The member's PROFILE axes: the part frame's width/depth turned by the authored roll about the member
1872
+ * axis. `rot` is measured +y toward +z (the same sense `positionSwingDelta` and the mesh preview use), so
1873
+ *
1874
+ * yRolled = y·cos r + z·sin r zRolled = −y·sin r + z·cos r
1875
+ *
1876
+ * The gizmo draws depth/width/roll on THESE, and the member-axis arrow plus both swing arcs on the
1877
+ * UNROLLED frame — because an elevation swing about a rolled y is not a tilt. Two frames, each carrying
1878
+ * the handles that are actually defined in it.
1879
+ */
1880
+ export function rolledProfileAxes(frame, rotDeg) {
1881
+ if (!frame || !finiteVec3(frame.y) || !finiteVec3(frame.z)) return null;
1882
+ const th = ((typeof rotDeg === 'number' && isFinite(rotDeg) ? rotDeg : 0) * Math.PI) / 180;
1883
+ const c = Math.cos(th), s = Math.sin(th);
1884
+ return {
1885
+ y: [frame.y[0] * c + frame.z[0] * s, frame.y[1] * c + frame.z[1] * s, frame.y[2] * c + frame.z[2] * s],
1886
+ z: [-frame.y[0] * s + frame.z[0] * c, -frame.y[1] * s + frame.z[1] * c, -frame.y[2] * s + frame.z[2] * c],
1887
+ };
1888
+ }
1889
+
1890
+ /**
1891
+ * The gizmo state as it stands PART-WAY THROUGH a gesture — the whole of "the gizmo tracks the member
1892
+ * while you drag it", in one pure function so it can be pinned in node rather than only in a browser.
1893
+ *
1894
+ * Before this existed neither drag handler touched the gizmo group at all: the handles re-anchored only
1895
+ * after the commit rebuilt the scene, so every gesture visibly left its own manipulator behind.
1896
+ *
1897
+ * translate (`depth` / `width` / `slide`) both work points move by `axis·value`; the axes are unchanged.
1898
+ * `rot` only the authored roll changes; the reference line does not move.
1899
+ * swings the far point and the whole part frame turn by `R(axis, value)`
1900
+ * about the anchor. `up` does NOT turn: it belongs to the
1901
+ * authoring basis, not to the member, so a tilt must not swing
1902
+ * the plan-swing arc's plane with it.
1903
+ *
1904
+ * @param {object} st the DRAG-START gizmo state (`memberPositionGizmoState`)
1905
+ * @param {string} gesture 'depth' | 'width' | 'slide' | 'rot' | 'swingPlan' | 'swingElev'
1906
+ * @param {number} value mm for a translate, degrees for `rot`, radians for a swing
1907
+ * @param {number[]} [axis] the translate axis / swing axis, when it is not derivable from `st` alone
1908
+ * @returns {object|null} a new state (never a mutation of `st`), or null when the input cannot be used
1909
+ */
1910
+ export function livePositionState(st, gesture, value, axis) {
1911
+ if (!st || !finiteVec3(st.anchor) || !finiteVec3(st.end)) return null;
1912
+ if (typeof value !== 'number' || !isFinite(value)) return null;
1913
+ // A roll turns the PROFILE frame and nothing else: the reference line is exactly where it was, which is
1914
+ // the whole point of rolling about it. `profile` is recomputed from the UNROLLED part axes, never
1915
+ // composed onto the previous profile, so a drag that sweeps back to zero lands back on the part frame.
1916
+ if (gesture === 'rot') return { ...st, rot: value, profile: rolledProfileAxes({ y: st.yAxis, z: st.zAxis }, value) };
1917
+ if (isTranslateGesture(gesture)) {
1918
+ const t = translateEndpoints(st.anchor, st.end, axis, value);
1919
+ return t ? { ...st, anchor: t.from, end: t.to } : null;
1920
+ }
1921
+ if (gesture !== 'swingPlan' && gesture !== 'swingElev') return null;
1922
+ const end = swingEndpoint(st.anchor, st.end, axis, value);
1923
+ if (!end) return null;
1924
+ const turn = (v) => (finiteVec3(v) ? swingEndpoint([0, 0, 0], v, axis, value) : v);
1925
+ const profile = st.profile && finiteVec3(st.profile.y) && finiteVec3(st.profile.z)
1926
+ ? { y: turn(st.profile.y), z: turn(st.profile.z) } : st.profile;
1927
+ // `up` is deliberately NOT turned — see the doc comment.
1928
+ return { ...st, end, xAxis: turn(st.xAxis), yAxis: turn(st.yAxis), zAxis: turn(st.zAxis), profile };
1929
+ }
1930
+
1931
+
1838
1932
  /**
1839
1933
  * The right-handed in-plane basis a swing measures its angle in: `e1` is the drag-start radius with the
1840
1934
  * rotation axis projected out, `e2 = axis x e1`, so `e1 x e2 = axis`. Measuring `atan2(d.e2, d.e1)` in THIS