Skip to content

Commit f1c5c5e

Browse files
author
DavidQ
committed
Split Preview Generator V2 into external CSS and one-class-per-file control modules - PR_26126_035-preview-generator-v2-file-split-and-control-classes
1 parent 5785f0f commit f1c5c5e

26 files changed

Lines changed: 4203 additions & 3361 deletions

docs/dev/codex_commands.md

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,82 @@
1-
# Codex Commands - PR_26126_034-preview-generator-v2-cleanup-and-class-review
1+
# Codex Commands - PR_26126_035-preview-generator-v2-file-split-and-control-classes
22

33
```bash
4-
codex run "Create PR_26126_034-preview-generator-v2-cleanup-and-class-review. Fix Preview Generator V2 cleanup and structure. Remove legacy tools/preview/* completely. Keep tools/preview-generator-v2 as the active tool. Refactor Preview Generator V2 JavaScript away from one large script body. Use classes for major responsibilities: PreviewGeneratorV2App, PreviewGeneratorV2Ui, PreviewGeneratorV2Capture, PreviewGeneratorV2RepoAccess, PreviewGeneratorV2Logger. Preserve current working behavior exactly. Do not rewrite generation logic. Do not add schema. Do not modify samples. Produce review artifacts and include notes explaining class responsibilities."
4+
codex run "Create PR_26126_035-preview-generator-v2-file-split-and-control-classes. Fix Preview Generator V2 structure only. Preserve current working behavior exactly. Remove all inline style blocks and inline script blocks from tools/preview-generator-v2/index.html. Move CSS into external stylesheet files. Move JavaScript into external module files. Use one class per JavaScript file. Give each UI control/section its own class. Keep a small app/bootstrap entry file only for wiring classes together. Preserve existing IDs and DOM behavior unless a rename is required for correctness. Do not rewrite generation logic. Do not add schema. Do not modify samples. Do not modify start_of_day folders. Produce review artifacts and class ownership notes."
55
```
66

77
## Validation Commands
88

