Skip to content

Refactor DiffEngine#230

Merged
rorychatt merged 13 commits into
mainfrom
refactor-diffengine
Oct 10, 2025
Merged

Refactor DiffEngine#230
rorychatt merged 13 commits into
mainfrom
refactor-diffengine

Conversation

@ArtemLazarchuk

Copy link
Copy Markdown
Collaborator

DiffEngine

image

One-Click Development Environment

Open in GitHub Codespaces

Click the badge above to open Ivy Examples repository in GitHub Codespaces with:

  • .NET 9.0 SDK pre-installed
  • Ready-to-run development environment
  • No local setup required

Created Using Ivy

Web application created using Ivy-Framework.

Ivy - The ultimate framework for building internal tools with LLM code generation by unifying front-end and back-end into a single C# codebase. With Ivy, you can build robust internal tools and dashboards using C# and AI assistance based on your existing database.

Ivy is a web framework for building interactive web applications using C# and .NET.

Interactive Example For Diff Tool Integration

This example demonstrates how to launch and manage external diff tools using the DiffEngine library integrated with Ivy. DiffEngine automatically detects and launches installed diff tools on Windows, macOS, and Linux.

What This Application Does:

This specific implementation creates a Diff Tool Launcher application that allows users to:

  • Compare Text Side-by-Side: Enter text in two code editors and launch a diff tool to compare them
  • Compare File Contents: Provide two file paths, which are safely copied to temp files before comparison
  • Extension Selection: Choose file extensions (txt, json) via dropdown for proper syntax highlighting
  • Kill Active Diffs: Close the last launched diff tool session with a single click
  • Tabbed Interface: Organized UI with separate tabs for Text Diff and File Paths Diff workflows
  • Automatic Tool Detection: Works with WinMerge, VS Code, KDiff3, Meld, BeyondCompare, and 15+ other tools

Technical Implementation:

  • Uses DiffEngine's DiffRunner.LaunchAsync() for automatic tool detection and launching
  • Generates temporary files with proper extensions for diff tool compatibility
  • Implements BuildServerDetector to detect CI/CD environments
  • Creates side-by-side card layouts with CodeInput for text comparison
  • Handles cleanup with DiffRunner.Kill() to close specific diff tool instances
  • Single C# view (Apps/DiffEngineApp.cs) built with Ivy UI primitives

How to Run

  1. Prerequisites:

    • .NET 9.0 SDK
    • A diff tool installed (e.g. WinMerge, VS Code, Meld, KDiff3). DiffEngine will detect what you have.
  2. Navigate to the example:

    cd diffengine
  3. Restore dependencies:

    dotnet restore
  4. Run the application:

    dotnet watch
  5. Open your browser to the URL shown in the terminal (typically http://localhost:5010)

How to Deploy

Deploy this example to Ivy's hosting platform:

  1. Navigate to the example:
    cd diffengine
  2. Deploy to Ivy hosting:
    ivy deploy

This will deploy your diff tool launcher application with a single command.

Learn More

@ArtemLazarchuk ArtemLazarchuk self-assigned this Oct 9, 2025
@nielsbosma
nielsbosma requested a review from Copilot October 10, 2025 00:10

Copilot AI left a comment

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.

Pull Request Overview

This PR refactors the DiffEngine example application to improve naming consistency and enhance the user interface. The changes rename the project from "DiffEngineDemo" to "DiffengineExample" throughout the codebase and replace the original HelloApp with a more sophisticated DiffEngineApp featuring a tabbed interface.

  • Updated project naming from "DiffEngineDemo" to "DiffengineExample" for consistency
  • Replaced HelloApp with an enhanced DiffEngineApp featuring tabbed UI and improved user experience
  • Added comprehensive documentation and GitHub Codespaces integration

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
diffengine/Services/DiffService.cs Updated namespace to match new project naming
diffengine/README.md Completely rewritten with detailed documentation, setup instructions, and feature descriptions
diffengine/Program.cs Updated to use DiffEngineApp as default with custom header and GitHub integration
diffengine/GlobalUsings.cs Updated namespace references and global using statements
diffengine/Dockerfile Updated project file references to match new naming
diffengine/DiffengineExample.sln Updated solution file project reference
diffengine/DiffengineExample.csproj Updated RootNamespace property
diffengine/Apps/HelloApp.cs Removed old application implementation
diffengine/Apps/DiffEngineApp.cs Added new tabbed interface application with enhanced UI
.devcontainer/diffengine/devcontainer.json Added GitHub Codespaces configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread diffengine/Program.cs
Comment on lines +8 to +15
var customHeader = Layout.Vertical().Gap(2).Align(Align.Center)
| new Html(@"
<div>
<a href=""https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=Ivy-Interactive%2FIvy-Examples&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdiffengine%2Fdevcontainer.json&location=EuropeWest"">
<img src=""https://github.com/codespaces/badge.svg"" alt=""Open DiffEngine in Codespaces"" />
</a>
</div>
")

Copilot AI Oct 10, 2025

Copy link

Choose a reason for hiding this comment

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

The long URL on line 11 should be extracted to a constant or configuration value to improve readability and maintainability.

Copilot uses AI. Check for mistakes.
Comment thread diffengine/Apps/DiffEngineApp.cs Outdated
{
try
{
error.Value = "";

Copilot AI Oct 10, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Consider using null instead of empty string for clearing error state to be consistent with the null check pattern used elsewhere in the code.

Copilot uses AI. Check for mistakes.
Comment thread diffengine/Apps/DiffEngineApp.cs Outdated
}
try
{
error.Value = "";

Copilot AI Oct 10, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Consider using null instead of empty string for clearing error state to be consistent with the null check pattern used elsewhere in the code.

Copilot uses AI. Check for mistakes.
Comment thread diffengine/Apps/DiffEngineApp.cs Outdated
Comment on lines +149 to +151
return Layout.Vertical()
| (Layout.Horizontal().Gap(2).Align(Align.Center)
| new Card(tabsView).Width(Size.Fraction(0.8f)));

Copilot AI Oct 10, 2025

Copy link

Choose a reason for hiding this comment

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

The magic number 0.8f for the card width fraction should be extracted to a named constant to improve code readability and maintainability.

Copilot uses AI. Check for mistakes.
@rorychatt
rorychatt merged commit a73d9d1 into main Oct 10, 2025
63 checks passed
@rorychatt
rorychatt deleted the refactor-diffengine branch October 10, 2025 14:26
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.

3 participants