Skip to content

Commit e8a7fed

Browse files
committed
Finished LMP diffing. Closes #36
1 parent dc3aaf2 commit e8a7fed

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

ell-studio/src/components/source/DiffRenderer.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@ export function DiffRenderer({
3636
let oldRowIndex = 0;
3737
let newRowIndex = 0;
3838

39-
console.log("PREVIOUS CODE ROWS", previousCodeRows)
40-
console.log("CURRENT CODE ROWS", currentCodeRows)
4139
diff.forEach((part, partIndex) => {
4240
const { added, removed, value } = part;
4341
const lines = value.split('\n')
4442
if(lines.length > 1 && lines[lines.length - 1] === '') {
4543
lines.pop()
4644
}
4745

48-
console.log("DIF PART", value, lines)
4946

5047
lines.forEach((line, lineIndex) => {
5148
const diffIndicator = added ? '+' : (removed ? '-' : ' ');

ell-studio/src/pages/LMP.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ function LMP() {
7070
(a, b) => new Date(b.created_at) - new Date(a.created_at)
7171
);
7272
setVersionHistory(sortedVersionHistory);
73-
if (sortedVersionHistory.length > 1) {
74-
setPreviousVersion(sortedVersionHistory[1]);
75-
}
76-
77-
73+
const currentVersionIndex = sortedVersionHistory.findIndex(v => v.lmp_id === latest_lmp.lmp_id);
74+
const hasPreviousVersion = sortedVersionHistory.length > 1 && currentVersionIndex < sortedVersionHistory.length - 1;
75+
setPreviousVersion(hasPreviousVersion ? sortedVersionHistory[currentVersionIndex + 1] : null);
7876

7977
const invocationsResponse = await axios.get(
8078
`${API_BASE_URL}/api/invocations/${name}${id ? `/${id}` : ""}`
@@ -133,6 +131,8 @@ function LMP() {
133131
setViewMode(prevMode => prevMode === 'Source' ? 'Diff' : 'Source');
134132
};
135133

134+
135+
136136
if (!lmp)
137137
return (
138138
<div className="flex items-center justify-center h-screen bg-gray-900 text-gray-100">
@@ -185,12 +185,12 @@ function LMP() {
185185
)}
186186
</div>
187187
<div className="flex space-x-4 items-center">
188-
<ToggleSwitch
188+
{previousVersion && <ToggleSwitch
189189
leftLabel="Source"
190190
rightLabel="Diff"
191191
isRight={viewMode === 'Diff'}
192192
onToggle={handleViewModeToggle}
193-
/>
193+
/> }
194194
<button
195195
className="p-1 rounded bg-[#2a2f3a] hover:bg-[#3a3f4b] transition-colors"
196196
onClick={handleCopyCode}
@@ -205,7 +205,7 @@ function LMP() {
205205
selectedInvocation={selectedTrace}
206206
showDependenciesInitial={!!id}
207207
previousVersion={previousVersion}
208-
viewMode={viewMode}
208+
viewMode={previousVersion ? viewMode : 'Source'}
209209
/>
210210
</div>
211211
</div>

0 commit comments

Comments
 (0)