CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / integration (push) Successful in 23s
CI & Build / TypeScript typecheck (push) Successful in 25s
CI & Build / Python tests (push) Successful in 57s
CI & Build / Build & push image (push) Successful in 43s
#2277 counted ~150 "raw colour literals bypassing the tokens". Measuring them told a different story: 184 sat in `var(--token, #fallback)` position, and a check against theme.css shows every one of those tokens IS declared. So the fallbacks could not render. Not drift — vestigial. They were also not this palette. The most common were Tailwind and Flat-UI defaults — #6366f1 indigo, #22c55e green, #f59e0b amber, #3b82f6 blue, #e74c3c and #27ae60 — a second, unsanctioned colour scheme sitting in the codebase looking like the app's colours to anyone reading it. Removing them is not tidying. #2319's lesson is that a fallback is WORSE than a missing token: a missing token renders as nothing and someone eventually notices, while a fallback renders something plausible forever. These 184 were one token rename away from silently repainting the app in Tailwind. The design token check would catch the rename — but the fallback is precisely the thing that would make it invisible if the check were ever bypassed. Literal count 152 -> 45, which matters beyond the number: a report that is mostly unreachable noise is one people stop reading, and then it stops working while still passing. What remains should be genuinely worth looking at. Done with a paren-aware transform, not a regex — `var(--x, rgba(0,0,0,.5))` nests parens and `[^)]+` would cut at the first one and leave `))` behind. Verified after: every changed line is a fallback strip and nothing else, and every var() reference still resolves. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UaYUaouG9jjhATyuxCKrQs
175 lines
4.3 KiB
Vue
175 lines
4.3 KiB
Vue
<script setup lang="ts">
|
||
import { computed } from "vue";
|
||
import type { DiffLine } from "@/composables/useAssist";
|
||
|
||
const props = defineProps<{
|
||
diff: DiffLine[];
|
||
}>();
|
||
|
||
const CONTEXT_LINES = 3;
|
||
const MIN_COLLAPSE = 6; // Only collapse if there are more than this many consecutive equal lines
|
||
|
||
type CollapseMarker = { type: 'collapse'; count: number };
|
||
type DisplayItem = DiffLine | CollapseMarker;
|
||
|
||
const insertions = computed(() => props.diff.filter(l => l.type === 'insert').length);
|
||
const deletions = computed(() => props.diff.filter(l => l.type === 'delete').length);
|
||
|
||
const displayItems = computed<DisplayItem[]>(() => {
|
||
const d = props.diff;
|
||
if (!d.length) return [];
|
||
|
||
// Mark which indices are within CONTEXT_LINES of a change
|
||
const shown = new Set<number>();
|
||
for (let i = 0; i < d.length; i++) {
|
||
if (d[i].type !== 'equal') {
|
||
for (let c = Math.max(0, i - CONTEXT_LINES); c <= Math.min(d.length - 1, i + CONTEXT_LINES); c++) {
|
||
shown.add(c);
|
||
}
|
||
}
|
||
}
|
||
|
||
// If nothing changed, show all
|
||
if (shown.size === 0) return d;
|
||
|
||
const result: DisplayItem[] = [];
|
||
let i = 0;
|
||
while (i < d.length) {
|
||
if (shown.has(i)) {
|
||
result.push(d[i]);
|
||
i++;
|
||
} else {
|
||
let count = 0;
|
||
while (i < d.length && !shown.has(i)) { count++; i++; }
|
||
if (count >= MIN_COLLAPSE) {
|
||
result.push({ type: 'collapse', count });
|
||
} else {
|
||
// Too short to collapse — show as-is
|
||
for (let k = i - count; k < i; k++) result.push(d[k]);
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
});
|
||
|
||
function markerFor(type: DiffLine['type']): string {
|
||
if (type === 'insert') return '+';
|
||
if (type === 'delete') return '−';
|
||
return ' ';
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="diff-view-full">
|
||
<div class="diff-summary-bar">
|
||
<span class="diff-summary-ins">+{{ insertions }} insertion{{ insertions !== 1 ? 's' : '' }}</span>
|
||
<span class="diff-summary-del">−{{ deletions }} deletion{{ deletions !== 1 ? 's' : '' }}</span>
|
||
</div>
|
||
<div class="diff-scroll">
|
||
<div v-if="!diff.length" class="diff-empty">No changes.</div>
|
||
<template v-for="(item, i) in displayItems" :key="i">
|
||
<div v-if="item.type === 'collapse'" class="diff-line diff-collapse">
|
||
<span class="diff-marker">⋯</span>
|
||
<span class="diff-text">{{ item.count }} unchanged line{{ item.count !== 1 ? 's' : '' }}</span>
|
||
</div>
|
||
<div
|
||
v-else
|
||
:class="['diff-line', `diff-${item.type}`]"
|
||
>
|
||
<span class="diff-marker">{{ markerFor(item.type) }}</span>
|
||
<span class="diff-text">{{ item.text }}</span>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.diff-view-full {
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
min-height: 0;
|
||
border: 1px solid var(--color-input-border);
|
||
border-radius: var(--radius-sm);
|
||
background: var(--color-bg);
|
||
overflow: hidden;
|
||
}
|
||
|
||
.diff-summary-bar {
|
||
position: sticky;
|
||
top: 0;
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
gap: 1rem;
|
||
padding: 0.4rem 0.75rem;
|
||
background: var(--color-bg-secondary);
|
||
border-bottom: 1px solid var(--color-border);
|
||
font-size: 0.78rem;
|
||
font-family: monospace;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.diff-summary-ins { color: var(--color-success); }
|
||
.diff-summary-del { color: var(--color-danger); }
|
||
|
||
.diff-scroll {
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow-y: auto;
|
||
padding: 0.3rem 0;
|
||
}
|
||
|
||
.diff-empty {
|
||
padding: 0.75rem;
|
||
font-size: 0.85rem;
|
||
color: var(--color-text-muted);
|
||
}
|
||
|
||
.diff-line {
|
||
display: flex;
|
||
align-items: baseline;
|
||
padding: 0.04rem 0.5rem;
|
||
line-height: 1.55;
|
||
font-family: monospace;
|
||
font-size: 0.82rem;
|
||
}
|
||
|
||
.diff-delete {
|
||
background: color-mix(in srgb, var(--color-danger) 12%, transparent);
|
||
color: var(--color-danger);
|
||
}
|
||
|
||
.diff-insert {
|
||
background: color-mix(in srgb, var(--color-success) 12%, transparent);
|
||
color: var(--color-success);
|
||
}
|
||
|
||
.diff-equal {
|
||
color: var(--color-text-muted);
|
||
}
|
||
|
||
.diff-collapse {
|
||
color: var(--color-text-muted);
|
||
opacity: 0.6;
|
||
border-top: 1px dashed var(--color-border);
|
||
border-bottom: 1px dashed var(--color-border);
|
||
padding-top: 0.2rem;
|
||
padding-bottom: 0.2rem;
|
||
}
|
||
|
||
.diff-marker {
|
||
flex-shrink: 0;
|
||
width: 1rem;
|
||
text-align: center;
|
||
user-select: none;
|
||
font-weight: 700;
|
||
}
|
||
|
||
.diff-text {
|
||
flex: 1;
|
||
white-space: pre-wrap;
|
||
word-break: break-word;
|
||
}
|
||
</style>
|