@floless/app 0.101.4 → 0.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -625,6 +625,7 @@
625
625
  // Exports gate unlocks without a reload.
626
626
  async function approveProject() {
627
627
  if (!current) return;
628
+ const approvingProject = current;
628
629
  const btn = document.getElementById('ws-approve');
629
630
  btn.disabled = true;
630
631
  const prev = btn.textContent;
@@ -635,16 +636,24 @@
635
636
  // fires. flushContract() PUTs the live contract and resolves; a save failure aborts the bake.
636
637
  const win = frames.model && frames.model.contentWindow;
637
638
  if (win && typeof win.flushContract === 'function') await win.flushContract();
638
- const res = await api(`/api/contract/${encodeURIComponent(current.app)}/approve?project=${encodeURIComponent(current.id)}`, { method: 'POST' });
639
- if (res && res.approvedAt) current.approvedAt = res.approvedAt; // unlock exports
640
- showToast(`Approved — "${current.name}" is baked into ${appDisplayName(current.app)}`, 'ok');
641
- track('workspace_project_approved', { app: current.app }); // a successful sign-off
639
+ const res = await api(`/api/contract/${encodeURIComponent(approvingProject.app)}/approve?project=${encodeURIComponent(approvingProject.id)}`, { method: 'POST' });
640
+ if (res && res.approvedAt) approvingProject.approvedAt = res.approvedAt; // unlock exports
641
+ const stillOpen = current && current.id === approvingProject.id;
642
+ if (stillOpen && !$wsHistory.hidden && res && res.version && Number.isInteger(Number(res.version.n))) {
643
+ expandDiffOnce = { projectId: approvingProject.id, n: Number(res.version.n) };
644
+ }
645
+ showToast(`Approved — "${approvingProject.name}" is baked into ${appDisplayName(approvingProject.app)}`, 'ok');
646
+ track('workspace_project_approved', { app: approvingProject.app }); // a successful sign-off
642
647
  // First Approve for this app calms the "✦ Start here" beacon (the document-archetype
643
648
  // analog of a workflow's first Run); ticks the Review + Approve guide rows.
644
- if (bridge.markWorkspaceApproved && wsHasDocGuide()) bridge.markWorkspaceApproved(current.app);
645
- syncWorkspaceGuide();
646
- if (!$wsExports.hidden) renderExports(); // reflect the unlocked gate immediately if it's open
647
- if (!$wsHistory.hidden) renderHistory(); // a new version was recorded — reflect it + clear the banner
649
+ if (bridge.markWorkspaceApproved && WORKSPACE_APPS[approvingProject.app]?.docGuide) {
650
+ bridge.markWorkspaceApproved(approvingProject.app);
651
+ }
652
+ if (stillOpen) {
653
+ syncWorkspaceGuide();
654
+ if (!$wsExports.hidden) renderExports(); // reflect the unlocked gate immediately if it's open
655
+ if (!$wsHistory.hidden) await renderHistory(); // reflect it, clear the banner, and open the new version's comparison
656
+ }
648
657
  } catch (err) {
649
658
  showToast('Approve failed: ' + (err && err.message || err), 'warn');
650
659
  } finally { btn.disabled = false; btn.textContent = prev; }
@@ -2103,6 +2112,32 @@
2103
2112
  };
2104
2113
 
2105
2114
  let versions = []; // last-rendered ledger (newest first)
