Skip to content

Constrainted reverts #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

yann-achard-MS
Copy link
Collaborator

No description provided.

@yann-achard-MS yann-achard-MS deleted the constrainted-reverts branch January 15, 2025 19:45
agarwal-navin pushed a commit that referenced this pull request Jun 3, 2025
…pes into a consumable version for UI visualizations (microsoft#24482)

## Description
Currently, the only way to get a set of objects for visualizing each
change an LLM makes to your tree using the aiCollab library is for users
to use the `sharedTreeDiff` utility that was created for the implicit
strategy separately. This utility is not perfect, likely does not cover
many edge cases and is fickle. However, when using the explicit strategy
we maintain an edit log internally that is the source truth. Currently,
we don't return the editLog because the `TreeEdit` type of the edit log
is not simple for users the consume and visualize changes on their UI.

The purpose of this ticket is to update the explicit strategy's entry
point function `generateTreeEdits` by taking the editLog, which is an
array of `TreeEdit`, and transforming it into a new set of objects
"diffs" that can be easily used for UI visualizations and return it
along with the success/fail response.

## Test
Mapping the edit log diff to the front-end task card diff objects:
~~~
Front-end Diff: Insert
[
    {
        "type": "INSERT",
        "path": [
            "tasks",
            3
        ],
        "value": {
            "title": "Task microsoft#4",
            "id": "2756a2e9-237d-487e-b75a-4ab7dd5e4a0d",
            "description": "This is the fourth task.",
            "priority": "Medium",
            "complexity": 2,
            "status": "To Do",
            "assignee": "Bob"
        }
    }
]
~~~
~~~
Edit Log: Insert
[
    {
        "edit": {
            "type": "insert",
"explanation": "Insert a new task titled 'Task microsoft#4' with description
'This is the fourth task.', priority 'Medium', complexity 2, and status
'To Do'. Assign the task to Bob and add it to the end of the tasks
array.",
            "content": {
                "__fluid_objectId": "Task4",
                "title": "Task microsoft#4",
                "id": "2756a2e9-237d-487e-b75a-4ab7dd5e4a0d",
                "description": "This is the fourth task.",
                "priority": "Medium",
                "complexity": 2,
                "status": "To Do",
                "assignee": "Bob"
            },
            "destination": {
                "type": "arrayPlace",
                "parentId": "TaskGroup1",
                "field": "tasks",
                "location": "end"
            }
        }
    }
]
~~~

~~~
Front-end Diff: Change
[
    {
        "path": [
            "tasks",
            0,
            "status"
        ],
        "type": "CHANGE",
        "value": "Done",
        "oldValue": "To Do",
        "objectId": "09138b2d-a75e-4376-be83-2be153c18ba6"
    }
]
~~~
~~~
Edit log: Change
[
    {
        "edit": {
            "type": "modify",
"explanation": "Change the status of Task #1 from 'To Do' to 'Done'",
            "target": {
                "target": "Task1"
            },
            "field": "status",
            "modification": "Done"
        }
    }
]
~~~

~~~
Front-end Diff: Remove
[
    {
        "type": "REMOVE",
        "path": [
            "tasks",
            0
        ],
        "oldValue": {
            "title": "Task #1",
            "id": "09138b2d-a75e-4376-be83-2be153c18ba6",
"description": "This is the first task. Blah Blah blah Blah Blah
blahBlah Blah blahBlah Blah blahBlah Blah blah",
            "priority": "Low",
            "complexity": 1,
            "status": "To Do",
            "assignee": "Alice"
        },
        "objectId": "09138b2d-a75e-4376-be83-2be153c18ba6"
    },
    {
        "type": "MOVE",
        "path": [
            "tasks",
            1
        ],
        "newIndex": 0,
        "value": {
            "title": "Task microsoft#2",
            "id": "09138b2d-a75e-4376-be83-2be153c18ba7",
"description": "This is the second task. Blah Blah blah Blah Blah
blahBlah Blah blahBlah Blah blahBlah Blah blah",
            "priority": "Medium",
            "complexity": 2,
            "status": "In Progress",
            "assignee": "Bob"
        },
        "objectId": "09138b2d-a75e-4376-be83-2be153c18ba7"
    },
    {
        "type": "MOVE",
        "path": [
            "tasks",
            2
        ],
        "newIndex": 1,
        "value": {
            "title": "Task microsoft#3",
            "id": "09138b2d-a75e-4376-be83-2be153c18ba8",
"description": "This is the third task! Blah Blah blah Blah Blah
blahBlah Blah blahBlah Blah blahBlah Blah blah",
            "priority": "High",
            "complexity": 3,
            "status": "Done",
            "assignee": "Charlie"
        },
        "objectId": "09138b2d-a75e-4376-be83-2be153c18ba8"
    },
    {
        "type": "MOVE",
        "path": [
            "tasks",
            3
        ],
        "newIndex": 2,
        "value": {
            "title": "Task microsoft#4",
            "id": "2756a2e9-237d-487e-b75a-4ab7dd5e4a0d",
            "description": "This is the fourth task.",
            "priority": "Medium",
            "complexity": 2,
            "status": "To Do",
            "assignee": "Bob"
        },
        "objectId": "2756a2e9-237d-487e-b75a-4ab7dd5e4a0d"
    }
]
~~~
~~~
Edit log: Remove
{
    "type": "remove",
    "explanation": "Remove Task#1 from the tasks array.",
    "source": {
        "target": "Task1"
    }
}
~~~

~~~
Front-end Diff: Move
[
    {
        "type": "MOVE",
        "path": [
            "tasks",
            0
        ],
        "newIndex": 3,
        "value": {
            "title": "Task #1",
            "id": "09138b2d-a75e-4376-be83-2be153c18ba6",
"description": "This is the first task. Blah Blah blah Blah Blah
blahBlah Blah blahBlah Blah blahBlah Blah blah",
            "priority": "Low",
            "complexity": 1,
            "status": "To Do",
            "assignee": "Alice"
        },
        "objectId": "09138b2d-a75e-4376-be83-2be153c18ba6"
    },
    {
        "type": "MOVE",
        "path": [
            "tasks",
            1
        ],
        "newIndex": 0,
        "value": {
            "title": "Task microsoft#2",
            "id": "09138b2d-a75e-4376-be83-2be153c18ba7",
"description": "This is the second task. Blah Blah blah Blah Blah
blahBlah Blah blahBlah Blah blahBlah Blah blah",
            "priority": "Medium",
            "complexity": 2,
            "status": "In Progress",
            "assignee": "Bob"
        },
        "objectId": "09138b2d-a75e-4376-be83-2be153c18ba7"
    },
    {
        "type": "MOVE",
        "path": [
            "tasks",
            2
        ],
        "newIndex": 1,
        "value": {
            "title": "Task microsoft#3",
            "id": "09138b2d-a75e-4376-be83-2be153c18ba8",
"description": "This is the third task! Blah Blah blah Blah Blah
blahBlah Blah blahBlah Blah blahBlah Blah blah",
            "priority": "High",
            "complexity": 3,
            "status": "Done",
            "assignee": "Charlie"
        },
        "objectId": "09138b2d-a75e-4376-be83-2be153c18ba8"
    },
    {
        "type": "MOVE",
        "path": [
            "tasks",
            3
        ],
        "newIndex": 2,
        "value": {
            "title": "Task microsoft#4",
            "id": "2756a2e9-237d-487e-b75a-4ab7dd5e4a0d",
            "description": "This is the fourth task.",
            "priority": "Medium",
            "complexity": 2,
            "status": "To Do",
            "assignee": "Bob"
        },
        "objectId": "2756a2e9-237d-487e-b75a-4ab7dd5e4a0d"
    }
]
~~~
~~~
Edit log: Move
[
    {
        "edit": {
            "type": "move",
"explanation": "Move Task #1 to the end of the tasks array.",
            "source": {
                "target": "Task1"
            },
            "destination": {
                "type": "arrayPlace",
                "parentId": "TaskGroup1",
                "field": "tasks",
                "location": "end"
            }
        }
    }
]
~~~


AB#[21569](https://dev.azure.com/fluidframework/internal/_workitems/edit/21569)

---------

Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
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