Skip to content

Commit 23e81c3

Browse files
committed
Delete uploaded asset files and calculate progress from server-received bytes - PR_26163_080-assets-delete-file-and-received-progress
1 parent 0a032dc commit 23e81c3

38 files changed

Lines changed: 4571 additions & 761 deletions
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# PR_26163_080-assets-delete-file-and-received-progress
2+
3+
## Branch Validation
4+
5+
- Current branch: `main`
6+
- Expected branch: `main`
7+
- Branch validation: PASS
8+
9+
## Scope
10+
11+
- Impacted lane: Assets tool runtime lane, Assets dev/mock repository lane, Assets Playwright behavior coverage.
12+
- Playwright impacted: Yes.
13+
- Samples validation: SKIP. Samples are out of scope for this Assets upload/delete tool fix and no sample JSON/runtime behavior was changed.
14+
- Full samples smoke: SKIP for the same reason.
15+
16+
## Requirement Checklist
17+
18+
- PASS: Trash for uploaded assets deletes the asset DB record and physical file. Evidence: targeted Playwright `Assets Trash deletes uploaded records and physical files with scoped failure handling` verifies the row is removed and `projects/01K8M3K0EX7V5A3W9Q2Y6R4T1B/image/trash-delete-ok.png` no longer exists.
19+
- PASS: Trash verifies the physical file no longer exists before reporting deleted. Evidence: repository delete returns success only after `existsSync` is false after `unlinkSync`; Playwright verifies the file is gone.
20+
- PASS: Trash failure shows FAIL and does not claim deleted. Evidence: targeted Playwright removes the physical file before Trash, expects visible `FAIL: Upload file delete failed`, and verifies the asset row remains.
21+
- PASS: Delete paths are scoped only under `/projects/`. Evidence: repository delete resolves stored project-relative paths through the existing `/projects/<projectId>/` guard.
22+
- PASS: Outside `/projects/` delete is rejected. Evidence: targeted Playwright uses the dev-only unsafe delete-path hook and verifies visible `FAIL: Upload file delete failed: target path must stay under /projects/<projectId>/` with the row and real project file preserved.
23+
- PASS: Progress percent equals server-received bytes divided by total file bytes. Evidence: `toolbox/assets/assets.js` progress metrics use `serverBytesReceived`; targeted Playwright records 8 B -> 16% and 16 B -> 33% for a 48 B upload.
24+
- PASS: Progress does not reach 100% until server-received bytes cover the file and write succeeds. Evidence: server receive stops at `fileSize - 1` before repository write; targeted Playwright verifies progress remains below 100 before completion and reaches 100 only after the OK row/write success.
25+
- PASS: Upload progress UI updates once per second while active. Evidence: targeted Playwright records two server-received progress events and verifies their timestamps are at least 900 ms apart for the one-second cadence.
26+
- PASS: BPS, speed, ETA, elapsed, and percent use server-received byte counts. Evidence: `uploadProgressMetrics` computes from `serverBytesReceived`; targeted Playwright verifies BPS > 0, speed `/s`, ETA, elapsed, and server-received bytes.
27+
- PASS: Browser/client bytes sent differs from server bytes received behavior is authoritative to server received. Evidence: worker progress updates `clientBytesSent` only and does not drive the meter; the visible meter uses `serverBytesReceived`.
28+
- PASS: Worker/background upload path remains. Evidence: targeted Playwright observes the `toolbox/assets/assets-upload-worker.js` worker and verifies accordion/scroll responsiveness during upload.
29+
- PASS: Duplicate folder/filename blocking remains. Evidence: targeted Playwright `Assets duplicate project-path uploads fail before write and do not create duplicate records` passes.
30+
- PASS: Inline upload progress remains under the relevant asset table. Evidence: existing targeted Playwright asserts inline progress appears below the Images table.
31+
- PASS: `codex_review.diff` is UTF-8 readable. Evidence: artifact writer uses UTF-8; targeted Playwright UTF-8 artifact check passed.
32+
33+
## Delete-File Evidence
34+
35+
- Success path: uploaded `trash-delete-ok.png`, clicked Trash, visible log included `Deleted file projects/01K8M3K0EX7V5A3W9Q2Y6R4T1B/image/trash-delete-ok.png.`, asset row count became zero, and the file no longer existed on disk.
36+
- Missing-file failure path: uploaded `trash-delete-missing.png`, removed the physical file, clicked Trash, visible log included `FAIL: Upload file delete failed`, and the asset row remained.
37+
- Unsafe path failure path: dev-only unsafe delete hook resolved an escaping path, clicked Trash, visible log rejected the path under `/projects/<projectId>/`, and the real stored project file remained.
38+
39+
## Server-Received Progress Evidence
40+
41+
- Progress source: `serverBytesReceived` is the only visible meter source; worker/client progress only records `clientBytesSent`.
42+
- One-second cadence: Playwright observed server-received progress events 8 B and 16 B at least 900 ms apart.
43+
- Percent evidence: 8 B / 48 B rendered 16%; 16 B / 48 B rendered 33%; final 100% rendered after write success.
44+
- Responsiveness evidence: Playwright toggled another accordion and scrolled during active upload while progress continued.
45+
46+
## Validation Performed
47+
48+
- PASS: `node --check toolbox/assets/assets.js`
49+
- PASS: `node --check toolbox/assets/assets-upload-worker.js`
50+
- PASS: `node --check src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js`
51+
- PASS: `node --check tests/playwright/tools/AssetToolMockRepository.spec.mjs`
52+
- PASS: `git diff --check -- toolbox/assets/assets.js toolbox/assets/index.html src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js tests/playwright/tools/AssetToolMockRepository.spec.mjs`
53+
- PASS: `npx playwright test tests/playwright/tools/AssetToolMockRepository.spec.mjs --workers=1 --reporter=list` -> 15 passed.
54+
- PASS: `npm run test:workspace-v2` -> workspace-contract lane 5 passed.
55+
- PASS: final targeted rerun `npx playwright test tests/playwright/tools/AssetToolMockRepository.spec.mjs --workers=1 --reporter=list` -> 15 passed.
56+
57+
## Playwright Result
58+
59+
- PASS: Assets targeted Playwright: 15 passed.
60+
- PASS: Workspace V2 command: 5 passed in workspace-contract lane.
61+
62+
## Coverage
63+
64+
- Coverage report: `docs_build/dev/reports/playwright_v8_coverage_report.txt`
65+
- PASS/WARN: PASS for generated coverage report. WARN is expected/advisory for changed server-side dev repository and worker files not collected by browser V8 coverage.
66+
- Changed runtime JavaScript coverage highlights:
67+
- `(93%) toolbox/assets/assets.js`
68+
- `(0%) src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js` WARN, server/dev repository not collected by browser V8 coverage.
69+
- `(0%) toolbox/assets/assets-upload-worker.js` WARN, worker coverage not collected by the current V8 reporter.
70+
71+
## Changed Files
72+
73+
- `toolbox/assets/assets.js`
74+
- `toolbox/assets/index.html`
75+
- `src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js`
76+
- `tests/playwright/tools/AssetToolMockRepository.spec.mjs`
77+
- `docs_build/dev/reports/playwright_v8_coverage_report.txt`
78+
- Workspace validation report files refreshed by the required `npm run test:workspace-v2` command.
79+
- Required review artifacts generated separately:
80+
- `docs_build/dev/reports/codex_review.diff`
81+
- `docs_build/dev/reports/codex_changed_files.txt`
82+
- Repo-structured delta ZIP:
83+
- `tmp/PR_26163_080-assets-delete-file-and-received-progress_delta.zip`
84+
85+
## Manual Validation Steps
86+
87+
1. Open `toolbox/assets/index.html` using Local DB mode with a signed-in user.
88+
2. Add an Image upload and verify the inline progress panel starts at 0 B received.
89+
3. Confirm the visible progress increments from server-received bytes at one-second intervals.
90+
4. Confirm the meter reaches 100% only after the upload row reports OK.
91+
5. Click Trash on the uploaded asset and confirm the DB row disappears and the stored `projects/<projectId>/image/<filename>` file is gone.
92+
6. Repeat with a missing physical file and confirm the UI shows FAIL and keeps the asset row.
93+
94+
## Skipped Lanes
95+
96+
- Samples: SKIP because no sample JSON, sample launch, or game runtime behavior was changed.
97+
- Engine lane: SKIP because no engine input/runtime code changed.
98+
- Auth/account lanes: SKIP because owner/session behavior was not changed.
Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,82 @@
11
# git status --short
2-
M docs_build/dev/reports/playwright_v8_coverage_report.txt
2+
M docs_build/dev/reports/codex_changed_files.txt
3+
M docs_build/dev/reports/codex_review.diff
4+
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
5+
M docs_build/dev/reports/dependency_gating_report.md
6+
M docs_build/dev/reports/dependency_hydration_reuse_report.md
7+
M docs_build/dev/reports/execution_graph_reuse_report.md
8+
M docs_build/dev/reports/failure_fingerprint_report.md
9+
M docs_build/dev/reports/filesystem_scan_reduction_report.md
10+
M docs_build/dev/reports/incremental_validation_report.md
11+
M docs_build/dev/reports/lane_compilation_report.md
12+
M docs_build/dev/reports/lane_deduplication_report.md
13+
M docs_build/dev/reports/lane_input_validation_report.md
14+
M docs_build/dev/reports/lane_manifests/workspace-contract.json
15+
M docs_build/dev/reports/lane_runtime_optimization_report.md
16+
M docs_build/dev/reports/lane_snapshot_report.md
17+
M docs_build/dev/reports/lane_snapshots/workspace-contract.json
18+
M docs_build/dev/reports/lane_warm_start_report.md
19+
M docs_build/dev/reports/lane_warm_starts/workspace-contract.json
20+
M docs_build/dev/reports/monolith_trigger_removal_report.md
21+
M docs_build/dev/reports/persistent_lane_manifest_report.md
22+
M docs_build/dev/reports/playwright_discovery_ownership_report.md
23+
M docs_build/dev/reports/playwright_discovery_scope_report.md
24+
M docs_build/dev/reports/playwright_structure_audit.md
25+
M docs_build/dev/reports/playwright_v8_coverage_report.txt
26+
M docs_build/dev/reports/retry_suppression_report.md
27+
M docs_build/dev/reports/slow_path_pruning_report.md
28+
M docs_build/dev/reports/static_validation_report.md
29+
M docs_build/dev/reports/targeted_file_manifest_report.md
30+
M docs_build/dev/reports/test_cleanup_performance_report.md
31+
M docs_build/dev/reports/test_cleanup_routing_report.md
32+
M docs_build/dev/reports/testing_lane_execution_report.md
33+
M docs_build/dev/reports/validation_cache_report.md
34+
M docs_build/dev/reports/zero_browser_preflight_report.md
35+
M src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js
336
M tests/playwright/tools/AssetToolMockRepository.spec.mjs
437
M toolbox/assets/assets.js
5-
?? docs_build/dev/reports/PR_26163_079-assets-byte-accurate-upload-progress.md
6-
?? toolbox/assets/assets-upload-worker.js
38+
M toolbox/assets/index.html
39+
?? docs_build/dev/reports/PR_26163_080-assets-delete-file-and-received-progress.md
740

