-
Notifications
You must be signed in to change notification settings - Fork 1
feat: responsive viewport comparison in calibration (#182) #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
7ad1baf
62b987c
2289bf8
e643b4d
e07df6d
8b3934b
3f9548c
71583f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,25 @@ Read and follow `.claude/skills/design-to-code/PROMPT.md` for all code generatio | |
| ``` | ||
| This saves `figma.png`, `code.png`, and `diff.png` into the run directory. | ||
| Replace `:` with `-` in the nodeId for the URL. | ||
| 5. Use similarity to determine overall difficulty (thresholds defined in `src/agents/orchestrator.ts` → `SIMILARITY_DIFFICULTY_THRESHOLDS`): | ||
| 5. **Responsive comparison** (if expanded screenshot exists): | ||
|
|
||
| Look for `screenshot-*.png` in the fixture directory. Sort by width (number in filename). | ||
| If there are 2+ screenshots, the smallest is the original and the largest is the expanded viewport. | ||
|
|
||
| ```bash | ||
| # Find expanded screenshot | ||
| ls <fixture-path>/screenshot-*.png | sort -t- -k2 -n | ||
| # Run responsive visual-compare with --figma-screenshot and --width | ||
| npx canicode visual-compare $RUN_DIR/output.html \ | ||
| --figma-url "https://www.figma.com/design/<fileKey>/file?node-id=<rootNodeId>" \ | ||
| --figma-screenshot <fixture-path>/screenshot-<largest>.png \ | ||
| --width <largest-width> \ | ||
| --output $RUN_DIR/responsive | ||
| ``` | ||
|
|
||
| Record `responsiveSimilarity` from the result and calculate `responsiveDelta = similarity - responsiveSimilarity`. | ||
| If only 1 screenshot exists, skip responsive comparison and set both to `null`. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| 6. Use similarity to determine overall difficulty (thresholds defined in `src/agents/orchestrator.ts` → `SIMILARITY_DIFFICULTY_THRESHOLDS`): | ||
|
|
||
| | Similarity | Difficulty | | ||
| |-----------|-----------| | ||
|
|
@@ -69,11 +87,16 @@ Read and follow `.claude/skills/design-to-code/PROMPT.md` for all code generatio | |
| | 50-69% | hard | | ||
| | <50% | failed | | ||
|
|
||
| 6. **MANDATORY — Rule Impact Assessment**: For EVERY rule ID in `nodeIssueSummaries[].flaggedRuleIds`, assess its actual impact on conversion. Read the analysis JSON, collect all unique `flaggedRuleIds`, and for each one write an entry in `ruleImpactAssessment`. This array MUST NOT be empty if there are flagged rules. | ||
| 7. **MANDATORY — Rule Impact Assessment**: For EVERY rule ID in `nodeIssueSummaries[].flaggedRuleIds`, assess its actual impact on conversion. Read the analysis JSON, collect all unique `flaggedRuleIds`, and for each one write an entry in `ruleImpactAssessment`. This array MUST NOT be empty if there are flagged rules. | ||
| - Did this rule's issue actually make the conversion harder? | ||
| - What was its real impact on the final similarity score? | ||
| - Rate as: `easy` (no real difficulty), `moderate` (some guessing needed), `hard` (significant pixel loss), `failed` (could not reproduce) | ||
| 7. Note any difficulties NOT covered by existing rules as `uncoveredStruggles` | ||
| 8. **Code metrics**: After writing `output.html`, record these in conversion.json: | ||
| - `htmlBytes`: file size in bytes | ||
| - `htmlLines`: line count | ||
| - `cssClassCount`: unique CSS class selectors in `<style>` block | ||
| - `cssVariableCount`: unique CSS custom properties (`--*:`) in `<style>` block | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| 9. Note any difficulties NOT covered by existing rules as `uncoveredStruggles` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify that code metrics and responsive fields (except responsiveDelta) are not consumed
rg -n --type=ts -C3 'htmlBytes|htmlLines|cssClassCount|cssVariableCount|responsiveSimilarity|responsiveViewport' \
-g '!*.test.ts' \
-g '!*.md'Repository: let-sunny/canicode Length of output: 5457 🏁 Script executed: # Check orchestrator.ts at the referenced lines to see what fields are extracted
find . -name "orchestrator.ts" -type f | head -5Repository: let-sunny/canicode Length of output: 90 🏁 Script executed: # Also search for calibration converter implementation and how it's used
rg -l "calibration.*converter" --type=ts -g '!*.test.ts'Repository: let-sunny/canicode Length of output: 44 🏁 Script executed: # Check what the converter agent actually does with these metrics
rg -n "conversion\.json" --type=ts -C2 -g '!*.test.ts' | head -50Repository: let-sunny/canicode Length of output: 2245 🏁 Script executed: # Check orchestrator.ts at the referenced lines
sed -n '300,330p' src/agents/orchestrator.tsRepository: let-sunny/canicode Length of output: 866 🏁 Script executed: # Check calibrate-debate.ts to see what fields it extracts from conversion.json
sed -n '28,80p' src/cli/commands/internal/calibrate-debate.tsRepository: let-sunny/canicode Length of output: 2013 🏁 Script executed: # Also search for where these metrics (htmlBytes, htmlLines, etc.) are used after being read
rg -n "ruleImpactAssessment|uncoveredStruggles|conversion" src/cli/commands/internal/calibrate-debate.ts -A3 -B3Repository: let-sunny/canicode Length of output: 1700 🏁 Script executed: # Read the converter.md file mentioned in the review
cat .claude/agents/calibration/converter.md | head -150Repository: let-sunny/canicode Length of output: 6743 🏁 Script executed: # Search for actual converter agent implementation or execution
rg -l "converter" src/agents --type=ts -g '!*.test.ts' | head -10Repository: let-sunny/canicode Length of output: 94 🏁 Script executed: # Look for where conversion.json is written to understand the schema
rg -n "conversion.json" src --type=ts -B5 -A5 | grep -A20 "writeFileSync.*conversion"Repository: let-sunny/canicode Length of output: 1761 🏁 Script executed: # Verify responsiveSimilarity and responsiveViewport are extracted
rg -n "responsiveSimilarity|responsiveViewport" src/agents/orchestrator.ts -B2 -A2Repository: let-sunny/canicode Length of output: 44 🏁 Script executed: # Double-check evaluation-agent contract for these fields
grep -A30 "responsiveSimilarity\|responsiveViewport" src/agents/contracts/evaluation-agent.tsRepository: let-sunny/canicode Length of output: 451 🏁 Script executed: # Check for all responsive-related field usage in orchestrator
rg -n "responsive" src/agents/orchestrator.ts -iRepository: let-sunny/canicode Length of output: 281 🏁 Script executed: # Check if responsiveViewport appears anywhere in codebase
rg -n "responsiveViewport" src --type=tsRepository: let-sunny/canicode Length of output: 44 🏁 Script executed: # Check the full conversion.json schema comment in converter.md to see all fields
sed -n '114,155p' .claude/agents/calibration/converter.mdRepository: let-sunny/canicode Length of output: 1380 Remove or use code metrics fields documented in step 8. The instructions direct the converter agent to collect Either remove these fields from the documentation or integrate them into the evaluation pipeline if they serve a future purpose. 🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 94-94: Ordered list item prefix (MD029, ol-prefix) [warning] 99-99: Ordered list item prefix (MD029, ol-prefix) 🤖 Prompt for AI Agents |
||
| - **Only include design-related issues** — problems in the Figma file structure, missing tokens, ambiguous layout, etc. | ||
| - **Exclude environment/tooling issues** — font CDN availability, screenshot DPI/retina scaling, browser rendering quirks, network issues, CI limitations. These are not design problems and create noise in rule discovery. | ||
|
|
||
|
|
@@ -88,6 +111,13 @@ Write results to `$RUN_DIR/conversion.json`. | |
| "rootNodeId": "562:9069", | ||
| "generatedCode": "// The full HTML page", | ||
| "similarity": 87, | ||
| "responsiveSimilarity": 72, | ||
| "responsiveDelta": 15, | ||
| "responsiveViewport": 1920, | ||
| "htmlBytes": 42000, | ||
| "htmlLines": 850, | ||
| "cssClassCount": 45, | ||
| "cssVariableCount": 12, | ||
| "difficulty": "moderate", | ||
| "notes": "Summary of the conversion experience", | ||
| "ruleImpactAssessment": [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.