2115
+ let expandDiffOnce = null; // { projectId, n }: successful Approve opens only that project's new row
2116
+
2117
+ function changeCellHtml(v, canDiff) {
2118
+ const s = v.changeSummary;
2119
+ const n = Number(v.n);
2120
+ const summaryBase = s && Number.isInteger(Number(s.from)) ? Number(s.from) : null;
2121
+ const baseAttr = summaryBase != null ? ` data-diff-base="${escapeAttr(String(summaryBase))}"` : '';
2122
+ const toggle = canDiff
2123
+ ? `<button type="button" class="hd-toggle" data-diff="${escapeAttr(String(n))}"${baseAttr} aria-expanded="false" ` +
2124
+ `aria-controls="hist-diff-${escapeAttr(String(n))}" aria-label="View detailed changes in version ${escapeAttr(String(n))}" ` +
2125
+ 'data-tip="Show the complete member-by-member comparison">' +
2126
+ '<span class="hd-caret">▸</span><span class="hd-toggle-label">View detailed changes</span></button>'
2127
+ : '';
2128
+ if (!s || !Array.isArray(s.bullets)) {
2129
+ return `<div class="hist-event">${escapeHtml(v.message)}</div>${toggle}`;
2130
+ }
2131
+ const visible = s.bullets.slice(0, 4);
2132
+ const more = s.bullets.length - visible.length;
2133
+ const bullets = visible.map((x) => `<li>${escapeHtml(String(x))}</li>`).join('') +
2134
+ (more > 0 ? `<li class="hist-change-more">${escapeHtml(`${more} more change ${more === 1 ? 'category' : 'categories'} in the detailed view.`)}</li>` : '');
2135
+ const cautions = Array.isArray(s.cautions) && s.cautions.length
2136
+ ? `<div class="hist-change-caution">⚠ ${escapeHtml(s.cautions.join(' '))}</div>`
2137
+ : '';
2138
+ return `<div class="hist-change-head">${escapeHtml(String(s.headline || v.message))}</div>` +
2139
+ `<ul class="hist-change-list">${bullets}</ul>${cautions}${toggle}`;
2140
+ }
2106
2141
 
2107
2142
  function versionRowHtml(v) {
2108
2143
  // Rolling back to the version you're already on is a no-op — omit the button (blank cell), never disable it.
@@ -2112,21 +2147,20 @@
2112
2147
  // "What changed" disclosure — only when the app HAS a semantic diff (steel; wsApp().diff) AND the
2113
2148
  // version has a predecessor (n>1). v1 is the baseline, and a no-diff app (vectorize) gets NO toggle
2114
2149
  // on ANY row — an ABSENT control, never a disabled one (spec §4.4, mirroring the v1-baseline branch).
2115
- const canDiff = !!(wsApp() && wsApp().diff) && Number(v.n) > 1;
2116
- const toggle = canDiff
2117
- ? `<button type="button" class="hd-toggle" data-diff="${escapeAttr(String(v.n))}" aria-expanded="false" data-tip="What changed vs the previous version"><span class="hd-caret">▸</span></button>`
2118
- : '';
2150
+ const isApprovalBaseline = v.kind === 'approve' && v.changeSummary && v.changeSummary.from == null;
2151
+ const canDiff = !!(wsApp() && wsApp().diff) && Number(v.n) > 1 && !isApprovalBaseline;
2119
2152
  const verRow = `<tr class="${v.current ? 'current' : ''}" data-ver="${escapeAttr(String(v.n))}">` +
2120
- `<td class="hd-cell">${toggle}</td>` +
2121
2153
  `<td><span class="ver${v.current ? ' cur' : ''}">v${escapeHtml(String(v.n))}</span></td>` +
2122
2154
  `<td class="htime">${escapeHtml(histWhen(v.ts))}</td>` +
2123
2155
  `<td><span class="hby">${avatarFor(v.author)}${escapeHtml(v.author)}</span></td>` +
2124
2156
  `<td>${gateBadge(v.gate, v.kind, v.n)}</td>` +
2125
- `<td class="change">${escapeHtml(v.message)}</td>` +
2157
+ `<td class="change">${changeCellHtml(v, canDiff)}</td>` +
2126
2158
  `<td>${action}</td></tr>`;
2127
2159
  // The disclosure row is always emitted (hidden) so toggling is a pure show/hide + lazy fetch.
2128
2160
  const diffRow = canDiff
2129
- ? `<tr class="hist-diff-row" data-diff-for="${escapeAttr(String(v.n))}" hidden><td colspan="7"><div class="hd-panel" data-panel="${escapeAttr(String(v.n))}"></div></td></tr>`
2161
+ ? `<tr class="hist-diff-row" data-diff-for="${escapeAttr(String(v.n))}" hidden><td colspan="6">` +
2162
+ `<div class="hd-panel" id="hist-diff-${escapeAttr(String(v.n))}" data-panel="${escapeAttr(String(v.n))}" role="region" ` +
2163
+ `aria-label="Detailed changes in version ${escapeAttr(String(v.n))}"></div></td></tr>`
2130
2164
  : '';
2131
2165
  return verRow + diffRow;
2132
2166
  }