99
```powershell
10-
node --check tools/preview-generator-v2/previewGeneratorV2.js
10+
$files = Get-ChildItem -Path tools/preview-generator-v2 -Recurse -Filter *.js | Select-Object -ExpandProperty FullName
11+
foreach ($file in $files) {
12+
node --check $file
13+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
14+
}
1115
@'
1216
const fs = require('fs');
1317
const html = fs.readFileSync('tools/preview-generator-v2/index.html', 'utf8');
14-
const inlineScripts = [...html.matchAll(/<script(?![^>]*\bsrc=)[^>]*>([\s\S]*?)<\/script>/gi)].map((match) => match[1]);
15-
inlineScripts.forEach((script, index) => {
16-
new Function(script);
17-
console.log(`inline script ${index + 1} syntax ok`);
18-
});
18+
if (/<style\b/i.test(html) || /<\/style>/i.test(html)) throw new Error('Inline style block remains');
19+
const inlineScripts = [...html.matchAll(/<script(?![^>]*\bsrc=)[^>]*>/gi)];
20+
if (inlineScripts.length) throw new Error(`Inline script block remains: ${inlineScripts.length}`);
21+
if (!html.includes('./previewGeneratorV2.css')) throw new Error('External CSS link missing');
22+
if (!html.includes('./previewGeneratorV2.bootstrap.js')) throw new Error('Bootstrap module missing');
23+
console.log('index has no inline style/script blocks');
1924
'@ | node -
2025
@'
2126
const fs = require('fs');
22-
const js = fs.readFileSync('tools/preview-generator-v2/previewGeneratorV2.js', 'utf8');
23-
for (const name of ['PreviewGeneratorV2App','PreviewGeneratorV2Ui','PreviewGeneratorV2Capture','PreviewGeneratorV2RepoAccess','PreviewGeneratorV2Logger']) {
24-
if (!js.includes(`class ${name}`)) throw new Error(`Missing class ${name}`);
27+
const path = require('path');
28+
const root = 'tools/preview-generator-v2';
29+
const files = [];
30+
function walk(dir) {
31+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
32+
const full = path.join(dir, entry.name);
33+
if (entry.isDirectory()) walk(full);
34+
if (entry.isFile() && entry.name.endsWith('.js')) files.push(full);
35+
}
36+
}
37+
walk(root);
38+
for (const file of files) {
39+
const text = fs.readFileSync(file, 'utf8');
40+
const classes = [...text.matchAll(/\bclass\s+[A-Za-z0-9_]+/g)].map(match => match[0]);
41+
if (classes.length > 1) throw new Error(`${file} has more than one class: ${classes.join(', ')}`);
42+
}
43+
console.log('one class per js file check ok');
44+
'@ | node -
45+
@'
46+
const fs = require('fs');
47+
const path = require('path');
48+
const root = 'tools/preview-generator-v2';
49+
const files = [];
50+
function walk(dir) {
51+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
52+
const full = path.join(dir, entry.name);
53+
if (entry.isDirectory()) walk(full);
54+
if (entry.isFile() && entry.name.endsWith('.js')) files.push(full);
55+
}
56+
}
57+
walk(root);
58+
for (const file of files) {
59+
const text = fs.readFileSync(file, 'utf8');
60+
for (const match of text.matchAll(/from\s+["'](.+?)["']/g)) {
61+
const target = path.resolve(path.dirname(file), match[1]);
62+
if (!fs.existsSync(target)) throw new Error(`${file} imports missing ${match[1]}`);
63+
}
2564
}
26-
if (!js.includes('new PreviewGeneratorV2App().init();')) throw new Error('App init missing');
27-
console.log('required classes present');
65+
console.log('local module imports resolve');
2866
'@ | node -
29-
if (Test-Path tools/preview) { throw 'tools/preview still exists' } else { 'tools/preview removed' }
30-
$legacyMatches = rg -n "preview_svg_generator|tools/preview" tools src docs/design --glob '!docs/dev/reports/*'
31-
if ($LASTEXITCODE -eq 0) { $legacyMatches; throw 'Active legacy preview reference found' }
32-
if ($LASTEXITCODE -eq 1) { 'no active legacy preview references' }
33-
if ($LASTEXITCODE -gt 1) { exit $LASTEXITCODE }
34-
git diff --check -- tools/preview-generator-v2/index.html tools/preview-generator-v2/previewGeneratorV2.js docs/design/tools/TOOLS_REENGINEERING_INDEX.md docs/dev/codex_commands.md docs/dev/commit_comment.txt docs/dev/reports/preview_generator_v2_class_responsibilities.md docs/dev/reports/codex_review.diff docs/dev/reports/codex_changed_files.txt
67+
git status --short -- samples tools/schemas start_of_day
68+
git diff --check -- tools/preview-generator-v2 docs/dev/codex_commands.md docs/dev/commit_comment.txt docs/dev/reports/preview_generator_v2_class_responsibilities.md docs/dev/reports/codex_review.diff docs/dev/reports/codex_changed_files.txt
3569
npm run test:workspace-v2
3670
```
3771

3872
## Playwright
3973

40-
No new Playwright test was added. This PR restructures Preview Generator V2 JavaScript and removes the legacy preview folder while preserving the existing Preview Generator V2 UI and behavior. `npm run test:workspace-v2` is attempted as the standard command if available.
74+
No new Playwright test was added. This PR is a file split and class ownership cleanup for Preview Generator V2 only; existing behavior is intended to remain unchanged. `npm run test:workspace-v2` is attempted as the standard command if available.
4175

4276
## Test Notes
4377

4478
`npm run test:workspace-v2` is not defined in the current `package.json`.
4579

4680
## Manual Test
4781

48-
Open Preview Generator V2 from the tool registry. Confirm the tool loads, the repo picker/generate gating/log clear/stop controls still behave as before, and the Last Generated Image and Paths accordion layout from the previous PRs remains intact.
82+
Open Preview Generator V2 and confirm the page loads with the same layout and controls. Pick a repo, verify Generate Preview gating, run a small known path, use Stop/Clear, and confirm Last Generated Image and Output Summary update as before.

