Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

fix(code): fix truncated diff preview - #1235

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

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

Conversation

@adboio

@adboioadboio commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

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

@adboioGraphite App

adboio commented Mar 13, 2026

Copy link
Copy Markdown
ContributorAuthor

@adboio
adboioforce-pushed the 03-13-fix_code_fix_truncated_diff_preview branch 4 times, most recently from 97bc735 to 8cb44e0CompareMarch 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 teamMarch 13, 2026 22:09
@charlesvienGraphite App

charlesvien commented Mar 14, 2026

Copy link
Copy Markdown
Member

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/1235March 14, 2026 19:27
@charlesvien
charlesvien changed the base branch from graphite-base/1235 to mainMarch 14, 2026 19:31
@charlesvien
charlesvienforce-pushed the 03-13-fix_code_fix_truncated_diff_preview branch from 8cb44e0 to e4e2ba6CompareMarch 14, 2026 19:32
@charlesvien
charlesvien merged commit d2896bc into mainMar 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 freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@adboio@charlesvien