Stage rows show cached share and cost; Changes explain no_patch_reason
Timeline stage rows add the cached share (when cache_known) and a positive cost: 20.1M tokens · 97% cached · $1.42. The file viewer words each server no_patch_reason, keeping the old truncated/binary text as the fallback.
This commit is contained in:
@@ -100,8 +100,31 @@ String noChangeDetail(RunChanges changes) {
|
||||
return emptyCaptureDetail;
|
||||
}
|
||||
|
||||
/// The message for the server's `no_patch_reason`, or null when it sent none
|
||||
/// or one this client does not know (the generic wording then applies).
|
||||
String? noPatchReasonMessage(String? reason) => switch (reason) {
|
||||
'binary' => 'Binary file; only its metadata was recorded.',
|
||||
'file_size' => 'This file is over 1 MiB, so no diff text was recorded.',
|
||||
'budget' =>
|
||||
'The workspace snapshot ran out of text budget, so no diff text was '
|
||||
'recorded.',
|
||||
'lines' => 'The change is over 5,000 lines, so no diff text was recorded.',
|
||||
'evidence_size' =>
|
||||
"This visit's recorded changes reached their size limit, so this patch "
|
||||
'was dropped.',
|
||||
'git_status' =>
|
||||
"This change was seen only in Git status, so the file's contents weren't "
|
||||
'compared.',
|
||||
'baseline' =>
|
||||
"The file's content at stage start couldn't be recovered from Git, so no "
|
||||
'diff was recorded.',
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// Why a file has no patch to render, in the entry's own recorded terms.
|
||||
String patchUnavailableReason(FileChange file) {
|
||||
final reason = noPatchReasonMessage(file.noPatchReason);
|
||||
if (reason != null) return reason;
|
||||
if (file.truncated) {
|
||||
return "The server truncated this file's patch at its capture limit; no "
|
||||
'diff text was recorded.';
|
||||
|
||||
@@ -12,12 +12,14 @@ class FileChange {
|
||||
String? patch,
|
||||
this.binary = false,
|
||||
this.truncated = false,
|
||||
String? noPatchReason,
|
||||
String? beforeMode,
|
||||
String? afterMode,
|
||||
this.steps = const [],
|
||||
ParsedPatch? parsedPatch,
|
||||
}) : patch = _nonBlank(patch),
|
||||
beforeMode = _nonBlank(beforeMode),
|
||||
noPatchReason = _nonBlank(noPatchReason),
|
||||
afterMode = _nonBlank(afterMode),
|
||||
// Aggregate copies pass their already-parsed patch through instead of
|
||||
// re-parsing the same recorded bytes for every stage that touched a path.
|
||||
@@ -32,6 +34,11 @@ class FileChange {
|
||||
final String? patch;
|
||||
final bool binary;
|
||||
final bool truncated;
|
||||
|
||||
/// Why the server recorded no (complete) patch: `binary`, `file_size`,
|
||||
/// `budget`, `lines`, `evidence_size`, `git_status` or `baseline`. Null from
|
||||
/// an older server or when a patch was recorded.
|
||||
final String? noPatchReason;
|
||||
final String? beforeMode;
|
||||
final String? afterMode;
|
||||
|
||||
@@ -68,6 +75,7 @@ class FileChange {
|
||||
patch: patch,
|
||||
binary: binary,
|
||||
truncated: truncated,
|
||||
noPatchReason: noPatchReason,
|
||||
beforeMode: beforeMode,
|
||||
afterMode: afterMode,
|
||||
steps: List.unmodifiable(value),
|
||||
@@ -88,6 +96,9 @@ class FileChange {
|
||||
patch: json['patch'] is String ? json['patch'] as String : null,
|
||||
binary: json['binary'] == true,
|
||||
truncated: json['truncated'] == true,
|
||||
noPatchReason: json['no_patch_reason'] is String
|
||||
? json['no_patch_reason'] as String
|
||||
: null,
|
||||
beforeMode: _textOrNull(json['before_mode']),
|
||||
afterMode: _textOrNull(json['after_mode']),
|
||||
);
|
||||
|
||||
@@ -211,7 +211,11 @@ class _FileDiffViewerState extends State<FileDiffViewer> {
|
||||
|
||||
Widget _body(BuildContext context, TextStyle mono) {
|
||||
final file = widget.file;
|
||||
if (file.binary) return _message(context, binaryDiffMessage);
|
||||
// A recorded reason is more specific than the generic binary message.
|
||||
final reason = noPatchReasonMessage(file.noPatchReason);
|
||||
if (file.binary && reason == null) {
|
||||
return _message(context, binaryDiffMessage);
|
||||
}
|
||||
if (!file.hasPatch) {
|
||||
return _message(context, patchUnavailableReason(file));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user