Skip to content

Commit 8a126dd

Browse files
author
GitLab CI
committed
chore: Release v0.5.2
Critical bug fixes for coordinate detection and JSON serialization - Fixed JSON serialization error in find_by_type - Improved TextField coordinate detection - Added coordinatesReliable flag for better targeting
1 parent 1436e29 commit 8a126dd

File tree

9 files changed

+133
-13
lines changed

9 files changed

+133
-13
lines changed

CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
## 0.5.2
2+
3+
**Critical bug fixes for coordinate detection and JSON serialization**
4+
5+
### 🐛 Bug Fixes (Critical)
6+
- 🔧 **Fixed JSON Serialization Error in find_by_type**: Added `safeRound()` helper to handle NaN/Infinity values
7+
- Previously crashed with "Unsupported object: NaN" or "Unsupported object: Infinity"
8+
- Now safely converts all coordinate values to finite integers
9+
- Consistent with `inspect()` implementation
10+
11+
- 📍 **Improved TextField Coordinate Detection**: Added reliability detection for widget coordinates
12+
- New `coordinatesReliable` flag on all elements
13+
- Detects when TextFields report false (0,0) coordinates
14+
- Provides warning message: "Coordinates may be unreliable - use key or text for targeting"
15+
- Helps AI agents know when to fall back to key/text-based targeting
16+
17+
### 🔧 Improvements
18+
- 📋 **Enhanced MCP Tool Descriptions**: Updated `inspect` and `find_by_type` documentation
19+
- Documents `coordinatesReliable` flag in output format
20+
- Warns about TextField coordinate issues
21+
- Guides AI agents to use keys when coordinates are unreliable
22+
23+
### 💡 Benefits
24+
- ✅ find_by_type no longer crashes on off-screen or animated widgets
25+
- ✅ AI agents can detect unreliable coordinates and adjust targeting strategy
26+
- ✅ Better error messages guide users to use keys instead of coordinates
27+
- ✅ More robust JSON serialization prevents crashes
28+
29+
### 📝 Migration Guide
30+
No breaking changes. New `coordinatesReliable` field is optional to check:
31+
32+
```dart
33+
// Check coordinate reliability before using coordinates
34+
final elements = await inspect();
35+
for (final element in elements) {
36+
if (element['coordinatesReliable'] == true) {
37+
// Safe to use bounds/center coordinates
38+
tap(x: element['center']['x'], y: element['center']['y']);
39+
} else {
40+
// Fall back to key/text targeting
41+
if (element['key'] != null) {
42+
tap(key: element['key']);
43+
}
44+
}
45+
}
46+
```
47+
48+
---
49+
150
## 0.5.1
251

352
**Major usability improvements for screenshots, errors, and logging**

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ flutter-skill launch /path/to/project
262262
1. Add dependency:
263263
```yaml
264264
dependencies:
265-
flutter_skill: ^0.5.1
265+
flutter_skill: ^0.5.2
266266
```
267267
268268
2. Initialize in main.dart:

intellij-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "com.aidashboad"
8-
version = "0.5.1"
8+
version = "0.5.2"
99