docs/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Remove legacy preview tool and class-structure Preview Generator V2 runtime - PR_26126_034-preview-generator-v2-cleanup-and-class-review
1+
Split Preview Generator V2 files and add per-section control classes - PR_26126_035-preview-generator-v2-file-split-and-control-classes
Lines changed: 101 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,111 @@
11
# Full git status --short
2-
M docs/design/tools/TOOLS_REENGINEERING_INDEX.md
32
M docs/dev/codex_commands.md
43
M docs/dev/commit_comment.txt
4+
M docs/dev/reports/codex_changed_files.txt
55
M docs/dev/reports/codex_review.diff
6+
M docs/dev/reports/preview_generator_v2_class_responsibilities.md
67
M tools/preview-generator-v2/index.html
7-
D tools/preview.zip
8-
D tools/preview/preview_svg_generator.html
9-
?? docs/dev/reports/preview_generator_v2_class_responsibilities.md
10-
?? tools/preview-generator-v2/previewGeneratorV2.js
11-
12-
# PR scoped git diff --cached --stat
8+
D tools/preview-generator-v2/previewGeneratorV2.js
9+
?? tools/preview-generator-v2/PreviewGeneratorV2App.js
10+
?? tools/preview-generator-v2/PreviewGeneratorV2Capture.js
11+
?? tools/preview-generator-v2/PreviewGeneratorV2Logger.js
12+
?? tools/preview-generator-v2/PreviewGeneratorV2RepoAccess.js
13+
?? tools/preview-generator-v2/PreviewGeneratorV2ShellControl.js
14+
?? tools/preview-generator-v2/PreviewGeneratorV2Ui.js
15+
?? tools/preview-generator-v2/controls/
16+
?? tools/preview-generator-v2/previewGeneratorV2.bootstrap.js
17+
?? tools/preview-generator-v2/previewGeneratorV2.css
1318

1419
# PR scoped git diff --stat
15-
docs/design/tools/TOOLS_REENGINEERING_INDEX.md | 1 -
16-
docs/dev/codex_commands.md | 47 +-
17-
docs/dev/commit_comment.txt | 2 +-
18-
tools/preview-generator-v2/index.html | 1238 +-----------------------
19-
tools/preview.zip | Bin 19111 -> 0 bytes
20-
tools/preview/preview_svg_generator.html | 1042 --------------------
21-
6 files changed, 24 insertions(+), 2306 deletions(-)
22-
23-
# New file diff stat: tools/preview-generator-v2/previewGeneratorV2.js
24-
.../preview-generator-v2/previewGeneratorV2.js | 1317 ++++++++++++++++++++
25-
1 file changed, 1317 insertions(+)
26-
27-
# New file diff stat: docs/dev/reports/preview_generator_v2_class_responsibilities.md
28-
.../reports/preview_generator_v2_class_responsibilities.md | 11 +++++++++++
20+
docs/dev/codex_commands.md | 76 +-
21+
docs/dev/commit_comment.txt | 2 +-
22+
.../preview_generator_v2_class_responsibilities.md | 35 +-
23+
tools/preview-generator-v2/index.html | 476 +------
24+
tools/preview-generator-v2/previewGeneratorV2.js | 1317 --------------------
25+
5 files changed, 85 insertions(+), 1821 deletions(-)
26+
27+
# New file diff stat: tools/preview-generator-v2/previewGeneratorV2.css
28+
.../preview-generator-v2/previewGeneratorV2.css | 338 +++++++++++++++++++++
29+
1 file changed, 338 insertions(+)
30+
31+
# New file diff stat: tools/preview-generator-v2/previewGeneratorV2.bootstrap.js
32+
.../preview-generator-v2/previewGeneratorV2.bootstrap.js | 5 +++++
33+
1 file changed, 5 insertions(+)
34+
35+
# New file diff stat: tools/preview-generator-v2/PreviewGeneratorV2App.js
36+
.../preview-generator-v2/PreviewGeneratorV2App.js | 1200 ++++++++++++++++++++
37+
1 file changed, 1200 insertions(+)
38+
39+
# New file diff stat: tools/preview-generator-v2/PreviewGeneratorV2Capture.js
40+
.../PreviewGeneratorV2Capture.js | 27 ++++++++++++++++++++++
41+
1 file changed, 27 insertions(+)
42+
43+
# New file diff stat: tools/preview-generator-v2/PreviewGeneratorV2Logger.js
44+
.../PreviewGeneratorV2Logger.js | 24 ++++++++++++++++++++++
45+
1 file changed, 24 insertions(+)
46+
47+
# New file diff stat: tools/preview-generator-v2/PreviewGeneratorV2RepoAccess.js
48+
.../PreviewGeneratorV2RepoAccess.js | 25 ++++++++++++++++++++++
49+
1 file changed, 25 insertions(+)
50+
51+
# New file diff stat: tools/preview-generator-v2/PreviewGeneratorV2ShellControl.js
52+
.../PreviewGeneratorV2ShellControl.js | 136 +++++++++++++++++++++
53+
1 file changed, 136 insertions(+)
54+
55+
# New file diff stat: tools/preview-generator-v2/PreviewGeneratorV2Ui.js
56+
.../preview-generator-v2/PreviewGeneratorV2Ui.js | 84 ++++++++++++++++++++++
57+
1 file changed, 84 insertions(+)
58+
59+
# New file diff stat: tools/preview-generator-v2/controls/AssetFolderControl.js
60+
.../controls/AssetFolderControl.js | 19 +++++++++++++++++++
61+
1 file changed, 19 insertions(+)
62+
63+
# New file diff stat: tools/preview-generator-v2/controls/CaptureModeControl.js
64+
.../controls/CaptureModeControl.js | 28 ++++++++++++++++++++++
65+
1 file changed, 28 insertions(+)
66+
67+
# New file diff stat: tools/preview-generator-v2/controls/LastGeneratedImageControl.js
68+
.../controls/LastGeneratedImageControl.js | 29 ++++++++++++++++++++++
69+
1 file changed, 29 insertions(+)
70+
71+
# New file diff stat: tools/preview-generator-v2/controls/MenuSampleControl.js
72+
.../controls/MenuSampleControl.js | 25 ++++++++++++++++++++++
73+
1 file changed, 25 insertions(+)
74+
75+
# New file diff stat: tools/preview-generator-v2/controls/OutputSummaryControl.js
76+
.../controls/OutputSummaryControl.js | 16 ++++++++++++++++
77+
1 file changed, 16 insertions(+)
78+
79+
# New file diff stat: tools/preview-generator-v2/controls/PathsOrIdsControl.js
80+
.../preview-generator-v2/controls/PathsOrIdsControl.js | 15 +++++++++++++++
81+
1 file changed, 15 insertions(+)
82+
83+
# New file diff stat: tools/preview-generator-v2/controls/PreviewFrameControl.js
84+
.../preview-generator-v2/controls/PreviewFrameControl.js | 11 +++++++++++
2985
1 file changed, 11 insertions(+)
3086