841
# git ls-files --others --exclude-standard
9-
docs_build/dev/reports/PR_26163_079-assets-byte-accurate-upload-progress.md
10-
toolbox/assets/assets-upload-worker.js
42+
docs_build/dev/reports/PR_26163_080-assets-delete-file-and-received-progress.md
1143

1244
# git diff --stat
13-
.../dev/reports/playwright_v8_coverage_report.txt | 11 +-
14-
.../tools/AssetToolMockRepository.spec.mjs | 108 ++++++++++++++-
15-
toolbox/assets/assets.js | 149 +++++++++++++++++----
16-
3 files changed, 234 insertions(+), 34 deletions(-)
45+
docs_build/dev/reports/codex_changed_files.txt | 80 +-
46+
docs_build/dev/reports/codex_review.diff | 2088 +++++++++++++++-----
47+
.../dev/reports/coverage_changed_js_guardrail.txt | 15 +-
48+
docs_build/dev/reports/dependency_gating_report.md | 2 +-
49+
.../reports/dependency_hydration_reuse_report.md | 12 +-
50+
.../dev/reports/execution_graph_reuse_report.md | 16 +-
51+
.../dev/reports/failure_fingerprint_report.md | 2 +-
52+
.../reports/filesystem_scan_reduction_report.md | 2 +-
53+
.../dev/reports/incremental_validation_report.md | 14 +-
54+
docs_build/dev/reports/lane_compilation_report.md | 2 +-
55+
.../dev/reports/lane_deduplication_report.md | 2 +-
56+
.../dev/reports/lane_input_validation_report.md | 2 +-
57+
.../reports/lane_manifests/workspace-contract.json | 10 +-
58+
.../reports/lane_runtime_optimization_report.md | 14 +-
59+
docs_build/dev/reports/lane_snapshot_report.md | 12 +-
60+
.../reports/lane_snapshots/workspace-contract.json | 26 +-
61+
docs_build/dev/reports/lane_warm_start_report.md | 12 +-
62+
.../lane_warm_starts/workspace-contract.json | 18 +-
63+
.../dev/reports/monolith_trigger_removal_report.md | 2 +-
64+
.../dev/reports/persistent_lane_manifest_report.md | 12 +-
65+
.../playwright_discovery_ownership_report.md | 2 +-
66+
.../reports/playwright_discovery_scope_report.md | 2 +-
67+
.../dev/reports/playwright_structure_audit.md | 2 +-
68+
.../dev/reports/playwright_v8_coverage_report.txt | 6 +-
69+
docs_build/dev/reports/retry_suppression_report.md | 2 +-
70+
docs_build/dev/reports/slow_path_pruning_report.md | 16 +-
71+
docs_build/dev/reports/static_validation_report.md | 12 +-
72+
.../dev/reports/targeted_file_manifest_report.md | 8 +-
73+
.../dev/reports/test_cleanup_performance_report.md | 22 +-
74+
.../dev/reports/test_cleanup_routing_report.md | 2 +-
75+
.../dev/reports/testing_lane_execution_report.md | 52 +-
76+
docs_build/dev/reports/validation_cache_report.md | 30 +-
77+
.../dev/reports/zero_browser_preflight_report.md | 10 +-
78+
.../tool-repositories/assets-mock-repository.js | 126 +-
79+
.../tools/AssetToolMockRepository.spec.mjs | 153 +-
80+
toolbox/assets/assets.js | 94 +-
81+
toolbox/assets/index.html | 2 +-
82+
37 files changed, 2124 insertions(+), 760 deletions(-)

0 commit comments

Comments
 (0)