Skip to content

Commit 1d19e44

Browse files
authored
Show Simplification Pass Names (#96)
1 parent 5a9ea92 commit 1d19e44

4 files changed

Lines changed: 71 additions & 14 deletions

File tree

client/src/types/vc-implications.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export type VCImplication = {
88
export type VCSimplificationResult = {
99
implication: VCImplication;
1010
origin: VCSimplificationResult | null;
11+
simplification: string | null;
1112
}

client/src/webview/styles.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,43 @@ export function getStyles(): string {
324324
}
325325
.vc-container {
326326
display: flex;
327-
justify-content: space-between;
328-
align-items: flex-start;
329-
gap: 1rem;
327+
flex-direction: column;
328+
gap: 0.375rem;
330329
margin: 0.5rem 0;
331330
}
331+
.vc-step-header {
332+
display: flex;
333+
align-items: center;
334+
justify-content: space-between;
335+
gap: 0.75rem;
336+
min-width: 0;
337+
padding-bottom: 0.25rem;
338+
border-bottom: 1px solid var(--vscode-widget-border, var(--vscode-panel-border));
339+
font-family: var(--vscode-font-family);
340+
font-size: 0.8rem;
341+
line-height: 1.25rem;
342+
}
343+
.vc-step-name {
344+
min-width: 0;
345+
overflow: hidden;
346+
color: var(--vscode-descriptionForeground);
347+
font-weight: 600;
348+
text-overflow: ellipsis;
349+
white-space: nowrap;
350+
}
351+
.vc-step-navigation {
352+
display: inline-flex;
353+
align-items: center;
354+
gap: 0.25rem;
355+
flex-shrink: 0;
356+
}
357+
.vc-step-position {
358+
min-width: 2.5rem;
359+
color: var(--vscode-descriptionForeground);
360+
font-variant-numeric: tabular-nums;
361+
text-align: right;
362+
}
332363
.vc-chain {
333-
flex: 1;
334364
display: flex;
335365
flex-direction: column;
336366
gap: 0.25rem;

client/src/webview/views/diagnostics/vc-implications.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ function renderStepButton(errorId: string, step: "previous" | "next", disabled:
2828
return `<button class="vc-step-btn vc-step-${step}-btn" data-error-id="${errorId}" data-vc-step="${step}" title="${label}" aria-label="${label}" ${disabled ? "disabled" : ""} type="button">${renderCodicon(icon)}</button>`;
2929
}
3030

31+
function renderStepHeader(
32+
errorId: string,
33+
current: VCSimplificationResult,
34+
index: number,
35+
stepCount: number,
36+
): string {
37+
const chronologicalStep = stepCount - index;
38+
const simplification = current.simplification?.trim();
39+
const label = simplification || "Original";
40+
41+
return /*html*/`
42+
<div class="vc-step-header">
43+
<span class="vc-step-name" title="${escapeHtml(label)}">${escapeHtml(label)}</span>
44+
<div class="vc-step-navigation">
45+
<span class="vc-step-position" aria-label="Simplification step ${chronologicalStep} of ${stepCount}">
46+
${chronologicalStep}/${stepCount}
47+
</span>
48+
<div class="vc-step-controls">
49+
${renderStepButton(errorId, "previous", index === stepCount - 1)}
50+
${renderStepButton(errorId, "next", index === 0)}
51+
</div>
52+
</div>
53+
</div>
54+
`;
55+
}
56+
3157
export function handleVCImplicationStepClick(target: Element): boolean {
3258
const errorId = target.getAttribute("data-error-id");
3359
const step = target.getAttribute("data-vc-step");
@@ -53,21 +79,19 @@ export function renderVCImplication(
5379
error.title,
5480
error.message
5581
]));
56-
const history: VCSimplificationResult[] = [];
82+
const steps: VCSimplificationResult[] = [];
5783
for (let current: VCSimplificationResult | null = result; current; current = current.origin) {
58-
history.push(current);
84+
steps.push(current);
5985
}
6086

61-
const index = Math.min(stepIndexes.get(errorId) ?? 0, history.length - 1);
87+
const index = Math.min(stepIndexes.get(errorId) ?? 0, steps.length - 1);
6288
stepIndexes.set(errorId, index);
89+
const current = steps[index];
6390

6491
return /*html*/ `
6592
<div class="container vc-container" data-error-id="${errorId}">
66-
<div class="vc-chain">${renderImplication(history[index].implication)}</div>
67-
<div class="vc-step-controls">
68-
${renderStepButton(errorId, "previous", index === history.length - 1)}
69-
${renderStepButton(errorId, "next", index === 0)}
70-
</div>
93+
${steps.length > 1 ? renderStepHeader(errorId, current, index, steps.length) : ""}
94+
<div class="vc-chain">${renderImplication(current.implication)}</div>
7195
</div>
7296
`;
7397
}

server/src/main/java/dtos/diagnostics/VCSimplificationResultDTO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
/**
66
* DTO for serializing a simplified VC and its complete predecessor states.
77
*/
8-
public record VCSimplificationResultDTO(VCImplicationDTO implication, VCSimplificationResultDTO origin) {
8+
public record VCSimplificationResultDTO(VCImplicationDTO implication, VCSimplificationResultDTO origin, String simplification) {
99

1010
public static VCSimplificationResultDTO from(VCSimplificationResult result) {
1111
if (result == null)
1212
return null;
1313

1414
return new VCSimplificationResultDTO(
1515
VCImplicationDTO.from(result.getImplication()),
16-
from(result.getOrigin()));
16+
from(result.getOrigin()),
17+
result.getSimplification()
18+
);
1719
}
1820
}

0 commit comments

Comments
 (0)