@@ -2176,10 +2210,14 @@
2176
2210
  // Version/Gate/action are fixed-narrow; When/By auto-size to their nowrap content (fixing them
2177
2211
  // wider than the content wastes room and needlessly wraps Change). Change flexes to the rest.
2178
2212
  '<table class="hist"><thead><tr>' +
2179
- '<th style="width:26px"></th>' +
2180
2213
  '<th style="width:44px">Version</th><th>When</th><th>By</th>' +
2181
2214
  '<th style="width:80px">Gate</th><th style="width:99%">Change</th><th style="width:92px"></th>' +
2182
2215
  '</tr></thead><tbody>' + rows.map(versionRowHtml).join('') + '</tbody></table>';
2216
+ if (expandDiffOnce && expandDiffOnce.projectId === id) {
2217
+ const toggle = $wsHistory.querySelector(`.hd-toggle[data-diff="${CSS.escape(String(expandDiffOnce.n))}"]`);
2218
+ expandDiffOnce = null;
2219
+ if (toggle) toggleDiff(toggle);
2220
+ }
2183
2221
  }
2184
2222
 
2185
2223
  // Rollback confirm — a styled anchored popover (never a native dialog); names the Exports re-lock.
@@ -2391,12 +2429,29 @@
2391
2429
  if (row.hasAttribute('hidden')) {
2392
2430
  row.removeAttribute('hidden');
2393
2431
  btn.setAttribute('aria-expanded', 'true');
2432
+ btn.setAttribute('aria-label', `Hide detailed changes in version ${n}`);
2433
+ const label = btn.querySelector('.hd-toggle-label');
2434
+ if (label) label.textContent = 'Hide detailed changes';
2394
2435
  if (verRow) verRow.classList.add('hd-open');
2395
2436
  const panel = row.querySelector('.hd-panel');
2396
- if (panel && !panel.dataset.stamp) loadDiff(n, diffBase.get(baseKeyFor(n))); // lazy first load
2437
+ if (panel && !panel.dataset.stamp) {
2438
+ const key = baseKeyFor(n);
2439
+ let base = diffBase.get(key);
2440
+ if (!diffBase.has(key) && btn.dataset.diffBase) {
2441
+ const summaryBase = Number(btn.dataset.diffBase);
2442
+ if (Number.isInteger(summaryBase)) {
2443
+ diffBase.set(key, summaryBase);
2444
+ base = summaryBase;
2445
+ }
2446
+ }
2447
+ loadDiff(n, base); // lazy first load; approval rows start at the previous signed version
2448
+ }
2397
2449
  } else {
2398
2450
  row.setAttribute('hidden', '');
2399
2451
  btn.setAttribute('aria-expanded', 'false');
2452
+ btn.setAttribute('aria-label', `View detailed changes in version ${n}`);
2453
+ const label = btn.querySelector('.hd-toggle-label');
2454
+ if (label) label.textContent = 'View detailed changes';
2400
2455
  if (verRow) verRow.classList.remove('hd-open');
2401
2456
  }
2402
2457
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.101.4",
3
+ "version": "0.102.0",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {