Skip to content

Commit f126af1

Browse files
author
DavidQ
committed
Keep untagged swatches last when sorting Palette Manager V2 tags descending - PR_26124_063-palette-manager-tag-sort-untagged-last
1 parent 0bff14b commit f126af1

7 files changed

Lines changed: 136 additions & 16 deletions

File tree

docs/dev/codex_commands.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
# Codex Commands - PR_26124_061-palette-manager-tag-clear-undo-location-and-pin-scroll
1+
# Codex Commands - PR_26124_063-palette-manager-tag-sort-untagged-last
22

33
## Workflow
44
- Read `docs/dev/PROJECT_INSTRUCTIONS.md`.
55
- Used `.codex/skills/repo-build/SKILL.md`.
66
- Checked git status before implementation.
7-
- Created `docs/pr/PR_26124_061-palette-manager-tag-clear-undo-location-and-pin-scroll/PLAN_PR.md`.
8-
- Created `docs/pr/PR_26124_061-palette-manager-tag-clear-undo-location-and-pin-scroll/BUILD_PR.md`.
7+
- Created `docs/pr/PR_26124_063-palette-manager-tag-sort-untagged-last/PLAN_PR.md`.
8+
- Created `docs/pr/PR_26124_063-palette-manager-tag-sort-untagged-last/BUILD_PR.md`.
99
- Read the active BUILD doc before changing runtime files.
10-
- Updated Palette Manager V2 only.
11-
- Created `docs/pr/PR_26124_061-palette-manager-tag-clear-undo-location-and-pin-scroll/APPLY_PR.md`.
10+
- Updated only `tools/palette-manager-v2/modules/PaletteManagerApp.js`.
11+
- Created `docs/pr/PR_26124_063-palette-manager-tag-sort-untagged-last/APPLY_PR.md`.
1212

1313
## Validation Commands
1414
- `node --check tools/palette-manager-v2/modules/PaletteManagerApp.js`
15-
- `node --check tools/palette-manager-v2/controls/PaletteEditorControl.js`
16-
- `node --check tools/palette-manager-v2/controls/UserPaletteControl.js`
17-
- `node --check tools/palette-manager-v2/controls/SourcePaletteBrowserControl.js`
18-
- Targeted served-browser Palette Manager V2 selection clear, heading action placement, tag add, and source scroll preservation validation using Playwright from Node.
15+
- Targeted served-browser Palette Manager V2 Tag ascending/descending sort validation using Playwright from Node.
1916
- `git diff --check`
2017
- `npm run test:workspace-v2`
2118
- `git diff --cached --check`
2219
- `npm run codex:review-artifacts`
23-
- Python `zipfile` packaging for `tmp/PR_26124_061-palette-manager-tag-clear-undo-location-and-pin-scroll_delta.zip`
20+
- Python `zipfile` packaging for `tmp/PR_26124_063-palette-manager-tag-sort-untagged-last_delta.zip`
2421

2522
## Validation Outcome
26-
- JavaScript syntax checks: PASS.
27-
- Targeted served-browser Palette Manager V2 selection clear, heading action placement, tag add, and source scroll preservation check: PASS.
28-
- `git diff --check`: PASS with Git LF-to-CRLF warnings for changed Palette Manager files.
23+
- JavaScript syntax check: PASS.
24+
- Targeted served-browser Palette Manager V2 Tag sort validation: PASS.
25+
- `git diff --check`: PASS.
2926
- `git diff --cached --check`: PASS.
3027
- `npm run test:workspace-v2`: FAILED because the script is missing from `package.json`.
3128
- Review artifacts: generated.