87+
# New file diff stat: tools/preview-generator-v2/controls/RenderControlsControl.js
88+
.../controls/RenderControlsControl.js | 20 ++++++++++++++++++++
89+
1 file changed, 20 insertions(+)
90+
91+
# New file diff stat: tools/preview-generator-v2/controls/RepoDestinationControl.js
92+
.../controls/RepoDestinationControl.js | 17 +++++++++++++++++
93+
1 file changed, 17 insertions(+)
94+
95+
# New file diff stat: tools/preview-generator-v2/controls/StatusControl.js
96+
.../preview-generator-v2/controls/StatusControl.js | 13 +++++++++++++
97+
1 file changed, 13 insertions(+)
98+
99+
# New file diff stat: tools/preview-generator-v2/controls/TargetSourceControl.js
100+
.../controls/TargetSourceControl.js | 35 ++++++++++++++++++++++
101+
1 file changed, 35 insertions(+)
102+
31103
# Full git diff --stat
32-
docs/design/tools/TOOLS_REENGINEERING_INDEX.md | 1 -
33-
docs/dev/codex_commands.md | 47 +-
34-
docs/dev/commit_comment.txt | 2 +-
35-
docs/dev/reports/codex_review.diff | 3958 ++++++++++++++++++++++--
36-
tools/preview-generator-v2/index.html | 1238 +-------
37-
tools/preview.zip | Bin 19111 -> 0 bytes
38-
tools/preview/preview_svg_generator.html | 1042 -------
39-
7 files changed, 3728 insertions(+), 2560 deletions(-)
104+
docs/dev/codex_commands.md | 76 +-
105+
docs/dev/commit_comment.txt | 2 +-
106+
docs/dev/reports/codex_changed_files.txt | 128 +-
107+
docs/dev/reports/codex_review.diff | 5734 +++++++++++---------
108+
.../preview_generator_v2_class_responsibilities.md | 35 +-
109+
tools/preview-generator-v2/index.html | 476 +-
110+
tools/preview-generator-v2/previewGeneratorV2.js | 1317 -----
111+
7 files changed, 3276 insertions(+), 4492 deletions(-)

0 commit comments

Comments
 (0)