Skip to content

Conversation

@R44VC0RP
Copy link
Contributor

Summary

This PR implements a "user diff" feature that tracks and displays external file changes made by users between AI generations. When a user modifies files outside of OpenCode and submits a new prompt, the system now shows what changed.

  • Captures a snapshot at the end of each successful AI generation
  • Computes diff against the snapshot when a new prompt is submitted
  • Shows changes in the TUI with file status indicators (A/M/D)
  • Injects diff context into the conversation for the AI to understand
  • Includes protections against context overload (max 50 files, 10k chars)
  • Ignores common non-essential files (node_modules, dist, lock files, etc.)

Changes

  • Added lastGenerationSnapshot field to Session schema
  • Created new UserDiffPart message part type
  • New user-diff.ts module for diff computation and formatting
  • Modified SessionProcessor to capture snapshots at end of generation
  • Modified SessionPrompt to compute and inject user diffs
  • Added TUI rendering for user diff display
  • Regenerated SDK types

Design Doc

See specs/user-diff.md for the full design specification.

@R44VC0RP
Copy link
Contributor Author

this is a POC do not merge

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.

1 participant