Skip to content

fix(code): fix truncated diff preview#1235

Merged
charlesvien merged 1 commit intomainfrom
03-13-fix_code_fix_truncated_diff_preview
Mar 14, 2026
Merged

fix(code): fix truncated diff preview#1235
charlesvien merged 1 commit intomainfrom
03-13-fix_code_fix_truncated_diff_preview

Conversation

@adboio
Copy link
Contributor

@adboio adboio commented Mar 13, 2026

problem

diff viewer is a little broken - mostly because sometimes the tool output is too large, causing the "diff preview content" to be something like this:

<persisted-output>
Output too large (110.7KB). Full output saved to: /Users/adambowker/Library/Application Support/@posthog/posthog-code-dev/claude/projects/-Users-adambowker-posthog/019ce8a1-8438-7365-af52-3e0d8a594eb2/tool-results/toolu_019XVYxMKKxpPvfecMUzFEwj.txt  
Preview (first 2KB):  
import './EditSurvey.scss'  
import { DndContext } from '@dnd-kit/core'  
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'  
import { BindLogic, useActions, useMountedLogic, useValues } from 'kea'  
...
</persisted-output>

when this happens, 1) it looks bad, 2) the stats are computed incorrectly as +0 -0 , and 3) just means you can’t actually view the diff

also, the diff sometimes doesn't work if it's a delete-only, because we only check newText when rendering the diff

changes

  1. updates EditToolView to check oldText || newText to determine if there is a diff, instead of only newText
  2. updates toolInfoFromToolUse to build the diff by:
    1. first, check file content cache exists and is valid (old text exists in the content)
    2. if missing or not valid, attempt to read the file contents from disk
    3. if both of those fail, fall back to rendering fragment diff only, no context lines

Copy link
Contributor Author

adboio commented Mar 13, 2026

@adboio adboio force-pushed the 03-13-fix_code_fix_truncated_diff_preview branch 4 times, most recently from 97bc735 to 8cb44e0 Compare March 13, 2026 22:02
@adboio adboio marked this pull request as ready for review March 13, 2026 22:05
@adboio adboio requested a review from a team March 13, 2026 22:09
Copy link
Member

charlesvien commented Mar 14, 2026

Merge activity

  • Mar 14, 7:26 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 14, 7:32 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 14, 7:36 PM UTC: @charlesvien merged this pull request with Graphite.

@charlesvien charlesvien changed the base branch from 03-13-feat_code_improve_pasted_text_ux to graphite-base/1235 March 14, 2026 19:27
@charlesvien charlesvien changed the base branch from graphite-base/1235 to main March 14, 2026 19:31
@charlesvien charlesvien force-pushed the 03-13-fix_code_fix_truncated_diff_preview branch from 8cb44e0 to e4e2ba6 Compare March 14, 2026 19:32
@charlesvien charlesvien merged commit d2896bc into main Mar 14, 2026
15 checks passed
@charlesvien charlesvien deleted the 03-13-fix_code_fix_truncated_diff_preview branch March 14, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants