v3.25.0 review: the access-rules open-state lifecycle

- profilerEdit resets the expanded-block map, so opening another profile
  (or a freshly scanned one) starts with every access-rules block
  collapsed instead of inheriting the previous profile's state.
- Deleting a rule re-keys the map (profilerArrShiftOpen): the entries
  below stay, the ones above shift down, so the expanded blocks stay
  with their rules.
- The declaration sits before the render function that reads it.
- Test fixture: a real command-description tag (0x85) instead of the
  RESIZE branch's 0x84.

Tests: the shift helper, the profilerEdit reset pin, the existing
editor tests.  883 frontend + 858 Python; sw cache simple-v424.
This commit is contained in:
2026-10-11 00:17:36 +03:00
parent b00d533f03
commit db78696865
2 changed files with 32 additions and 8 deletions
+20 -4
View File
@@ -19545,6 +19545,8 @@ function profilerEdit(i) {
const p = profiles[i];
profilerEditId = p.id;
profilerDraft = JSON.parse(JSON.stringify(p));
// a fresh draft starts with every access-rules block collapsed
_profilerArrOpen = {};
profilerSetView('editor');
document.getElementById('profiler-name').value = profilerDraft.name;
profilerRenderEditor();
@@ -19733,6 +19735,7 @@ function profilerAddRule() {
function profilerDeleteRule(i) {
if (!profilerDraft) return;
profilerDraft.rules.splice(i, 1);
_profilerArrOpen = profilerArrShiftOpen(_profilerArrOpen, i);
profilerRenderEditor();
}
@@ -19807,6 +19810,11 @@ function profilerRenderRule(i, r) {
return html;
}
// The expanded access-rule blocks of the profile editor (transient UI state,
// kept across the editor re-renders; None hides the block entirely; a fresh
// draft resets it and a deleted rule shifts the keys).
let _profilerArrOpen = {};
// Access-rules check editor (v3.25.0): captured rules open as structured rows
// (operation bits / command + security conditions) and hand-made rules can be
// built the same way; every change re-encodes the canonical decoded line the
@@ -19844,15 +19852,23 @@ function profilerRenderAccessRulesEditor(i, r) {
return html;
}
// The expanded access-rule blocks of the profile editor (transient UI state,
// kept across the editor re-renders; None hides the block entirely).
let _profilerArrOpen = {};
function profilerArrToggleOpen(i) {
_profilerArrOpen[i] = !_profilerArrOpen[i];
profilerRenderEditor();
}
// Re-key the open-state map after a rule at `removed` was deleted: the
// entries below stay, the ones above shift down by one.
function profilerArrShiftOpen(open, removed) {
const next = {};
for (const k of Object.keys(open)) {
const n = Number(k);
if (n < removed) next[n] = open[k];
else if (n > removed) next[n - 1] = open[k];
}
return next;
}
// One expected rule row: the operation form + bit checkboxes (or the RESIZE /
// INCREASE command), the condition rows and the canonical preview line.
function profilerArrRuleHtml(i, ri, line) {