Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,12 @@
body.results-fullscreen .results-header-left h2 { font-size: 22px; }
body.results-fullscreen .results-action-bar { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
body.results-fullscreen .sidebar,
body.results-fullscreen.results-with-sidebar .sidebar {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.results-view *,
.results-view *::before,
Expand Down
12 changes: 12 additions & 0 deletions src/resultsLayout.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";

const html = readFileSync(new URL("../index.html", import.meta.url), "utf8");

test("hides the prompt sidebar above mobile Results", () => {
assert.match(
html,
/@media \(max-width: 768px\)[\s\S]*?body\.results-fullscreen \.sidebar,[\s\S]*?body\.results-fullscreen\.results-with-sidebar \.sidebar \{\s*display: none;/,
);
});
18 changes: 10 additions & 8 deletions src/reviewPresentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,16 @@ export function buildReviewPresentation({ bundle, reviewResult }) {
const safeBundle = toObject(bundle);
const artifacts = asArray(safeBundle.artifacts);
const { root, rawText } = unwrapReviewPayload(reviewResult);
const overallReview = toObject(
root.bundleReview
|| root.overallReview
|| root.overall
|| root.bundleSummary
|| root.summaryReview
|| root.review,
);
const overallReview = [
root.bundleReview,
root.overallReview,
root.overall,
root.bundleSummary,
root.summaryReview,
root.review,
]
.map(toObject)
.find((candidate) => Object.keys(candidate).length) || {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Malformed objects block valid reviews

When bundleReview is a non-empty malformed object such as { metadata: {} }, this predicate selects it solely because it has a key and never reaches a valid overallReview, causing the valid score, summary, and findings to be omitted or replaced with fallback presentation values.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/reviewPresentation.js
Line: 274

Comment:
**Malformed objects block valid reviews**

When `bundleReview` is a non-empty malformed object such as `{ metadata: {} }`, this predicate selects it solely because it has a key and never reaches a valid `overallReview`, causing the valid score, summary, and findings to be omitted or replaced with fallback presentation values.

How can I resolve this? If you propose a fix, please make it concise.

const reviewArtifacts = asArray(root.artifacts || root.files || root.reviews);
const artifactPresentations = artifacts.map((artifact, index) => (
buildArtifactPresentation(safeBundle, reviewArtifacts, artifact, index)
Expand Down
27 changes: 27 additions & 0 deletions src/reviewPresentation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,30 @@ test("preserves top-level artifact reviews alongside bundleReview", () => {
assert.equal(presentation.reviewCoverage.reviewed, 2);
assert.equal(presentation.artifacts[0].findings[0].severity, "pass");
});

test("falls back from malformed bundleReview to a valid overallReview", () => {
for (const bundleReview of [{}, "not a review object"]) {
const presentation = buildReviewPresentation({
bundle,
reviewResult: {
bundleReview,
overallReview: {
status: "pass",
score: 94,
summary: "The valid overall review was preserved.",
findings: [
{
severity: "info",
message: "The bundle structure is valid.",
},
],
},
artifacts: [],
},
});

assert.equal(presentation.score, 94);
assert.equal(presentation.summary, "The valid overall review was preserved.");
assert.equal(presentation.findings[0].message, "The bundle structure is valid.");
}
});