pi-cc-extensions 0.8.14 → 0.8.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2138,6 +2138,8 @@ function createCcstyleTool(
|
|
|
2138
2138
|
setToolVisualState(context, isError ? "error" : "success");
|
|
2139
2139
|
const expanded = isToolExpanded(options, context);
|
|
2140
2140
|
if (shouldRenderRichDiff(config.mode, toolName, Boolean(isError))) {
|
|
2141
|
+
// Pass getter so Diff indicator / wrap / limits update on the next paint
|
|
2142
|
+
// without recreating the tool result component.
|
|
2141
2143
|
const richResult = renderRichToolResult(
|
|
2142
2144
|
toolName,
|
|
2143
2145
|
result,
|
|
@@ -2145,7 +2147,7 @@ function createCcstyleTool(
|
|
|
2145
2147
|
theme,
|
|
2146
2148
|
context,
|
|
2147
2149
|
writeExecutionMetadata,
|
|
2148
|
-
getToolDisplayConfig
|
|
2150
|
+
getToolDisplayConfig,
|
|
2149
2151
|
);
|
|
2150
2152
|
if (richResult) return richResult;
|
|
2151
2153
|
}
|
|
@@ -1312,6 +1312,25 @@ function resolveDiffIndicatorMode(
|
|
|
1312
1312
|
return config.diffIndicatorMode ?? DEFAULT_TOOL_DISPLAY_CONFIG.diffIndicatorMode;
|
|
1313
1313
|
}
|
|
1314
1314
|
|
|
1315
|
+
/** Snapshot or live getter — panel changes must apply on the next paint. */
|
|
1316
|
+
export type DisplayConfigInput = ToolDisplayConfig | (() => ToolDisplayConfig);
|
|
1317
|
+
|
|
1318
|
+
function resolveLiveDisplayConfig(input: DisplayConfigInput): ToolDisplayConfig {
|
|
1319
|
+
return typeof input === "function" ? input() : input;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/** Cache key fragment so indicator/wrap/limits invalidate without host recreate. */
|
|
1323
|
+
function displayConfigCacheKey(config: ToolDisplayConfig): string {
|
|
1324
|
+
return [
|
|
1325
|
+
config.diffViewMode,
|
|
1326
|
+
config.diffIndicatorMode,
|
|
1327
|
+
String(config.diffSplitMinWidth),
|
|
1328
|
+
String(config.diffCollapsedLines),
|
|
1329
|
+
config.diffWordWrap ? "1" : "0",
|
|
1330
|
+
String(config.expandedPreviewMaxLines),
|
|
1331
|
+
].join(":");
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1315
1334
|
function resolveIndicatorGlyph(
|
|
1316
1335
|
kind: DiffLineKind,
|
|
1317
1336
|
indicatorMode: DiffIndicatorMode,
|
|
@@ -2350,24 +2369,38 @@ function createDiffRenderCache() {
|
|
|
2350
2369
|
let cachedWidth: number | undefined;
|
|
2351
2370
|
let cachedExpanded: boolean | undefined;
|
|
2352
2371
|
let cachedMode: DiffPresentationMode | undefined;
|
|
2372
|
+
let cachedConfigKey: string | undefined;
|
|
2353
2373
|
let cachedLines: string[] | undefined;
|
|
2354
2374
|
|
|
2355
2375
|
return {
|
|
2356
|
-
get(
|
|
2376
|
+
get(
|
|
2377
|
+
width: number,
|
|
2378
|
+
expanded: boolean,
|
|
2379
|
+
mode: DiffPresentationMode,
|
|
2380
|
+
configKey: string,
|
|
2381
|
+
): string[] | undefined {
|
|
2357
2382
|
if (
|
|
2358
2383
|
cachedLines &&
|
|
2359
2384
|
cachedWidth === width &&
|
|
2360
2385
|
cachedExpanded === expanded &&
|
|
2361
|
-
cachedMode === mode
|
|
2386
|
+
cachedMode === mode &&
|
|
2387
|
+
cachedConfigKey === configKey
|
|
2362
2388
|
) {
|
|
2363
2389
|
return cachedLines;
|
|
2364
2390
|
}
|
|
2365
2391
|
return undefined;
|
|
2366
2392
|
},
|
|
2367
|
-
set(
|
|
2393
|
+
set(
|
|
2394
|
+
width: number,
|
|
2395
|
+
expanded: boolean,
|
|
2396
|
+
mode: DiffPresentationMode,
|
|
2397
|
+
configKey: string,
|
|
2398
|
+
lines: string[],
|
|
2399
|
+
): string[] {
|
|
2368
2400
|
cachedWidth = width;
|
|
2369
2401
|
cachedExpanded = expanded;
|
|
2370
2402
|
cachedMode = mode;
|
|
2403
|
+
cachedConfigKey = configKey;
|
|
2371
2404
|
cachedLines = lines;
|
|
2372
2405
|
return lines;
|
|
2373
2406
|
},
|
|
@@ -2375,6 +2408,7 @@ function createDiffRenderCache() {
|
|
|
2375
2408
|
cachedWidth = undefined;
|
|
2376
2409
|
cachedExpanded = undefined;
|
|
2377
2410
|
cachedMode = undefined;
|
|
2411
|
+
cachedConfigKey = undefined;
|
|
2378
2412
|
cachedLines = undefined;
|
|
2379
2413
|
},
|
|
2380
2414
|
};
|
|
@@ -2383,7 +2417,7 @@ function createDiffRenderCache() {
|
|
|
2383
2417
|
export function renderEditDiffResult(
|
|
2384
2418
|
details: unknown,
|
|
2385
2419
|
options: DiffRenderOptions,
|
|
2386
|
-
config:
|
|
2420
|
+
config: DisplayConfigInput,
|
|
2387
2421
|
theme: DiffTheme,
|
|
2388
2422
|
fallbackText: string,
|
|
2389
2423
|
): Component {
|
|
@@ -2418,16 +2452,19 @@ export function renderEditDiffResult(
|
|
|
2418
2452
|
const containerBgAnsi = undefined;
|
|
2419
2453
|
const language = resolveLanguageFromPath(options.filePath);
|
|
2420
2454
|
const highlightLine = createCodeLineHighlighter(language);
|
|
2421
|
-
const wordWrap = config.diffWordWrap;
|
|
2422
|
-
const indicatorMode = resolveDiffIndicatorMode(config);
|
|
2423
2455
|
|
|
2424
2456
|
const cache = createDiffRenderCache();
|
|
2425
2457
|
|
|
2426
2458
|
return {
|
|
2427
2459
|
render(width: number): string[] {
|
|
2460
|
+
// Live config: panel can change indicator/wrap/limits after this component is created.
|
|
2461
|
+
const live = resolveLiveDisplayConfig(config);
|
|
2462
|
+
const wordWrap = live.diffWordWrap;
|
|
2463
|
+
const indicatorMode = resolveDiffIndicatorMode(live);
|
|
2464
|
+
const configKey = displayConfigCacheKey(live);
|
|
2428
2465
|
const safeWidth = normalizeDiffRenderWidth(width);
|
|
2429
|
-
const mode = resolveDiffPresentationMode(
|
|
2430
|
-
const cached = cache.get(safeWidth, options.expanded, mode);
|
|
2466
|
+
const mode = resolveDiffPresentationMode(live, safeWidth, canRenderSplitLayout(safeWidth));
|
|
2467
|
+
const cached = cache.get(safeWidth, options.expanded, mode, configKey);
|
|
2431
2468
|
if (cached) {
|
|
2432
2469
|
return cached;
|
|
2433
2470
|
}
|
|
@@ -2437,6 +2474,7 @@ export function renderEditDiffResult(
|
|
|
2437
2474
|
safeWidth,
|
|
2438
2475
|
options.expanded,
|
|
2439
2476
|
mode,
|
|
2477
|
+
configKey,
|
|
2440
2478
|
clampDiffLinesToWidth(
|
|
2441
2479
|
renderSingleDiffRow(
|
|
2442
2480
|
buildDiffSummaryText(parsed.stats, safeWidth),
|
|
@@ -2452,8 +2490,8 @@ export function renderEditDiffResult(
|
|
|
2452
2490
|
const headerRows = renderHeaderRows(parsed.stats, mode, safeWidth, theme);
|
|
2453
2491
|
const displayLimit = resolveDiffDisplayLimit(
|
|
2454
2492
|
options.expanded,
|
|
2455
|
-
|
|
2456
|
-
|
|
2493
|
+
live.diffCollapsedLines,
|
|
2494
|
+
live.expandedPreviewMaxLines,
|
|
2457
2495
|
);
|
|
2458
2496
|
const processBudget = resolveDiffProcessBudget(displayLimit, wordWrap);
|
|
2459
2497
|
// Only highlight/render a prefix that can fill the display limit; full-diff
|
|
@@ -2486,8 +2524,8 @@ export function renderEditDiffResult(
|
|
|
2486
2524
|
bodyRows,
|
|
2487
2525
|
safeWidth,
|
|
2488
2526
|
options.expanded,
|
|
2489
|
-
|
|
2490
|
-
|
|
2527
|
+
live.diffCollapsedLines,
|
|
2528
|
+
live.expandedPreviewMaxLines,
|
|
2491
2529
|
parsed.stats.hunks,
|
|
2492
2530
|
theme,
|
|
2493
2531
|
unprocessedLogicalRows,
|
|
@@ -2499,7 +2537,7 @@ export function renderEditDiffResult(
|
|
|
2499
2537
|
: [...headerRows.map((row) => row.text), ...bodyWithLimit];
|
|
2500
2538
|
|
|
2501
2539
|
const clampedLines = clampDiffLinesToWidth(renderedLines, safeWidth);
|
|
2502
|
-
return cache.set(safeWidth, options.expanded, mode, clampedLines);
|
|
2540
|
+
return cache.set(safeWidth, options.expanded, mode, configKey, clampedLines);
|
|
2503
2541
|
},
|
|
2504
2542
|
invalidate: cache.invalidate,
|
|
2505
2543
|
};
|
|
@@ -2753,7 +2791,7 @@ function renderWriteOverwriteGuardRows(
|
|
|
2753
2791
|
export function renderWriteDiffResult(
|
|
2754
2792
|
content: string | undefined,
|
|
2755
2793
|
options: DiffRenderOptions,
|
|
2756
|
-
config:
|
|
2794
|
+
config: DisplayConfigInput,
|
|
2757
2795
|
theme: DiffTheme,
|
|
2758
2796
|
fallbackText: string,
|
|
2759
2797
|
): Component {
|
|
@@ -2782,8 +2820,6 @@ export function renderWriteDiffResult(
|
|
|
2782
2820
|
const containerBgAnsi = undefined;
|
|
2783
2821
|
const language = resolveLanguageFromPath(filePath);
|
|
2784
2822
|
const highlightLine = createCodeLineHighlighter(language);
|
|
2785
|
-
const wordWrap = config.diffWordWrap;
|
|
2786
|
-
const indicatorMode = resolveDiffIndicatorMode(config);
|
|
2787
2823
|
|
|
2788
2824
|
let detailedData: WriteDiffData | undefined;
|
|
2789
2825
|
const cache = createDiffRenderCache();
|
|
@@ -2801,9 +2837,14 @@ export function renderWriteDiffResult(
|
|
|
2801
2837
|
|
|
2802
2838
|
return {
|
|
2803
2839
|
render(width: number): string[] {
|
|
2840
|
+
// Live config: panel can change indicator/wrap/limits after this component is created.
|
|
2841
|
+
const live = resolveLiveDisplayConfig(config);
|
|
2842
|
+
const wordWrap = live.diffWordWrap;
|
|
2843
|
+
const indicatorMode = resolveDiffIndicatorMode(live);
|
|
2844
|
+
const configKey = displayConfigCacheKey(live);
|
|
2804
2845
|
const safeWidth = normalizeDiffRenderWidth(width);
|
|
2805
2846
|
const resolvedMode = resolveDiffPresentationMode(
|
|
2806
|
-
|
|
2847
|
+
live,
|
|
2807
2848
|
safeWidth,
|
|
2808
2849
|
canRenderSplitLayout(safeWidth),
|
|
2809
2850
|
);
|
|
@@ -2812,7 +2853,7 @@ export function renderWriteDiffResult(
|
|
|
2812
2853
|
: resolvedMode === "split"
|
|
2813
2854
|
? "unified"
|
|
2814
2855
|
: resolvedMode;
|
|
2815
|
-
const cached = cache.get(safeWidth, options.expanded, mode);
|
|
2856
|
+
const cached = cache.get(safeWidth, options.expanded, mode, configKey);
|
|
2816
2857
|
if (cached) {
|
|
2817
2858
|
return cached;
|
|
2818
2859
|
}
|
|
@@ -2832,6 +2873,7 @@ export function renderWriteDiffResult(
|
|
|
2832
2873
|
safeWidth,
|
|
2833
2874
|
options.expanded,
|
|
2834
2875
|
mode,
|
|
2876
|
+
configKey,
|
|
2835
2877
|
clampDiffLinesToWidth(
|
|
2836
2878
|
[header, ...renderWriteOverwriteGuardRows(overwriteGuard, safeWidth, theme)],
|
|
2837
2879
|
safeWidth,
|
|
@@ -2856,6 +2898,7 @@ export function renderWriteDiffResult(
|
|
|
2856
2898
|
safeWidth,
|
|
2857
2899
|
options.expanded,
|
|
2858
2900
|
mode,
|
|
2901
|
+
configKey,
|
|
2859
2902
|
clampDiffLinesToWidth(summaryRows, safeWidth),
|
|
2860
2903
|
);
|
|
2861
2904
|
}
|
|
@@ -2863,8 +2906,8 @@ export function renderWriteDiffResult(
|
|
|
2863
2906
|
const data = getDetailedData();
|
|
2864
2907
|
const displayLimit = resolveDiffDisplayLimit(
|
|
2865
2908
|
options.expanded,
|
|
2866
|
-
|
|
2867
|
-
|
|
2909
|
+
live.diffCollapsedLines,
|
|
2910
|
+
live.expandedPreviewMaxLines,
|
|
2868
2911
|
);
|
|
2869
2912
|
const processBudget = resolveDiffProcessBudget(displayLimit, wordWrap);
|
|
2870
2913
|
const entryBudget = takeEntriesForLineBudget(data.entries, processBudget);
|
|
@@ -2901,8 +2944,8 @@ export function renderWriteDiffResult(
|
|
|
2901
2944
|
bodyRows,
|
|
2902
2945
|
safeWidth,
|
|
2903
2946
|
options.expanded,
|
|
2904
|
-
|
|
2905
|
-
|
|
2947
|
+
live.diffCollapsedLines,
|
|
2948
|
+
live.expandedPreviewMaxLines,
|
|
2906
2949
|
data.hunkCount,
|
|
2907
2950
|
theme,
|
|
2908
2951
|
unprocessedLogicalRows,
|
|
@@ -2911,7 +2954,7 @@ export function renderWriteDiffResult(
|
|
|
2911
2954
|
const renderedLines =
|
|
2912
2955
|
mode === "unified" ? [header, frame, ...bodyWithLimit, frame] : [header, ...bodyWithLimit];
|
|
2913
2956
|
const finalLines = clampDiffLinesToWidth(renderedLines, safeWidth);
|
|
2914
|
-
return cache.set(safeWidth, options.expanded, mode, finalLines);
|
|
2957
|
+
return cache.set(safeWidth, options.expanded, mode, configKey, finalLines);
|
|
2915
2958
|
},
|
|
2916
2959
|
invalidate: cache.invalidate,
|
|
2917
2960
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { createWriteToolDefinition, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
renderEditDiffResult,
|
|
5
|
+
renderWriteDiffResult,
|
|
6
|
+
type DisplayConfigInput,
|
|
7
|
+
} from "./diff-renderer.ts";
|
|
8
|
+
import { DEFAULT_TOOL_DISPLAY_CONFIG } from "./types.ts";
|
|
5
9
|
import { executeWriteWithMetadata, WriteExecutionMetadataStore } from "./write-execution.ts";
|
|
6
10
|
|
|
7
11
|
function resultText(result: any): string {
|
|
@@ -34,7 +38,8 @@ export function renderRichToolResult(
|
|
|
34
38
|
theme: any,
|
|
35
39
|
context: any,
|
|
36
40
|
writeMetadata: WriteExecutionMetadataStore,
|
|
37
|
-
|
|
41
|
+
/** Plain snapshot or live getter — getter lets /ccstyle panel changes repaint existing diffs. */
|
|
42
|
+
displayConfig: DisplayConfigInput = DEFAULT_TOOL_DISPLAY_CONFIG,
|
|
38
43
|
): any | undefined {
|
|
39
44
|
if (options?.isPartial || options?.isError || context?.isError) return undefined;
|
|
40
45
|
const expanded = options?.expanded === true || context?.expanded === true;
|
|
@@ -110,4 +115,5 @@ export {
|
|
|
110
115
|
type DiffViewMode,
|
|
111
116
|
type DiffIndicatorMode,
|
|
112
117
|
} from "./types.ts";
|
|
118
|
+
export type { DisplayConfigInput } from "./diff-renderer.ts";
|
|
113
119
|
export { WriteExecutionMetadataStore } from "./write-execution.ts";
|
package/package.json
CHANGED