|
1 | | -# PR 11.188 Palette Reverse Engineering Report |
2 | | - |
3 | | -## Purpose |
4 | | -Reverse engineer the legacy Palette Browser, preserve it as `tools/Palette Browser-v1/`, and rebuild `tools/Palette Browser/` as the first clean session-backed Tool v2 implementation. |
5 | | - |
6 | | -## Legacy Files Inspected |
7 | | -Inspected before replacing the active folder: |
8 | | - |
9 | | -- `tools/Palette Browser/index.html` |
10 | | -- `tools/Palette Browser/main.js` |
11 | | -- `tools/Palette Browser/paletteBrowser.css` |
12 | | -- `tools/Palette Browser/README.md` |
13 | | -- `tools/Palette Browser/how_to_use.html` |
14 | | -- `tools/Palette Browser/assets/images/preview.svg` |
15 | | - |
16 | | -Immediate legacy input dependencies inspected for contract evidence only: |
17 | | - |
18 | | -- `tools/shared/paletteDocumentContract.js` |
19 | | -- `src/engine/paletteList.js` |
20 | | - |
21 | | -## Legacy Folder Preservation |
22 | | -The legacy implementation was moved by safe copy-then-replace because Windows denied a direct folder rename while the folder was likely held open by another process. |
23 | | - |
24 | | -Result: |
25 | | - |
26 | | -```text |
27 | | -tools/Palette Browser-v1/ |
28 | | -``` |
29 | | - |
30 | | -contains the legacy Palette Browser files, including the old platform shell entry, legacy CSS, README, how-to file, and preview asset. |
31 | | - |
32 | | -## Legacy Inputs |
33 | | -Observed legacy inputs and data paths: |
34 | | - |
35 | | -- `paletteJson` style data was normalized indirectly through `normalizePaletteDocument()` and `validatePaletteDocument()`. |
36 | | -- Legacy built-in palettes came from `src/engine/paletteList.js` via global `palettesList`. |
37 | | -- Custom palettes were stored in `localStorage` under `toolboxaid.paletteBrowser.customPalettes`. |
38 | | -- Hidden built-in palette ids were stored in `localStorage` under `toolboxaid.paletteBrowser.hiddenBuiltins`. |
39 | | -- Shared palette state was read/written through `assetUsageIntegration.js` handoff helpers. |
40 | | -- Query loading existed through `samplePresetPath` and diagnostics helpers. |
41 | | -- Workspace detection depended on URL params, referrer, parent path checks, and shared handoff state. |
42 | | -- Import/export/copy actions accepted broader palette document shapes through legacy normalization. |
43 | | - |
44 | | -Required focus for the rebuilt contract: |
45 | | - |
46 | | -```text |
47 | | -paletteJson.name |
48 | | -paletteJson.colors[] |
49 | | -``` |
50 | | - |
51 | | -A displayable color must provide an explicit `#RRGGBB` or `#RRGGBBAA` value. The rebuilt contract accepts string color entries and object entries with an explicit `hex` field because those were the explicit color forms observed in the legacy palette paths. |
52 | | - |
53 | | -## UI Sections Found |
54 | | -Legacy UI sections found: |
55 | | - |
56 | | -- Collapsible platform shell/header region. |
57 | | -- Left Palette List panel with launch context, search, count, and palette list. |
58 | | -- Center Palette Preview panel with selected palette title, swatches, palette name input, swatch color/name/symbol controls, palette actions, and swatch actions. |
59 | | -- Right Actions & Validation panel with JSON preview, validation summary, import/export/copy/use-in-workspace controls, and handoff status text. |
60 | | - |
61 | | -## Behavior To Keep Conceptually |
62 | | -Kept conceptually in the clean rebuild: |
63 | | - |
64 | | -- Visible tool name: `Palette Browser / Manager`. |
65 | | -- Palette name display. |
66 | | -- Swatch rendering. |
67 | | -- Swatch count display. |
68 | | -- Explicit empty state when no session palette exists. |
69 | | -- Explicit malformed/error state when session palette data violates the contract. |
70 | | -- Validation readout for the active session contract. |
71 | | - |
72 | | -## Behavior To Delete |
73 | | -Deleted from the rebuilt active tool: |
74 | | - |
75 | | -- `platformShell` usage. |
76 | | -- `assetUsageIntegration` usage. |
77 | | -- Shared handoff reads/writes. |
78 | | -- Built-in palette fallback loading. |
79 | | -- `localStorage` custom palette loading. |
80 | | -- Query-driven sample preset loading. |
81 | | -- Import/export/copy/edit/delete/new/duplicate palette workflows. |
82 | | -- Workspace auto-open behavior. |
83 | | -- Legacy broad schema normalization. |
84 | | -- Tool id alias dependencies. |
85 | | - |
86 | | -## Legacy Systems Avoided |
87 | | -The rebuilt `tools/Palette Browser/` and new `tools/common/` files do not import or call: |
88 | | - |
89 | | -- `tools/shared/platformShell.js` |
90 | | -- `tools/shared/assetUsageIntegration.js` |
91 | | -- shared handoff modules |
92 | | -- shared palette document normalization modules |
93 | | -- tool alias registries |
94 | | -- samples or games |
95 | | - |
96 | | -## Final Tool Contract |
97 | | -The rebuilt Palette Browser reads only session-backed `paletteJson`. |
98 | | - |
99 | | -Supported session sources: |
100 | | - |
101 | | -1. Workspace URL writes session and launches tool with `hostContextId`; the tool reads `toolboxaid.toolHost.context.<hostContextId>` from `sessionStorage`. |
102 | | -2. Tool URL provides explicit `paletteJson` or `paletteData`; `tools/common/sessionContext.js` writes that explicit data to session first, then returns the session-backed record. |
103 | | -3. Tool URL provides explicit `paletteUrl`; `tools/common/sessionContext.js` fetches that explicit URL, writes the result to session first, then returns the session-backed record. |
104 | | - |
105 | | -Accepted `paletteJson` shape: |
106 | | - |
107 | | -```text |
108 | | -paletteJson.name: non-empty string |
109 | | -paletteJson.colors: array |
110 | | -paletteJson.colors[]: string #RRGGBB/#RRGGBBAA or object with hex #RRGGBB/#RRGGBBAA |
111 | | -``` |
112 | | - |
113 | | -No fallback/default palette data is provided. |
114 | | - |
115 | | -## Sidebar Accordion Control Type Plan |
116 | | -Initial Palette-first control groups: |
117 | | - |
118 | | -### Context |
119 | | -Implemented as read-only session source/context display. |
120 | | - |
121 | | -Needed controls/readouts: |
122 | | - |
123 | | -- session found/missing |
124 | | -- source path |
125 | | -- context id |
126 | | - |
127 | | -### Palette |
128 | | -Implemented as read-only palette display. |
129 | | - |
130 | | -Needed controls/readouts: |
131 | | - |
132 | | -- palette name |
133 | | -- color count |
134 | | -- swatch grid |
135 | | - |
136 | | -### Display |
137 | | -Implemented as fixed display only. |
138 | | - |
139 | | -Needed controls/readouts: |
140 | | - |
141 | | -- responsive swatch cards |
142 | | -- visible hex/name/symbol values |
143 | | - |
144 | | -Deferred, not implemented: |
145 | | - |
146 | | -- display density controls |
147 | | -- sort controls |
148 | | -- color-space toggles |
149 | | - |
150 | | -### Validation |
151 | | -Implemented as read-only contract validation. |
152 | | - |
153 | | -Needed controls/readouts: |
154 | | - |
155 | | -- valid/invalid contract state |
156 | | -- error messages for malformed session data |
157 | | - |
158 | | -### Workspace |
159 | | -Implemented as read-only workspace/session status. |
160 | | - |
161 | | -Needed controls/readouts: |
162 | | - |
163 | | -- workspace/session context status |
164 | | - |
165 | | -Deferred, not implemented: |
166 | | - |
167 | | -- workspace session mutation controls |
168 | | -- import/export controls |
169 | | -- palette selection handoff controls |
170 | | - |
171 | | -## Menu Plan |
172 | | -The rebuilt tool has two menu zones: |
173 | | - |
174 | | -```text |
175 | | -menuTool |
176 | | -menuWorkspace |
177 | | -``` |
178 | | - |
179 | | -`menuTool` contains read-only session and contract launch information for the current tool. |
180 | | - |
181 | | -`menuWorkspace` contains read-only workspace/session status only. No workspace mutation, import, or export controls are exposed in this PR. |
182 | | - |
183 | | -## Files Created Or Rebuilt |
184 | | -- `tools/Palette Browser-v1/**` preserves the legacy implementation. |
185 | | -- `tools/Palette Browser/index.html` clean active Palette Browser shell. |
186 | | -- `tools/Palette Browser/main.js` class-based session reader/renderer. |
187 | | -- `tools/Palette Browser/styles.css` active Palette Browser styling. |
188 | | -- `tools/common/toolLayout.css` shared clean tool layout foundation. |
189 | | -- `tools/common/sessionContext.js` session-backed context reader/writer. |
190 | | -- `tools/common/toolContract.js` narrow palette contract validator. |
191 | | - |
192 | | -## Validation Results |
193 | | -Targeted validation run: |
194 | | - |
195 | | -```powershell |
196 | | -node --check "tools/common/sessionContext.js" |
197 | | -node --check "tools/common/toolContract.js" |
198 | | -node --check "tools/Palette Browser/main.js" |
199 | | -``` |
200 | | - |
201 | | -Results: |
202 | | - |
203 | | -- `node --check "tools/common/sessionContext.js"` passed. |
204 | | -- `node --check "tools/common/toolContract.js"` passed. |
205 | | -- `node --check "tools/Palette Browser/main.js"` passed. |
206 | | - |
207 | | -Additional targeted inspection: |
208 | | - |
209 | | -```powershell |
210 | | -rg -n "platformShell|assetUsageIntegration|shared/|handoff|v2|V2" "tools/Palette Browser" "tools/common" |
211 | | -``` |
212 | | - |
213 | | -Result: only required lifecycle log labels contain `V2`; no platformShell, assetUsageIntegration, shared import, or handoff references remain in the rebuilt active tool/common files. |
214 | | - |
215 | | -Targeted browser/tool launch check: not run. No existing automated Palette Browser browser harness was found in scope, and the requested validation was syntax-only. |
216 | | - |
217 | | -## Full Samples Smoke Decision |
218 | | -Skipped - targeted Palette Browser and new `tools/common/` foundation changes only; no broad shared sample loader change was made. |
219 | | - |
220 | | -## Roadmap Decision |
221 | | -`docs/dev/roadmaps/MASTER_ROADMAP_ENGINE.md` was left untouched. Existing palette roadmap entries relate to older palette data completeness/normalization work, not an exact Tool v2 or Palette v2 rebuild status item, so no status-only marker update was appropriate. |
| 1 | +# Palette Manager Reverse Engineering |
| 2 | + |
| 3 | +## Inputs |
| 4 | +- paletteJson |
| 5 | + |
| 6 | +## UI Sections |
| 7 | +- Header (name) |
| 8 | +- Swatch grid |
| 9 | +- Count display |
| 10 | + |
| 11 | +## Behavior |
| 12 | +- Render colors from array |
| 13 | +- Display palette name |
| 14 | +- Show total count |
| 15 | + |
| 16 | +## KEEP |
| 17 | +- Concept: palette display |
| 18 | +- Concept: swatch grid |
| 19 | + |
| 20 | +## DELETE |
| 21 | +- platformShell |
| 22 | +- shared handoff |
| 23 | +- fallback data |
| 24 | +- tool aliasing |
| 25 | +- workspace coupling |
0 commit comments