Skip to content

Commit f29ce36

Browse files
committed
Merge branch 'origin/main' (prioritizing local UI and audit fixes)
2 parents d50bc48 + 9e5fb6a commit f29ce36

4 files changed

Lines changed: 80 additions & 15 deletions

File tree

scripts/agentic_review.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ def run_ai_review(commands, assertions=None):
9494
print("Performing metadata verification...")
9595
metadata_pass = verify_metadata(metadata_path, assertions)
9696

97+
# Semantic Review (Collision Detection)
98+
print("Performing semantic UI review...")
99+
from semantic_review import semantic_review
100+
semantic_pass = semantic_review(metadata_path)
101+
97102
# Visual Regression Check
98103
baseline_path = "review/baseline.png"
99104
visual_pass = True
@@ -113,7 +118,7 @@ def run_ai_review(commands, assertions=None):
113118
if os.path.exists(metadata_path):
114119
shutil.copy(metadata_path, "review/screenshot.json")
115120

116-
return metadata_pass and visual_pass
121+
return metadata_pass and semantic_pass and visual_pass
117122

118123
print("Review failed! Screenshot not found.")
119124
return False

scripts/button_state_audit.py

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,57 @@ def compare_button_states(idle_path, hover_path):
77
print("Missing screenshots for comparison.")
88
return False
99

10+
idle_meta = idle_path.replace(".png", ".json")
11+
hover_meta = hover_path.replace(".png", ".json")
12+
13+
if not os.path.exists(idle_meta) or not os.path.exists(hover_meta):
14+
print("Missing metadata for comparison.")
15+
return False
16+
17+
with open(idle_meta, "r") as f: m1 = json.load(f)
18+
with open(hover_meta, "r") as f: m2 = json.load(f)
19+
1020
img1 = Image.open(idle_path).convert('RGB')
1121
img2 = Image.open(hover_path).convert('RGB')
1222

13-
# Calculate average brightness
14-
avg1 = np.mean(np.array(img1))
15-
avg2 = np.mean(np.array(img2))
23+
# Identify the button that changed (the one being hovered)
24+
# For now, we compare all buttons and find the one with the most change
25+
# or look for a specific button if provided.
26+
27+
print(f"Button State Audit (Metadata-Aware):")
1628

17-
print(f"Button State Audit:")
18-
print(f" Idle Brightness: {avg1:.2f}")
19-
print(f" Hover Brightness: {avg2:.2f}")
29+
max_diff = -1
30+
best_btn = None
2031

21-
# Hover should generally be brighter in our theme
22-
if avg2 > avg1:
23-
print(f" [SUCCESS] Hover state detected (Brightness increased by {avg2-avg1:.2f})")
24-
return True
32+
for b in m1.get("Buttons", []):
33+
bounds = b['Bounds']
34+
box = (bounds['X'], bounds['Y'], bounds['X'] + bounds['Width'], bounds['Y'] + bounds['Height'])
35+
36+
# Crop button area
37+
crop1 = img1.crop(box)
38+
crop2 = img2.crop(box)
39+
40+
avg1 = np.mean(np.array(crop1))
41+
avg2 = np.mean(np.array(crop2))
42+
diff = abs(avg2 - avg1)
43+
44+
if diff > max_diff:
45+
max_diff = diff
46+
best_btn = (b['Text'], avg1, avg2)
47+
48+
if best_btn and max_diff > 5: # Threshold for hover effect
49+
print(f" Detected hover effect on '{best_btn[0]}':")
50+
print(f" Idle Brightness: {best_btn[1]:.2f}")
51+
print(f" Hover Brightness: {best_btn[2]:.2f}")
52+
53+
if best_btn[2] > best_btn[1]:
54+
print(f" [SUCCESS] Hover state detected (Brightness increased by {max_diff:.2f})")
55+
return True
56+
else:
57+
print(f" [FAIL] Hover state did not increase brightness.")
58+
return False
2559
else:
26-
print(f" [FAIL] No visual change detected between Idle and Hover states.")
60+
print(f" [FAIL] No significant visual change detected in any button bounding box.")
2761
return False
2862

2963
if __name__ == "__main__":

scripts/update_screenshots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"manifest:speck_of_matter",
2424
"update:10.0",
2525
"tab:Spire",
26-
"wait:1.0",
26+
"update:1.0",
2727
"screenshot:spire_flow"
2828
],
2929
"world_map": [
@@ -32,7 +32,7 @@
3232
"manifest:familiar",
3333
"update:5.0",
3434
"tab:World",
35-
"wait:1.0",
35+
"update:1.0",
3636
"screenshot:world_map"
3737
],
3838
"mixing_table": [
@@ -41,7 +41,7 @@
4141
"manifest:forge",
4242
"update:5.0",
4343
"tab:Spire",
44-
"wait:1.0",
44+
"update:1.0",
4545
"screenshot:mixing_table"
4646
]
4747
}

test_collision.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"ScreenWidth": 1024,
3+
"ScreenHeight": 768,
4+
"Buttons": [
5+
{
6+
"Text": "Test1",
7+
"Bounds": { "X": 100, "Y": 100, "Width": 50, "Height": 50 },
8+
"Tab": "Void"
9+
},
10+
{
11+
"Text": "Test2",
12+
"Bounds": { "X": 120, "Y": 120, "Width": 50, "Height": 50 },
13+
"Tab": "Void"
14+
},
15+
{
16+
"Text": "OffScreen",
17+
"Bounds": { "X": 1100, "Y": 100, "Width": 50, "Height": 50 },
18+
"Tab": "Void"
19+
},
20+
{
21+
"Text": "PanelCollision",
22+
"Bounds": { "X": 20, "Y": 60, "Width": 50, "Height": 50 },
23+
"Tab": "Void"
24+
}
25+
]
26+
}

0 commit comments

Comments
 (0)