Skip to content

Conversation

@pavanmudumba
Copy link

@pavanmudumba pavanmudumba commented Jan 30, 2026

Summary

This PR improves the diff preview shown when committing changes in the Playground.

Previously, even small edits to a prompt caused the entire prompt block to be marked as changed, making it difficult to understand what actually changed. This update makes the diff operate at a field level so that only the modified prompt fields are highlighted.

What changed

  • Introduced a field-level diff input for prompt data instead of diffing the full serialized object
  • Ensured the diff logic remains reusable and isolated
  • Preserved existing behavior for non-prompt parameters

Why this matters

This makes commit previews more readable and precise, especially for small prompt edits, improving the overall developer experience when reviewing changes.

Scope & Safety

  • Changes are limited to the diff preparation logic
  • No backend or API behavior is affected
  • No changes to authentication, routing, or state management

Related Issue

Fixes #3550


Open with Devin

@vercel
Copy link

vercel bot commented Jan 30, 2026

@pavanmudumba is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Jan 30, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jan 30, 2026
@mmabrouk
Copy link
Member

Hey @pavanmudumba it would be great if you could share a short video of how it works.

@dosubot dosubot bot added dev experience Improvement of the experience using the software. For instance better error messaging Frontend labels Jan 30, 2026
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 3 additional flags in Devin Review.

Open in Devin Review

Comment on lines +23 to +28
function buildPromptDiffInput(params?: Record<string, any>): DiffInput {
if (!params) return {}
return {
prompt: params.prompt,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 buildPromptDiffInput extracts non-existent prompt property, resulting in empty diff

The buildPromptDiffInput function extracts params.prompt assuming there's a top-level prompt property, but the actual data structure has prompt names as keys with prompt as a nested property inside each.

Click to expand

Data Structure Mismatch

The params variable (line 94) is either:

  • derivedAgConfig from transformedPromptsAtomFamily(variantId)?.ag_config - which has structure like { "promptName": { prompt: [...], llm_config: {...} } }
  • jsonOverride - a parameters override object
  • variant.parameters - which has structure like { ag_config: { promptName: { ... } } }

The buildPromptDiffInput function at lines 23-28:

function buildPromptDiffInput(params?: Record<string, any>): DiffInput {
    if (!params) return {}
    return {
        prompt: params.prompt,  // This will be undefined!
    }
}

Since params.prompt is undefined (the actual prompt arrays are nested under prompt name keys), the function returns { prompt: undefined }. When JSON.stringify is called on this, the undefined value is omitted, resulting in "{}".

Impact

The diff preview in the commit modal will always show an empty or near-empty comparison (e.g., {} vs {}), making it useless for reviewing actual prompt changes before committing.

Recommendation: The function should iterate over the prompt keys in the config object and extract the nested prompt arrays. For example:

function buildPromptDiffInput(params?: Record<string, any>): DiffInput {
    if (!params) return {}
    const result: DiffInput = {}
    for (const [key, value] of Object.entries(params)) {
        if (value && typeof value === 'object' && 'prompt' in value) {
            result[key] = { prompt: value.prompt }
        }
    }
    return result
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

function buildPromptDiffInput(params?: Record<string, any>): DiffInput {
if (!params) return {}
return {
prompt: params.prompt,
Copy link
Member

Choose a reason for hiding this comment

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

This assumes there is a property called prompt in params. That is not always the case (for instance with custom workflows)

Copy link
Author

Choose a reason for hiding this comment

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

Good point — agreed.

The current version assumes a top-level prompt field, which won’t hold for custom workflows or alternative config shapes.

I’ll update the diff input builder to iterate over the config entries and extract nested prompt fields only when present, so the diff remains field-level without making assumptions about the schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev experience Improvement of the experience using the software. For instance better error messaging Frontend size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diff in commit modal replaces entire prompt field

3 participants