docs/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add Palette Manager heading controls and preserve source pin scroll - PR_26124_061-palette-manager-tag-clear-undo-location-and-pin-scroll
1+
Keep untagged swatches last in Palette Manager Tag sort - PR_26124_063-palette-manager-tag-sort-untagged-last
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# PR_26124_063-palette-manager-tag-sort-untagged-last Report
2+
3+
## Summary
4+
Implemented a Palette Manager V2-only Tag sort fix.
5+
6+
## Changes
7+
- User Palette Tag ascending keeps tagged swatches sorted A-Z with untagged swatches last.
8+
- User Palette Tag descending now keeps tagged swatches sorted Z-A with untagged swatches last.
9+
- The fix avoids full-array reverse for Tag sorting so the untagged bucket does not move ahead of tagged swatches.
10+
11+
## Validation
12+
- `node --check tools/palette-manager-v2/modules/PaletteManagerApp.js`: PASS.
13+
- Targeted served-browser Palette Manager V2 Tag ascending/descending sort validation: PASS.
14+
- `git diff --check`: PASS.
15+
- `npm run test:workspace-v2`: FAIL, `package.json` does not define `test:workspace-v2`.
16+
- Full samples smoke test: skipped because this PR is limited to Palette Manager V2 User Palette sort behavior and sample JSON remains out of scope.
17+
18+
## Manual Test Notes
19+
1. Open Palette Manager V2.
20+
2. Create or import swatches tagged `alpha`, tagged `zulu`, and untagged.
21+
3. Click User Palette `Tag` sort once and confirm tagged swatches sort A-Z with untagged swatches last.
22+
4. Click User Palette `Tag` sort again and confirm tagged swatches sort Z-A with untagged swatches last.
23+
5. Confirm Clear checkbox behavior, pin button size, source/sample pin scroll preservation, and Validation/Error Viewer behavior are unchanged.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# APPLY_PR - PR_26124_063-palette-manager-tag-sort-untagged-last
2+
3+
## Summary
4+
Fixed Palette Manager V2 User Palette Tag descending sort so untagged swatches remain after tagged swatches.
5+
6+
## Applied Changes
7+
- Updated `sortRowsByTag` in `tools/palette-manager-v2/modules/PaletteManagerApp.js`.
8+
- Removed full-array reverse from Tag descending sort.
9+
- Kept untagged swatches after tagged swatches for both ascending and descending.
10+
- Preserved stable original order for equal tag keys and untagged rows.
11+
- Did not change Clear checkbox behavior, pin sizing, source/sample pin scroll preservation, or Validation/Error Viewer behavior.
12+
13+
## Validation
14+
- `node --check tools/palette-manager-v2/modules/PaletteManagerApp.js`: PASS.
15+
- Targeted served-browser Palette Manager V2 Tag ascending/descending sort validation: PASS.
16+
- `git diff --check`: PASS.
17+
- `npm run test:workspace-v2`: FAIL, `package.json` does not define `test:workspace-v2`.
18+
- Full samples smoke test: skipped by instruction.
19+
20+
## Artifacts
21+
- Review diff: `docs/dev/reports/codex_review.diff`
22+
- Changed files: `docs/dev/reports/codex_changed_files.txt`
23+
- Delta ZIP: `tmp/PR_26124_063-palette-manager-tag-sort-untagged-last_delta.zip`
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# BUILD_PR - PR_26124_063-palette-manager-tag-sort-untagged-last
2+
3+
## Purpose
4+
Implement one scoped Palette Manager V2 sort fix: User Palette Tag descending sort keeps untagged swatches after tagged swatches.
5+
6+
## Scope
7+
- `tools/palette-manager-v2/modules/PaletteManagerApp.js`
8+
- PR workflow docs and required review artifacts only.
9+
10+
## Implementation
11+
1. Update `sortRowsByTag` in `PaletteManagerApp.js`.
12+
2. Do not call full-array reverse for Tag descending sort.
13+
3. Keep untagged swatches after tagged swatches in both directions.
14+
4. For tagged swatches:
15+
- ascending uses A-Z tag comparison,
16+
- descending uses Z-A tag comparison.
17+
5. Preserve stable original order for equal tag keys and untagged rows.
18+
19+
## Boundaries
20+
- Do not change Clear checkbox behavior.
21+
- Do not change pin button size.
22+
- Do not change source/sample pin scroll preservation.
23+
- Do not change Validation/Error Viewer behavior.
24+
- Do not touch workspace/toolState/session behavior.
25+
- Do not touch sample JSON.
26+
- Do not modify `tools/shared`.
27+
- Do not add dependencies.
28+
- Do not broadly refactor Palette Manager V2.
29+
30+
## Validation
31+
- Syntax check changed JavaScript files.
32+
- Run targeted served-browser Palette Manager V2 Tag ascending/descending sort validation.
33+
- Run `npm run test:workspace-v2`.
34+
- Skip the full samples smoke test.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PLAN_PR - PR_26124_063-palette-manager-tag-sort-untagged-last
2+
3+
## Goal
4+
Fix Palette Manager V2 User Palette Tag descending sort so untagged swatches stay after tagged swatches.
5+
6+
## Scope
7+
- `tools/palette-manager-v2/modules/PaletteManagerApp.js`
8+
- PR workflow docs and required review artifacts only.
9+
10+
## Boundaries
11+
- Do not change Clear checkbox behavior.
12+
- Do not change pin button size.
13+
- Do not change source/sample pin scroll preservation.
14+
- Do not change Validation/Error Viewer behavior.
15+
- Do not touch workspace/toolState/session behavior.
16+
- Do not touch sample JSON.
17+
- Do not modify `tools/shared`.
18+
- Do not add dependencies.
19+
- Avoid broad refactor.
20+
21+
## Implementation Plan
22+
1. Update only User Palette Tag sort comparison logic in `PaletteManagerApp.js`.
23+
2. Keep tagged swatches before untagged swatches for both ascending and descending.
24+
3. Sort tagged swatches A-Z for ascending.
25+
4. Sort tagged swatches Z-A for descending.
26+
5. Preserve original order for equivalent tag keys and untagged swatches.
27+
28+
## Playwright
29+
- Command: `npm run test:workspace-v2`
30+
- What Playwright validates: Workspace V2/tool lifecycle coverage remains unchanged by this Palette Manager V2-only sort update.
31+
- Expected pass behavior: Workspace V2 validation remains green.
32+
- Expected fail behavior: missing script or Workspace V2 regression is reported.
33+
- Full samples smoke test: skipped by instruction.
34+
35+
## Manual Validation
36+
1. Open Palette Manager V2.
37+
2. Create or import User Palette swatches with tags `alpha`, `zulu`, and at least one untagged swatch.
38+
3. Click User Palette `Tag` sort once.
39+
4. Confirm tagged swatches sort A-Z and untagged swatches remain last.
40+
5. Click User Palette `Tag` sort again.
41+
6. Confirm tagged swatches sort Z-A and untagged swatches remain last.
42+
7. Confirm Clear checkbox behavior, pin button size, source/sample pin scroll preservation, and Validation/Error Viewer behavior are unchanged.

tools/palette-manager-v2/modules/PaletteManagerApp.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function applySortDirection(entries, sortDirection) {
123123

124124
function sortRowsByTag(rows, sortDirection) {
125125
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
126+
const tagDirection = sortDirection === "descending" ? -1 : 1;
126127
const sortedRows = (Array.isArray(rows) ? rows : [])
127128
.map((row, index) => ({ row, index, tagKey: getTagSortKey(row?.swatch) }))
128129
.sort((left, right) => {
@@ -132,10 +133,10 @@ function sortRowsByTag(rows, sortDirection) {
132133
if (left.tagKey && !right.tagKey) {
133134
return -1;
134135
}
135-
return collator.compare(left.tagKey, right.tagKey) || left.index - right.index;
136+
return (collator.compare(left.tagKey, right.tagKey) * tagDirection) || left.index - right.index;
136137
})
137138
.map((entry) => entry.row);
138-
return applySortDirection(sortedRows, sortDirection);
139+
return sortedRows;
139140
}
140141

141142
function toggleSortDirection(sortDirection) {

0 commit comments

Comments
 (0)