This repository has been archived on 2026-06-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FabledApp/lib/data/api/quick_capture_api.dart
T
bvandeusen c3d9cc273f fix: quick capture incorrectly treated as offline on LLM timeout
The global receiveTimeout is 30s but quick capture runs LLM inference
that can take much longer. receiveTimeout fired, fell through to the
NetworkException fallback in dioToApp, and the work queue queued it as
an offline item.

- quick_capture_api.dart: override receiveTimeout to 120s for the
  /api/quick-capture request
- api_client.dart: handle receiveTimeout/sendTimeout explicitly in the
  error interceptor, converting them to AppException (not NetworkException)
  so slow responses are never mistaken for being offline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 07:54:00 -04:00

51 lines
1.4 KiB
Dart

import 'package:dio/dio.dart';
import 'api_client.dart';
/// Result returned by POST /api/quick-capture.
/// type is one of: "note", "task", "event", "todo"
class CaptureResult {
final String type;
final String message; // human-readable summary from the server
final bool fallback; // true when the server used a note as a fallback
final int? id;
final String title;
const CaptureResult({
required this.type,
required this.message,
this.fallback = false,
this.id,
required this.title,
});
factory CaptureResult.fromJson(Map<String, dynamic> json) {
final data = json['data'] as Map<String, dynamic>? ?? {};
return CaptureResult(
type: json['type'] as String? ?? 'note',
message: json['message'] as String? ?? '',
fallback: json['fallback'] as bool? ?? false,
id: data['id'] as int?,
title: data['title'] as String? ?? '',
);
}
}
class QuickCaptureApi {
final Dio _dio;
const QuickCaptureApi(this._dio);
Future<CaptureResult> capture(String text) async {
try {
final response = await _dio.post(
'/api/quick-capture',
data: {'text': text},
options: Options(receiveTimeout: const Duration(seconds: 120)),
);
return CaptureResult.fromJson(response.data as Map<String, dynamic>);
} on DioException catch (e) {
throw dioToApp(e);
}
}
}