Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Store: reviews post again — the app sends the local header the CLI requires for writes

dee41a874be1966
diff --git a/desktop/lib/api/api_client.dart b/desktop/lib/api/api_client.dart
index 111613e56..2f4a7eab6 100644
--- a/desktop/lib/api/api_client.dart
+++ b/desktop/lib/api/api_client.dart
@@ -76,12 +76,19 @@ class ApiClient {
if (title != null && title.trim().isNotEmpty) 'title': title.trim(),
if (body != null && body.trim().isNotEmpty) 'body': body.trim(),
},
+ // The CLI accepts a write only from this app on this computer, as it does
+ // for renaming a machine. Without the header every review was refused
+ // with 403, which the store worded as "Sign in".
+ options: Options(headers: {'x-adapter-local': '1'}),
);
return unwrapApiResponse(res) as Map<String, dynamic>?;
}
Future<void> deleteStoreReview(String harnessId) async {
- final res = await _dio.delete('/api/store/harnesses/$harnessId/review');
+ final res = await _dio.delete(
+ '/api/store/harnesses/$harnessId/review',
+ options: Options(headers: {'x-adapter-local': '1'}),
+ );
unwrapApiResponse(res);
}
diff --git a/desktop/test/api_client_test.dart b/desktop/test/api_client_test.dart
index 2766b61d3..48e61c34b 100644
--- a/desktop/test/api_client_test.dart
+++ b/desktop/test/api_client_test.dart
@@ -57,6 +57,49 @@ void main() {
}
});
+ test('review writes carry the local header the CLI requires; reads do not need it', () async {
+ final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
+ final seen = <(String, String, String?)>[];
+ final subscription = server.listen((request) async {
+ seen.add((
+ request.method,
+ request.uri.path,
+ request.headers.value('x-adapter-local'),
+ ));
+ await utf8.decoder.bind(request).join();
+ request.response
+ ..statusCode = HttpStatus.ok
+ ..headers.contentType = ContentType.json
+ ..write(
+ jsonEncode({
+ 'success': true,
+ 'data': {'ok': true},
+ }),
+ );
+ await request.response.close();
+ });
+ try {
+ final api = ApiClient(
+ config: AppConfig(
+ apiBaseUrl: 'http://unused.invalid',
+ localCliBaseUrl: 'http://127.0.0.1:${server.port}',
+ ),
+ session: AuthSession(),
+ );
+ await api.storeRatings();
+ await api.putStoreReview('autonomous/typst', rating: 5, title: ' Great ');
+ await api.deleteStoreReview('autonomous/typst');
+ expect(seen, [
+ ('GET', '/api/store/ratings', null),
+ ('PUT', '/api/store/harnesses/autonomous/typst/review', '1'),
+ ('DELETE', '/api/store/harnesses/autonomous/typst/review', '1'),
+ ]);
+ } finally {
+ await subscription.cancel();
+ await server.close(force: true);
+ }
+ });
+
group('describeApiError', () {
final options = RequestOptions(
path: '/api/machines',