1010
repositories {
1111
mavenCentral()

intellij-plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin>
22
<id>com.aidashboad.flutterskill</id>
33
<name>Flutter Skill - AI App Automation</name>
4-
<version>0.5.1</version>
4+
<version>0.5.2</version>
55
<vendor email="support@ai-dashboad.com" url="https://github.com/ai-dashboad/flutter-skill">ai-dashboad</vendor>
66

77
<description><![CDATA[

lib/flutter_skill.dart

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,20 @@ class FlutterSkillBinding {
15071507
return value.round();
15081508
}
15091509

1510+
// Detect if coordinates are reliable (not (0,0) unless widget is actually at origin)
1511+
final isAtOrigin = offset.dx == 0 && offset.dy == 0;
1512+
final hasValidSize =
1513+
renderObject.size.width > 0 && renderObject.size.height > 0;
1514+
final isFinite = offset.dx.isFinite && offset.dy.isFinite;
1515+
1516+
// For TextFields, check if they're genuinely at origin or just not laid out
1517+
bool coordinatesReliable = isFinite && hasValidSize;
1518+
if (isAtOrigin && (widget is TextField || widget is TextFormField)) {
1519+
// TextField at (0,0) is suspicious - likely not fully laid out
1520+
// Check if there are other widgets to compare against
1521+
coordinatesReliable = false;
1522+
}
1523+
15101524
entry['bounds'] = {
15111525
'x': safeRound(offset.dx),
15121526
'y': safeRound(offset.dy),
@@ -1517,8 +1531,14 @@ class FlutterSkillBinding {
15171531
'x': safeRound(offset.dx + renderObject.size.width / 2),
15181532
'y': safeRound(offset.dy + renderObject.size.height / 2),
15191533
};
1520-
entry['visible'] =
1521-
renderObject.size.width > 0 && renderObject.size.height > 0;
1534+
entry['visible'] = hasValidSize;
1535+
entry['coordinatesReliable'] = coordinatesReliable;
1536+
1537+
// Add warning for unreliable coordinates
1538+
if (!coordinatesReliable && isAtOrigin) {
1539+
entry['warning'] =
1540+
'Coordinates may be unreliable - widget might not be fully laid out. Use key or text for targeting.';
1541+
}
15221542
}
15231543

15241544
results.add(entry);
@@ -1676,11 +1696,30 @@ class FlutterSkillBinding {
16761696
final renderObject = element.renderObject;
16771697
if (renderObject is RenderBox && renderObject.hasSize) {
16781698
final offset = renderObject.localToGlobal(Offset.zero);
1679-
node['position'] = {'x': offset.dx, 'y': offset.dy};
1699+
1700+
// Helper function to safely convert double to int, handling Infinity/NaN
1701+
int safeRound(double value) {
1702+
if (!value.isFinite) return 0;
1703+
return value.round();
1704+
}
1705+
1706+
// Use safeRound to prevent JSON serialization errors
1707+
node['position'] = {
1708+
'x': safeRound(offset.dx),
1709+
'y': safeRound(offset.dy)
1710+
};
16801711
node['size'] = {
1681-
'width': renderObject.size.width,
1682-
'height': renderObject.size.height
1712+
'width': safeRound(renderObject.size.width),
1713+
'height': safeRound(renderObject.size.height)
16831714
};
1715+
1716+
// Add coordinate reliability flag
1717+
final isReliable = offset.dx.isFinite &&
1718+
offset.dy.isFinite &&
1719+
(offset.dx != 0 || offset.dy != 0) &&
1720+
renderObject.size.width > 0 &&
1721+
renderObject.size.height > 0;
1722+
node['coordinatesReliable'] = isReliable;
16841723
}
16851724

16861725
results.add(node);

lib/src/cli/server.dart

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import '../flutter_skill_client.dart';
77
import '../diagnostics/error_reporter.dart';
88
import 'setup.dart';
99

10-
const String _currentVersion = '0.5.1';
10+
const String _currentVersion = '0.5.2';
1111

1212
/// Session information for multi-session support
1313
class SessionInfo {
@@ -503,6 +503,18 @@ Discover and list all interactive UI elements currently visible on screen (butto
503503
[WORKFLOW]
504504
Essential first step for any UI interaction. Returns element list with keys/texts for use with tap() and enter_text().
505505
506+
[OUTPUT FORMAT]
507+
Each element includes:
508+
• key: Element identifier for targeting
509+
• type: Widget type (Button, TextField, etc.)
510+
• bounds/center: Position coordinates
511+
• coordinatesReliable: Boolean flag indicating if coordinates are trustworthy
512+
• warning: Present if coordinates are unreliable (e.g., TextField at (0,0))
513+
514+
[IMPORTANT]
515+
⚠️ TextFields may report (0,0) coordinates if not fully laid out. Check 'coordinatesReliable' flag.
516+
When false, use 'key' or 'text' for targeting instead of coordinates.
517+
506518
[MULTI-SESSION]
507519
All action tools support optional session_id parameter. If omitted, uses the active session.
508520
""",
@@ -547,7 +559,27 @@ All action tools support optional session_id parameter. If omitted, uses the act
547559
},
548560
{
549561
"name": "find_by_type",
550-
"description": "Find widgets by type name",
562+
"description": """Find widgets by type name
563+
564+
[PRIMARY PURPOSE]
565+
Search for all widgets matching a specific type (e.g., "TextField", "Button", "ListTile").
566+
567+
[USAGE]
568+
find_by_type(type: "TextField") // Finds all TextFields
569+
find_by_type(type: "Button") // Finds all button types
570+
571+
[OUTPUT FORMAT]
572+
Returns list of widgets with:
573+
• type: Full widget type name
574+
• key: Element identifier if available
575+
• position: {x, y} coordinates
576+
• size: {width, height} dimensions
577+
• coordinatesReliable: Boolean - true if coordinates are trustworthy
578+
579+
[IMPORTANT]
580+
⚠️ Check 'coordinatesReliable' flag before using coordinates for tap/click actions.
581+
If false, use 'key' property for reliable targeting.
582+
""",
551583
"inputSchema": {
552584
"type": "object",
553585
"properties": {

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flutter-skill-mcp",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "MCP Server for Flutter app automation - Give your AI Agent eyes and hands inside your Flutter app",
55
"main": "index.js",
66
"bin": {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_skill
22
description: Give your AI Agent eyes and hands inside your Flutter app.
3-
version: 0.5.1
3+
version: 0.5.2
44
homepage: https://github.com/ai-dashboad/flutter-skill
55
repository: https://github.com/ai-dashboad/flutter-skill
66
# publish_to: 'none' # Remove this when ready to publish to pub.dev

vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "flutter-skill",
33
"displayName": "Flutter Skill - AI App Automation",
44
"description": "Give your AI Agent eyes and hands inside your Flutter app. Bridge between AI coding assistants (Claude Code, Cursor, Windsurf) and running Flutter applications with 25+ MCP tools for UI inspection, gestures, screenshots, and more.",
5-
"version": "0.5.1",
5+
"version": "0.5.2",
66
"publisher": "ai-dashboad",
77
"icon": "images/icon.png",
88
"repository": {

0 commit comments

Comments
 (0)