Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: Improved metrics tracking behaviour on fs_undo#1489

Merged
tusharmath merged 5 commits into
tailcallhq:mainfrom
manthanabc:metrics
Sep 7, 2025
Merged

fix: Improved metrics tracking behaviour on fs_undo#1489
tusharmath merged 5 commits into
tailcallhq:mainfrom
manthanabc:metrics

Conversation

@manthanabc

Copy link
Copy Markdown
Contributor

Changes

  1. Updated undo changes to update metrics correctly
  2. Updated fs_undo diff

Current metrics updation behaviour

i made diagram to better understand this, fs_undo changes were treated as any other changes
wrng

Updated behaviour

when fs_undo the changes will be subtracted from metrics instead of added, to correctly reflect the status of those files
screenshot
as seen in this image the metrics will correctly reflect on the state of the file prior to the changes which are now undone

Fs_undo diffs

While doing this i also noticed Fs_undo diffs where off, specifically before and after was the other way around
like can be seen in this snapshot
Operation:

output: FsUndoOutput {
    before_undo: Some("Original content\nBefore changes".to_string()),
    after_undo: Some("Modified content\nAfter restoration".to_string()),
},

Output (current)

1        |-Modified content
2        |-After restoration
    1    |+Original content
    2    |+Before changes

Output (newer)

1        |-Original content
2        |-Before changes
    1    |+Modified content
    2    |+After restoration

Since original content is basically removed, and now the file contains Modified content\n After restoratte later diff is more suitable.
The diff is not seen in actual tool usage tho.

@github-actions github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Sep 5, 2025
Comment on lines +383 to +385
let diff = DiffFormat::format(
output.after_undo.as_deref().unwrap_or(""),
output.before_undo.as_deref().unwrap_or(""),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters in DiffFormat::format are reversed between the metrics calculation and display code. In the metrics calculation:

let diff = DiffFormat::format(
    output.after_undo.as_deref().unwrap_or(""),
    output.before_undo.as_deref().unwrap_or(""),
);

But for display:

let diff = DiffFormat::format(before, after);

This inconsistency will cause metrics to track the inverse of what's being displayed. Either swap the parameters in the metrics calculation to match the display order:

let diff = DiffFormat::format(
    output.before_undo.as_deref().unwrap_or(""),
    output.after_undo.as_deref().unwrap_or(""),
);

Or adjust the metrics calculation to account for the reversed diff.

Suggested change
let diff = DiffFormat::format(
output.after_undo.as_deref().unwrap_or(""),
output.before_undo.as_deref().unwrap_or(""),
let diff = DiffFormat::format(
output.before_undo.as_deref().unwrap_or(""),
output.after_undo.as_deref().unwrap_or(""),

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

forge_domain::ToolOutput::text(elm)
}
(Some(after), Some(before)) => {
(Some(before), Some(after)) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add some failing tests for this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this point, it is only converted to a text element and returned, which should be captured in the new snapshots

@tusharmath tusharmath merged commit 08b9b19 into tailcallhq:main Sep 7, 2025
8 checks passed
@manthanabc manthanabc deleted the metrics branch December 21, 2025 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants