@floless/app 0.108.1 → 0.109.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +253 -203
- package/dist/web/app.css +36 -1
- package/dist/web/app.js +6 -1
- package/dist/web/aware.js +6 -0
- package/dist/web/steel-detail-refs.js +69 -0
- package/dist/web/steel-editor.html +6 -3
- package/dist/web/workspaces.js +155 -1
- package/package.json +1 -1
package/dist/web/app.css
CHANGED
|
@@ -3574,8 +3574,43 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
|
|
|
3574
3574
|
.ws-card .ws-kind { position:absolute; top:8px; left:8px; font-size:9px; text-transform:uppercase; letter-spacing:.1em;
|
|
3575
3575
|
color:var(--accent-bright); background:var(--surface); border:1px solid var(--accent-dim); padding:2px 7px; border-radius:4px; }
|
|
3576
3576
|
.ws-card .ws-body { padding:11px 13px 13px; display:flex; align-items:flex-start; justify-content:space-between; gap:8px; }
|
|
3577
|
-
|
|
3577
|
+
/* The project NAME is user-supplied and unbounded, and CSS Grid stretches every card in a row to the
|
|
3578
|
+
tallest — so one long name reflows the whole grid. Measured: a 69-character name wrapped to two
|
|
3579
|
+
lines and pushed all four cards in its row from 175px to 195px, while the row below stayed at 175px.
|
|
3580
|
+
(The "type · workflow · time" line below is already immune — see .ws-meta-app.)
|
|
3581
|
+
TWO lines, not one. The name is the card's primary identifier, and the discriminating part of a real
|
|
3582
|
+
project name is usually its TAIL — "…revision A" vs "…revision final" — which one line throws away.
|
|
3583
|
+
Measured on a 275px card (a 212px name box): a mixed-case name fits about 36 characters per line, so
|
|
3584
|
+
two lines carry ~72 against ~36 — and they absorbed the 69-character repro name in full, with no
|
|
3585
|
+
ellipsis at all. All-caps is the worst case at ~25 per line, and the grid's narrowest card (the 240px
|
|
3586
|
+
minmax floor) still holds ~30.
|
|
3587
|
+
CAPPED, deliberately NOT reserved. A min-height of exactly two lines was built first and rejected on
|
|
3588
|
+
the rendered result: it makes every card equal height, but the empty reserved line lands BETWEEN the
|
|
3589
|
+
name and the capability line — a gap in the middle of the card's most-scanned content — and it lands
|
|
3590
|
+
there on the common case, since most names are one line (6 of the 8 cards in the test workspace).
|
|
3591
|
+
That leaves the one long-named card looking tighter than all the ordinary ones, inverting the
|
|
3592
|
+
hierarchy. The bug here is a long name propagating its height onto UNRELATED cards without bound;
|
|
3593
|
+
grid's default align-items:stretch equalising the cards within one row is normal card-grid behaviour
|
|
3594
|
+
and is what the clamp now bounds to a fixed +20px. Rows no longer have to match each other.
|
|
3595
|
+
align-items:start was considered too and rejected: it is right for .lib-list, where a collapsed card
|
|
3596
|
+
next to an expanded one is a designed state, but this is a project dashboard where same-row cards are
|
|
3597
|
+
expected to share a bottom edge — ragged bottoms would read as more broken, not less.
|
|
3598
|
+
overflow-wrap:anywhere because a name need not contain spaces — a single long token would otherwise
|
|
3599
|
+
overflow the clamp sideways instead of wrapping into it.
|
|
3600
|
+
Where the clamp actually hides something, renderLanding() attaches the full name as a data-tip; it
|
|
3601
|
+
measures rather than guesses, so a short name never gets a tooltip that just repeats it. A truly
|
|
3602
|
+
clipped tail is not laid out and so cannot be drag-selected off the card — the copy path is ⋯ →
|
|
3603
|
+
Rename…, whose prompt prefills the full current name in a selectable input. */
|
|
3604
|
+
.ws-card .ws-name { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2;
|
|
3605
|
+
overflow:hidden; overflow-wrap:anywhere; line-height:1.5;
|
|
3606
|
+
font-size:13px; font-weight:600; color:var(--text); }
|
|
3607
|
+
/* The capability line, held to one line for the same reason. :not(.ws-meta-app) because the meta line
|
|
3608
|
+
below shares this class and owns its own, richer priority rules — see .ws-meta-app. Today it is a
|
|
3609
|
+
short constant from WORKSPACE_APPS, a first-party map we control, so this rule bites nothing yet; it
|
|
3610
|
+
is here for when that map is promoted to a .flo-declared descriptor (workspaces.js says that is the
|
|
3611
|
+
plan once a user-authored workspace app appears), at which point the string stops being ours. */
|
|
3578
3612
|
.ws-card .ws-meta { display:block; font-size:11px; color:var(--text-muted); margin-top:4px; }
|
|
3613
|
+
.ws-card .ws-meta:not(.ws-meta-app) { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
|
3579
3614
|
.ws-card .ws-meta .t { font-family:var(--mono); font-size:10px; color:var(--text-dim); }
|
|
3580
3615
|
/* The "type · workflow · time" line.
|
|
3581
3616
|
*
|
package/dist/web/app.js
CHANGED
|
@@ -1625,7 +1625,12 @@ document.addEventListener('keydown', (e) => {
|
|
|
1625
1625
|
|
|
1626
1626
|
document.addEventListener('mouseover', (e) => {
|
|
1627
1627
|
const el = e.target.closest('[data-tip]');
|
|
1628
|
-
|
|
1628
|
+
// Ignore moves that stay within the SAME anchor. Comparing against the live anchor, rather than
|
|
1629
|
+
// asking whether el contains relatedTarget, is what makes a NESTED tip work: leaving a tipped child
|
|
1630
|
+
// (a project card's ⋯, a favourite chip's ×) back onto its tipped parent resolves a DIFFERENT
|
|
1631
|
+
// anchor, and the containment test swallowed that — the parent's tip could then not be shown again
|
|
1632
|
+
// without leaving the parent entirely and coming back.
|
|
1633
|
+
if (!el || el === anchor) return;
|
|
1629
1634
|
show(el);
|
|
1630
1635
|
});
|
|
1631
1636
|
document.addEventListener('mouseout', (e) => {
|
package/dist/web/aware.js
CHANGED
|
@@ -5474,6 +5474,12 @@
|
|
|
5474
5474
|
} else if (m.type === 'apps-changed') {
|
|
5475
5475
|
// A workflow was imported (here or in another tab) → refresh the picker (#66).
|
|
5476
5476
|
loadApps().catch(() => {});
|
|
5477
|
+
// Relayed as a DOM event for the same reason render-progress is: workspaces.js owns the
|
|
5478
|
+
// Workspaces landing, is the only listener, and caches the workflow names + create-card
|
|
5479
|
+
// targets this event invalidates (#389). A relay rather than a wider bridge. No try/catch
|
|
5480
|
+
// around it: dispatchEvent contains a throwing listener itself (it reports the exception
|
|
5481
|
+
// globally and carries on), so this loop is already safe and a guard here would be dead code.
|
|
5482
|
+
window.dispatchEvent(new CustomEvent('floless:apps-changed', { detail: m }));
|
|
5477
5483
|
} else if (m.type === 'baked' && m.id === currentId) {
|
|
5478
5484
|
// Baked (here or in another tab) → refresh so the menu item flips to "Re-bake".
|
|
5479
5485
|
loadApp(currentId).catch(() => {});
|
|
@@ -102,6 +102,75 @@ export function planDetailRefs(plan) {
|
|
|
102
102
|
return out;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Callout kinds that are NOT details for scoring purposes.
|
|
107
|
+
*
|
|
108
|
+
* A section or an elevation is a more GENERAL drawing than a detail — it is a cut or a face of the
|
|
109
|
+
* structure, and it typically carries detail callouts of its own rather than being one. So the
|
|
110
|
+
* confidence report should not score it as a detail. (Product call, 2026-07-24, answering the question
|
|
111
|
+
* #401 was opened to ask.)
|
|
112
|
+
*
|
|
113
|
+
* Denying these two is the exact complement of `detail-ref`: the schema's callout enum is
|
|
114
|
+
* section | elevation | detail-ref and nothing else, and every writeback goes through validateContract,
|
|
115
|
+
* so no third general kind can reach here in a document that validates.
|
|
116
|
+
*
|
|
117
|
+
* It is nonetheless a DENY list rather than an allow list of `detail-ref`, because `callouts[]` is not
|
|
118
|
+
* the only input. The schema requires `kind` on a CALLOUT, but a `details[]` entry is a bare `{text}`
|
|
119
|
+
* with no kind at all — that is every detail written before callouts existed. Allow-listing would
|
|
120
|
+
* score ZERO of them and silently empty the report for models that score fine today. An entry that
|
|
121
|
+
* does not say it is a section is treated as a detail: the safe direction, since the failure it risks
|
|
122
|
+
* is one row too many rather than a whole model's worth missing.
|
|
123
|
+
*/
|
|
124
|
+
export const NON_DETAIL_KINDS = ['section', 'elevation'];
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The callouts on this plan that COUNT AS DETAILS for confidence scoring — the same `details[]` +
|
|
128
|
+
* `callouts[]` union every other surface reads since #397, minus NON_DETAIL_KINDS.
|
|
129
|
+
*
|
|
130
|
+
* Not deduplicated and not sorted, unlike planDetailTexts: the scorer emits one row per callout, and
|
|
131
|
+
* the same detail referenced twice on a sheet is two things to resolve, not one. Entries with no
|
|
132
|
+
* resolvable name are KEPT with an empty text — the scorer bands those `low` with "no sheet reference
|
|
133
|
+
* parsed", which is a real finding about the drawing, not a row to hide.
|
|
134
|
+
*
|
|
135
|
+
* Both scorers read this one function — server/steel-confidence.ts (the authority) and the editor's own
|
|
136
|
+
* scoreContractJS — so THIS rule cannot drift between them. The banding either side of it is still two
|
|
137
|
+
* hand-mirrored copies; what pins the editor's is the pair of #401 tests in steel-editor-draft.test.ts,
|
|
138
|
+
* which boot the real page and assert its detail row count. See the note above the loop in
|
|
139
|
+
* steel-confidence.ts for exactly what that does and does not cover.
|
|
140
|
+
*/
|
|
141
|
+
export function planScoredDetails(plan) {
|
|
142
|
+
const skip = new Set(NON_DETAIL_KINDS);
|
|
143
|
+
const seen = new Set(), out = [];
|
|
144
|
+
for (const entry of entries(plan)) {
|
|
145
|
+
if (!entry || typeof entry !== 'object') continue;
|
|
146
|
+
if (skip.has(text(entry.kind).toLowerCase())) continue;
|
|
147
|
+
const name = calloutRefText(entry) || '';
|
|
148
|
+
// The sheet the callout STRUCTURALLY points at, carried alongside the printed mark. The scorer
|
|
149
|
+
// parses the mark first, but a mark need not contain its sheet — the schema documents "A" and
|
|
150
|
+
// "A-A" as legal text and makes `target` required — and on those the parse yields nothing while
|
|
151
|
+
// the navigation bubble, which reads target.sheet, jumps to the right sheet regardless. Without
|
|
152
|
+
// this the two surfaces disagree: one resolves the reference, the other calls it unparseable.
|
|
153
|
+
const t = entry.target;
|
|
154
|
+
const targetSheet = (t && typeof t === 'object' && text(t.sheet)) || '';
|
|
155
|
+
// One row per distinct REFERENCE, not per bubble. The band asks only whether the referenced sheet
|
|
156
|
+
// is in the set, which is a property of the reference — so the same detail called out five times on
|
|
157
|
+
// a sheet (the demo model does exactly this: 42 bubbles naming 21 distinct references, one of them
|
|
158
|
+
// five times) is ONE thing to resolve, repeated. Left un-deduplicated it padded the Details
|
|
159
|
+
// worklist with byte-identical rows and let a single dangling reference count five times against
|
|
160
|
+
// the category. planDetailRefs is right NOT to dedupe — it draws a hot-zone per physical bubble —
|
|
161
|
+
// but that is the placement question, not the resolution question this scorer asks.
|
|
162
|
+
// Keyed on mark AND target sheet, because two sheets can both print "7". Deduplication is PER PLAN,
|
|
163
|
+
// which is the scope this function has: the same detail referenced from two different plans stays
|
|
164
|
+
// two rows, and each row names its own plan's sheet, so the worklist still says where to look. On
|
|
165
|
+
// the demo model that takes 42 bubbles to 32 rows over three plans, for 21 distinct references.
|
|
166
|
+
const key = name + '' + targetSheet;
|
|
167
|
+
if (seen.has(key)) continue;
|
|
168
|
+
seen.add(key);
|
|
169
|
+
out.push({ text: name, targetSheet: targetSheet || null, kind: text(entry.kind) || 'detail' });
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
|
|
105
174
|
/**
|
|
106
175
|
* Every detail this plan can bind to, unique and sorted — the plan's own callouts plus the model's
|
|
107
176
|
* custom details. Numeric-aware ordering, so detail 2 sorts before detail 10 the way a detailer reads
|
|
@@ -7582,9 +7582,12 @@ function scoreContractJS(){const plans=C.plans||[];const byMember=[],byDetail=[]
|
|
|
7582
7582
|
const known=new Set();for(const p of plans)if(p.sheet)known.add(p.sheet.toUpperCase());for(const s of Object.keys(C.detail_bubbles||{}))known.add(s.toUpperCase());
|
|
7583
7583
|
plans.forEach((plan,pi)=>{segs+=(plan.segments||[]).length;const ms=plan.members||[];const dup=_confDupIds(ms);
|
|
7584
7584
|
for(const m of ms){const r=_scoreMember(m,dup);byMember.push({id:m.id,planIdx:pi,sheet:plan.sheet||'',role:m.role==='column'?'column':'beam',isBrace:isBrace(m)||undefined,profile:m.profile||'',band:r.band,tons:r.band==='rfi'?0:_mTons(m,plan.pt_per_ft,plan.default_tos),factors:r.factors});} // isBrace mirrors the server MemberScore so the report can label it Brace
|
|
7585
|
-
//
|
|
7586
|
-
//
|
|
7587
|
-
|
|
7585
|
+
// The details[]+callouts[] union minus sections/elevations (#401). Both scorers call the SAME helper
|
|
7586
|
+
// in steel-detail-refs.js rather than each spelling the rule out, because a rule written twice is a
|
|
7587
|
+
// rule that drifts. The banding below still mirrors steel-confidence.ts BY HAND; what keeps this call
|
|
7588
|
+
// site honest is the pair of #401 tests in steel-editor-draft.test.ts, which boot the real page and
|
|
7589
|
+
// assert the row count this produces. See the note at its matching loop for what is still unpinned.
|
|
7590
|
+
for(const d of DetailRefs.planScoredDetails(plan)){const sh=_detSheet(d.text)??d.targetSheet;const ok=sh!=null&&known.has(sh.toUpperCase());byDetail.push({text:d.text,planIdx:pi,sheet:plan.sheet||'',band:ok?'high':'low',reason:ok?('references '+sh+' (in the set)'):sh?('references '+sh+' — not found in the set'):'no sheet reference parsed'});}});
|
|
7588
7591
|
const roll=(arr,cw)=>{const c=_cnt0();let n=0,d=0,t=0;for(const m of arr){c[m.band]++;if(m.band==='rfi')continue;const w=cw?1:m.tons;n+=w*BANDW[m.band];d+=w;t+=m.tons;}return {score:d>0?Math.round(n/d*100):null,tons:t,counts:c};};
|
|
7589
7592
|
const dRoll=arr=>{const c=_cnt0();let n=0,d=0;for(const x of arr){c[x.band]++;n+=BANDW[x.band];d++;}return {score:d>0?Math.round(n/d*100):null,tons:0,counts:c};};
|
|
7590
7593
|
const beams=roll(byMember.filter(m=>m.role==='beam'));const columns=roll(byMember.filter(m=>m.role==='column'));const details=dRoll(byDetail);
|
package/dist/web/workspaces.js
CHANGED
|
@@ -133,7 +133,26 @@
|
|
|
133
133
|
|
|
134
134
|
// The picker menu is a `.menu` (display:none by default; `.menu.show` → display:block, which
|
|
135
135
|
// OVERRIDES the `hidden` attribute). So close must clear BOTH — same idiom as the ext-menu.
|
|
136
|
-
|
|
136
|
+
// Hand focus back to the kebab BEFORE hiding, when the menu is what currently holds it. Clicking a
|
|
137
|
+
// menu item focuses that item (browsers focus a <button> on click), and the very next thing several
|
|
138
|
+
// items do is open a formModal, which on close returns focus to whatever was focused when it opened
|
|
139
|
+
// — by then a detached node, since hiding the menu and repainting the grid both drop it. Handing
|
|
140
|
+
// focus to the kebab first gives that return a live target instead of <body>, which has no
|
|
141
|
+
// accessible name and reads to a screen reader as nowhere.
|
|
142
|
+
//
|
|
143
|
+
// Note this does NOT make the menu keyboard-accessible: openProjMenu() never moves focus into it, so
|
|
144
|
+
// activating a kebab by keyboard leaves focus on the kebab, and #ws-proj-menu is the last element in
|
|
145
|
+
// index.html — ~730 lines after #ws-landing — so tabbing to it means traversing the rest of the
|
|
146
|
+
// document, and there is no Escape/Arrow handling on it. That gap is real and untouched here.
|
|
147
|
+
// (`menuFor` is a `let` declared further down; every call path runs after module init — the boot
|
|
148
|
+
// applyMode() is the last statement in this file — so it is never read in its TDZ.)
|
|
149
|
+
const closeProjMenu = () => {
|
|
150
|
+
const owner = menuFor;
|
|
151
|
+
const hadFocus = $projMenu.contains(document.activeElement);
|
|
152
|
+
$projMenu.hidden = true;
|
|
153
|
+
$projMenu.classList.remove('show');
|
|
154
|
+
if (hadFocus && owner) $landing.querySelector(`[data-kebab="${escapeAttr(owner)}"]`)?.focus({ focusVisible: true });
|
|
155
|
+
};
|
|
137
156
|
|
|
138
157
|
const LS_MODE = 'floless:mode';
|
|
139
158
|
// Per-app Workspaces presentation. The flag (floless.workspace, surfaced on /api/apps) says WHICH
|
|
@@ -463,6 +482,67 @@
|
|
|
463
482
|
}
|
|
464
483
|
}
|
|
465
484
|
|
|
485
|
+
// A workflow was renamed, duplicated, imported or deleted — here, in another tab, or by the terminal
|
|
486
|
+
// AI. aware.js relays the `apps-changed` SSE as a DOM event (the same seam as floless:render-progress:
|
|
487
|
+
// a relay, not a wider bridge, since this is the only listener). Without it the landing kept showing
|
|
488
|
+
// pre-rename workflow names on the project cards, and a stale `data-seed-app` on the create cards,
|
|
489
|
+
// until a manual reload — it caches `projects` and `wsAppEntries` and otherwise re-derives them only
|
|
490
|
+
// in loadProjects(), which applyMode() calls solely on ENTERING Workspaces mode with no project open
|
|
491
|
+
// (#389).
|
|
492
|
+
//
|
|
493
|
+
// Gated on the landing actually being on screen — the same `ws && !current` condition applyMode()
|
|
494
|
+
// uses. With a project open, or in Workflows mode, the landing is hidden and closing the project (or
|
|
495
|
+
// switching mode) re-runs applyMode() → loadProjects() anyway, so those paths self-heal without
|
|
496
|
+
// background churn. The guard also drops the broadcasts that never concern the landing: freeze and
|
|
497
|
+
// unfreeze fire `apps-changed` for a workflow open in Workflows mode, and the 3D render fires it
|
|
498
|
+
// mid-project when its companion app appears.
|
|
499
|
+
// True while the user is engaged with something an unprompted rebuild would pull out from under
|
|
500
|
+
// them. Two halves, because neither covers the other:
|
|
501
|
+
// - projActionBusy — an in-flight rename/duplicate/archive from the card kebab.
|
|
502
|
+
// - any open modal — the landing's OTHER prompts (createSeeded's and createFromDrawing's name
|
|
503
|
+
// boxes, deleteArchivedProject's confirm) never touch projActionBusy, and formModal returns
|
|
504
|
+
// focus on close to the element that opened it. Rebuild the landing underneath and that element
|
|
505
|
+
// is detached; promptName passes no fallback, so focus lands on <body>. Read off the shared
|
|
506
|
+
// .modal-backdrop.show class rather than a new bridge seam — workspaces.js already opens these
|
|
507
|
+
// through bridge.formModal, so it is the same surface, not a wider one.
|
|
508
|
+
const landingBusy = () => projActionBusy || !!document.querySelector('.modal-backdrop.show');
|
|
509
|
+
|
|
510
|
+
let appsChangedTimer = null;
|
|
511
|
+
function appsChangedRefresh() {
|
|
512
|
+
if (mode !== 'workspaces' || current) return; // re-check — the user can move on during the wait
|
|
513
|
+
// Same "suppress an autonomous repaint while the user is engaged" guard as kbAdjustActive().
|
|
514
|
+
//
|
|
515
|
+
// DEFER, don't drop. It is tempting to return here and let doProjectAction's trailing
|
|
516
|
+
// loadProjects() reconcile instead, but that call is after the try/catch/finally and the rename
|
|
517
|
+
// CANCEL path (`if (!name) return`) never reaches it — an event dropped during a prompt the user
|
|
518
|
+
// then dismissed would be lost for good, leaving exactly the stale landing this listener exists to
|
|
519
|
+
// fix. Re-arming keeps the guard self-sufficient instead of coupling it to another function's
|
|
520
|
+
// control flow. Every branch that raises either half lowers it again (a `finally` for the flag, a
|
|
521
|
+
// close for the modal), so this waits, it cannot spin — and the re-check is a boolean plus one
|
|
522
|
+
// querySelector, cheap enough to poll while a dialog sits open.
|
|
523
|
+
if (landingBusy()) { appsChangedTimer = setTimeout(appsChangedRefresh, 250); return; }
|
|
524
|
+
// #ws-proj-menu lives OUTSIDE $landing, so the repaint does NOT close it: it would stay pinned at
|
|
525
|
+
// the coordinates of the kebab that opened it while the grid reflows beneath it, reading as if it
|
|
526
|
+
// acts on whichever project slid into that spot. loadProjects()'s own second paint closes it for
|
|
527
|
+
// exactly this reason, and an unprompted refresh needs it more — nothing the user did started it.
|
|
528
|
+
closeProjMenu();
|
|
529
|
+
// `quiet`: the user did not ask for this load, so a surprise failure toast would be noise. A real
|
|
530
|
+
// failure still shows — renderLanding() paints the error banner from projectsLoadError.
|
|
531
|
+
loadProjects({ quiet: true }).catch((err) => {
|
|
532
|
+
// loadProjects swallows API failures itself, so reaching here means the RENDER threw. Nothing to
|
|
533
|
+
// restore (no control was put into a pending state), but never swallow it silently.
|
|
534
|
+
console.error('[workspaces] apps-changed refresh failed to render: ' + ((err && err.message) || err));
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
window.addEventListener('floless:apps-changed', () => {
|
|
538
|
+
if (mode !== 'workspaces' || current) return;
|
|
539
|
+
// Coalesce: one user action can broadcast more than once (an import that also installs a companion
|
|
540
|
+
// app), and every landing refresh is a full innerHTML rebuild. Same 250 ms as aware.js's fs-change
|
|
541
|
+
// debounce.
|
|
542
|
+
clearTimeout(appsChangedTimer);
|
|
543
|
+
appsChangedTimer = setTimeout(appsChangedRefresh, 250);
|
|
544
|
+
});
|
|
545
|
+
|
|
466
546
|
// Translate the failures we can recognise into the user's language, the way kbPaintError does for
|
|
467
547
|
// the Knowledge viewer. Returns '' for anything unrecognised — better to show only the raw detail
|
|
468
548
|
// than to guess wrong about why. The raw string is shown either way, just demoted.
|
|
@@ -629,10 +709,84 @@
|
|
|
629
709
|
`<div class="ws-archived-list">${rows}</div>` +
|
|
630
710
|
`</details>`;
|
|
631
711
|
}
|
|
712
|
+
// Carry the user's place across the rebuild below, which replaces the landing wholesale: that
|
|
713
|
+
// drops focus to <body>, collapses the Archived disclosure, and can leave a scrolled grid showing
|
|
714
|
+
// a different slice. Every caller used to be a click or keypress in this tab, so the user's
|
|
715
|
+
// attention was already on the control they had just pressed and the loss was invisible — the
|
|
716
|
+
// apps-changed refresh (#389) is the first caller that fires with NO local action.
|
|
717
|
+
const keepFocus = landingFocusKey(document.activeElement);
|
|
718
|
+
const keepScroll = $landing.scrollTop;
|
|
719
|
+
const keepArchivedOpen = !!$landing.querySelector('.ws-archived')?.open;
|
|
632
720
|
$landing.innerHTML = html;
|
|
721
|
+
// Reapply in this order: the disclosure changes the scrollable height, so it must land before the
|
|
722
|
+
// offset; focus lands last, with preventScroll so its scroll-into-view can't undo that offset.
|
|
723
|
+
if (keepArchivedOpen) { const d = $landing.querySelector('.ws-archived'); if (d) d.open = true; }
|
|
724
|
+
$landing.scrollTop = keepScroll;
|
|
725
|
+
if (keepFocus) $landing.querySelector(keepFocus)?.focus({ focusVisible: true, preventScroll: true });
|
|
726
|
+
tipTruncatedNames();
|
|
633
727
|
reflashCard(); // a repaint must not swallow an in-flight confirmation glow
|
|
634
728
|
}
|
|
635
729
|
|
|
730
|
+
/** Make a clamped project name reachable: the two-line clamp on .ws-name (see app.css) can hide the
|
|
731
|
+
* tail, which for a real project name is often the discriminating part. Attach the full value as a
|
|
732
|
+
* data-tip ONLY where something is actually hidden — MEASURED (scrollHeight past clientHeight is
|
|
733
|
+
* exactly the clamp having dropped a line), not guessed from a character count, so a short name
|
|
734
|
+
* never gets a tooltip that merely repeats what is already on screen. data-tip, never title= — the
|
|
735
|
+
* native tooltip is light and breaks the dark theme (CI-enforced by verify:no-title). */
|
|
736
|
+
function tipTruncatedNames() {
|
|
737
|
+
for (const el of $landing.querySelectorAll('.ws-card .ws-name')) {
|
|
738
|
+
const card = el.closest('.ws-card');
|
|
739
|
+
if (!card) continue;
|
|
740
|
+
// +1 absorbs sub-pixel line-height rounding, which otherwise tips every name on some zoom levels.
|
|
741
|
+
// The tip goes on the CARD, not the name: the card is what takes focus, and the shared tooltip
|
|
742
|
+
// handler resolves its anchor with closest('[data-tip]'), which walks UP — so a tip on the inner
|
|
743
|
+
// span is reachable by hover but invisible to a keyboard user. The kebab and the workflow slug
|
|
744
|
+
// inside carry their own tips and still win, being nearer.
|
|
745
|
+
if (el.scrollHeight > el.clientHeight + 1) card.setAttribute('data-tip', el.textContent);
|
|
746
|
+
else card.removeAttribute('data-tip'); // no longer clipped — never leave a tip that repeats the visible name
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// .ws-grid is responsive (auto-fill/minmax), so ANYTHING that changes the landing's width changes
|
|
751
|
+
// whether a name is clipped — without rebuilding a single node. A window resize is only one of those,
|
|
752
|
+
// and not the commonest: collapsing or dragging the Narrative panel rewrites --left-width on #app
|
|
753
|
+
// (app.js's toggleCollapse and the drag handle) and swings this column by ~292px while firing no
|
|
754
|
+
// resize event at all, and opening the Archived disclosure can bring in this container's own
|
|
755
|
+
// scrollbar. So observe the landing box instead of listening for window resizes: it is stable across
|
|
756
|
+
// renderLanding()'s innerHTML rebuilds (no re-observing needed) and its content box moves for all
|
|
757
|
+
// three causes. That makes "a tip exists exactly when something is hidden" hold continuously rather
|
|
758
|
+
// than only at the last paint — widening otherwise strands a tip that repeats a fully visible name,
|
|
759
|
+
// and narrowing leaves a freshly-clipped one with no way to read its tail.
|
|
760
|
+
let wsResizeTipTimer = null;
|
|
761
|
+
new ResizeObserver(() => {
|
|
762
|
+
clearTimeout(wsResizeTipTimer);
|
|
763
|
+
// Debounced, because a drag fires continuously and every pass is a forced layout read. The mode
|
|
764
|
+
// guard belongs INSIDE the timer, not at observation time: a resize followed within the debounce by
|
|
765
|
+
// opening a project would otherwise measure a hidden landing, where every height reads 0 and every
|
|
766
|
+
// tip would be stripped.
|
|
767
|
+
wsResizeTipTimer = setTimeout(() => { if (mode === 'workspaces' && !current) tipTruncatedNames(); }, 150);
|
|
768
|
+
}).observe($landing);
|
|
769
|
+
|
|
770
|
+
// A selector that re-finds the focused control after a rebuild. Identify by the attribute the
|
|
771
|
+
// element is ACTED on by, never by DOM position: a rebuild reorders the grid (a rename re-fronts its
|
|
772
|
+
// card), so an index would hand focus to a different project — worse than losing it. Returns null
|
|
773
|
+
// for anything unrecognised or outside the landing, which simply means "don't restore".
|
|
774
|
+
const FOCUS_KEY_ATTRS = ['data-open', 'data-kebab', 'data-restore', 'data-delete-archived'];
|
|
775
|
+
function landingFocusKey(el) {
|
|
776
|
+
if (!el || !$landing.contains(el)) return null;
|
|
777
|
+
if (el.id) return `#${el.id}`; // #ws-import-project / #ws-retry-projects
|
|
778
|
+
for (const a of FOCUS_KEY_ATTRS) {
|
|
779
|
+
const v = el.getAttribute(a);
|
|
780
|
+
if (v != null) return `[${a}="${escapeAttr(v)}"]`;
|
|
781
|
+
}
|
|
782
|
+
// A create card needs BOTH halves of its identity: one workflow can declare several create actions
|
|
783
|
+
// (steel declares two), so data-seed-app alone would match the wrong card.
|
|
784
|
+
const seed = el.getAttribute('data-seed-app');
|
|
785
|
+
if (seed != null) return `[data-seed-app="${escapeAttr(seed)}"][data-seed-action="${escapeAttr(el.getAttribute('data-seed-action') || '')}"]`;
|
|
786
|
+
if (el.classList.contains('ws-archived-summary')) return '.ws-archived-summary';
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
|
|
636
790
|
$landing.addEventListener('click', async (e) => {
|
|
637
791
|
const kebab = e.target.closest('[data-kebab]');
|
|
638
792
|
if (kebab) { e.stopPropagation(); openProjMenu(kebab.dataset.kebab, kebab); return; }
|