dsh-diff-approval 0.17.0 → 0.18.0
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.
- package/lib/client.js +835 -216
- package/lib/index.js +37 -3
- package/lib/types/client/ColorPicker.d.ts +23 -0
- package/lib/types/client/PendingPanel.d.ts +10 -1
- package/lib/types/client/locales.d.ts +24 -0
- package/lib/types/client/port.d.ts +2 -2
- package/lib/types/client/settings.d.ts +38 -0
- package/lib/types/client/slots.d.ts +2 -7
- package/lib/types/client/store.d.ts +2 -4
- package/lib/types/types.d.ts +5 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1325,9 +1325,25 @@ function apply(ctx, config) {
|
|
|
1325
1325
|
fileText: void 0
|
|
1326
1326
|
});
|
|
1327
1327
|
persistSession();
|
|
1328
|
+
const fullyResolved = updatedOld === entry.newText;
|
|
1329
|
+
if (fullyResolved && blockTarget.removeWhenResolved === true) {
|
|
1330
|
+
store.remove(blockTarget.id);
|
|
1331
|
+
pushUndo(blockTarget.sessionId, {
|
|
1332
|
+
id: entry.id,
|
|
1333
|
+
path: entry.path,
|
|
1334
|
+
entry: afterEntry,
|
|
1335
|
+
fileText: void 0
|
|
1336
|
+
}, {
|
|
1337
|
+
id: entry.id,
|
|
1338
|
+
path: entry.path,
|
|
1339
|
+
entry: void 0,
|
|
1340
|
+
fileText: void 0
|
|
1341
|
+
});
|
|
1342
|
+
persistSession(true);
|
|
1343
|
+
}
|
|
1328
1344
|
return {
|
|
1329
1345
|
ok: true,
|
|
1330
|
-
value:
|
|
1346
|
+
value: fullyResolved ? {
|
|
1331
1347
|
outcome: "kept",
|
|
1332
1348
|
resolved: true
|
|
1333
1349
|
} : { outcome: "kept" }
|
|
@@ -1378,9 +1394,25 @@ function apply(ctx, config) {
|
|
|
1378
1394
|
}
|
|
1379
1395
|
if (undo !== void 0) pushUndo(blockTarget.sessionId, undo.before, undo.after);
|
|
1380
1396
|
persistSession();
|
|
1397
|
+
const fullyResolved = normalizeEol(updatedNew) === normalizeEol(entry.oldText);
|
|
1398
|
+
if (fullyResolved && blockTarget.removeWhenResolved === true) {
|
|
1399
|
+
store.remove(blockTarget.id);
|
|
1400
|
+
pushUndo(blockTarget.sessionId, {
|
|
1401
|
+
id: entry.id,
|
|
1402
|
+
path: entry.path,
|
|
1403
|
+
entry: afterEntry,
|
|
1404
|
+
fileText: void 0
|
|
1405
|
+
}, {
|
|
1406
|
+
id: entry.id,
|
|
1407
|
+
path: entry.path,
|
|
1408
|
+
entry: void 0,
|
|
1409
|
+
fileText: void 0
|
|
1410
|
+
});
|
|
1411
|
+
persistSession(true);
|
|
1412
|
+
}
|
|
1381
1413
|
return {
|
|
1382
1414
|
ok: true,
|
|
1383
|
-
value:
|
|
1415
|
+
value: fullyResolved ? {
|
|
1384
1416
|
outcome: "reverted",
|
|
1385
1417
|
resolved: true
|
|
1386
1418
|
} : { outcome: "reverted" }
|
|
@@ -1625,6 +1657,7 @@ function blockTargetOf(payload) {
|
|
|
1625
1657
|
newStart,
|
|
1626
1658
|
newEnd
|
|
1627
1659
|
].every((value) => typeof value === "number" && Number.isFinite(value))) return void 0;
|
|
1660
|
+
const removeWhenResolved = payload.removeWhenResolved;
|
|
1628
1661
|
return {
|
|
1629
1662
|
...target,
|
|
1630
1663
|
block: {
|
|
@@ -1632,7 +1665,8 @@ function blockTargetOf(payload) {
|
|
|
1632
1665
|
oldEnd,
|
|
1633
1666
|
newStart,
|
|
1634
1667
|
newEnd
|
|
1635
|
-
}
|
|
1668
|
+
},
|
|
1669
|
+
removeWhenResolved: typeof removeWhenResolved === "boolean" ? removeWhenResolved : void 0
|
|
1636
1670
|
};
|
|
1637
1671
|
}
|
|
1638
1672
|
/** Narrow a wire payload to one keep/revert target. */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A compact HSV color picker (saturation/value square + hue bar + hex/RGB
|
|
2
|
+
* input). Avoids the browser-native color dialog, which cannot be themed, so
|
|
3
|
+
* it matches DSH. Pure helpers are exported for testing. */
|
|
4
|
+
/** Parse `#rrggbb` / `#rgb` / `rrggbb` / `rgb(r,g,b)` into a normalised
|
|
5
|
+
* `#rrggbb`, or `undefined` when the text is not a color. */
|
|
6
|
+
export declare function parseColor(input: string): string | undefined;
|
|
7
|
+
/** Convert a `#rrggbb` hex to HSV (h 0-360, s 0-1, v 0-1). */
|
|
8
|
+
export declare function hexToHsv(hex: string): {
|
|
9
|
+
h: number;
|
|
10
|
+
s: number;
|
|
11
|
+
v: number;
|
|
12
|
+
};
|
|
13
|
+
/** Convert HSV (h 0-360, s 0-1, v 0-1) to a `#rrggbb` hex. */
|
|
14
|
+
export declare function hsvToHex(h: number, s: number, v: number): string;
|
|
15
|
+
/** A draggable HSV picker: saturation/value square + hue bar + a hex/RGB text
|
|
16
|
+
* input. `onChange` reports a normalised `#rrggbb`; `onClose` fires after a
|
|
17
|
+
* committed text value so the caller can close the popover. */
|
|
18
|
+
export declare function ColorPicker({ value, onChange, onClose, ariaLabel, }: {
|
|
19
|
+
value: string;
|
|
20
|
+
onChange: (hex: string) => void;
|
|
21
|
+
onClose?: () => void;
|
|
22
|
+
ariaLabel: string;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
@@ -7,6 +7,15 @@ import type { DiffApprovalKey } from './locales.ts';
|
|
|
7
7
|
import { computeWholeFileDiff } from './whole-file-diff.ts';
|
|
8
8
|
import type { IntraRun } from './whole-file-diff.ts';
|
|
9
9
|
import { highlightLines } from './highlight.ts';
|
|
10
|
+
/** Normalize a path for comparison: forward slashes, no trailing slash. */
|
|
11
|
+
export declare function normalizeDiffPath(p: string): string;
|
|
12
|
+
/** Whether a produced-file chip path and a pending file path refer to the same
|
|
13
|
+
* file, tolerant of separator style (\\ vs /) and of a workspace-relative vs
|
|
14
|
+
* absolute form. `chipPath` is typically the harness's workspace-relative
|
|
15
|
+
* forward-slash path; `filePath` is the host's absolute native-separator path.
|
|
16
|
+
* Matching is case-insensitive so a Windows drive/segment case difference does
|
|
17
|
+
* not miss the file the user clicked. */
|
|
18
|
+
export declare function diffPathsMatch(chipPath: string, filePath: string, workspacePath: string | undefined): boolean;
|
|
10
19
|
/** The dsh shell's sidebar auto-collapse breakpoint (ui-layout columns.ts):
|
|
11
20
|
* below it the sidebar auto-collapses, and the file list floats on the same
|
|
12
21
|
* breakpoint so the two stay consistent. */
|
|
@@ -84,5 +93,5 @@ export declare const SplitDiff: import("react").ForwardRefExoticComponent<{
|
|
|
84
93
|
*/
|
|
85
94
|
export declare function selectedPlainText(): string | undefined;
|
|
86
95
|
/** Render the pending-edit review panel and its unified footer action. */
|
|
87
|
-
export declare function PendingPanel({ wide, useSessions, usePending, onRefresh, onKeep, onRevert, onBlockKeep, onBlockRevert, onOpen, onPasteReference, onUndo, onRedo, onImportVcs, onAckRedoCleared,
|
|
96
|
+
export declare function PendingPanel({ wide, useSessions, usePending, onRefresh, onKeep, onRevert, onBlockKeep, onBlockRevert, onOpen, onPasteReference, onUndo, onRedo, onImportVcs, onAckRedoCleared, collapseSidebar, t, }: PendingPanelProps): import("react").JSX.Element;
|
|
88
97
|
export {};
|
|
@@ -32,10 +32,22 @@ export declare const zh: {
|
|
|
32
32
|
'panel.splitModeDesc': string;
|
|
33
33
|
'panel.navLeadRows': string;
|
|
34
34
|
'panel.navLeadRowsDesc': string;
|
|
35
|
+
'panel.diffFontSize': string;
|
|
36
|
+
'panel.diffFontSizeDesc': string;
|
|
37
|
+
'panel.diffLineHeight': string;
|
|
38
|
+
'panel.diffLineHeightDesc': string;
|
|
39
|
+
'panel.diffAddColor': string;
|
|
40
|
+
'panel.diffAddColorDesc': string;
|
|
41
|
+
'panel.diffDelColor': string;
|
|
42
|
+
'panel.diffDelColorDesc': string;
|
|
35
43
|
'panel.quickSummon': string;
|
|
36
44
|
'panel.quickSummonDesc': string;
|
|
37
45
|
'panel.recordShortcut': string;
|
|
38
46
|
'settings.keybindings': string;
|
|
47
|
+
'settings.keybindingsDesc': string;
|
|
48
|
+
'settings.diffView': string;
|
|
49
|
+
'settings.diffViewDesc': string;
|
|
50
|
+
'settings.diffPreview': string;
|
|
39
51
|
'panel.keyDesc': string;
|
|
40
52
|
'panel.key.jumpUp': string;
|
|
41
53
|
'panel.key.jumpDown': string;
|
|
@@ -134,10 +146,22 @@ export declare const en: {
|
|
|
134
146
|
'panel.splitModeDesc': string;
|
|
135
147
|
'panel.navLeadRows': string;
|
|
136
148
|
'panel.navLeadRowsDesc': string;
|
|
149
|
+
'panel.diffFontSize': string;
|
|
150
|
+
'panel.diffFontSizeDesc': string;
|
|
151
|
+
'panel.diffLineHeight': string;
|
|
152
|
+
'panel.diffLineHeightDesc': string;
|
|
153
|
+
'panel.diffAddColor': string;
|
|
154
|
+
'panel.diffAddColorDesc': string;
|
|
155
|
+
'panel.diffDelColor': string;
|
|
156
|
+
'panel.diffDelColorDesc': string;
|
|
137
157
|
'panel.quickSummon': string;
|
|
138
158
|
'panel.quickSummonDesc': string;
|
|
139
159
|
'panel.recordShortcut': string;
|
|
140
160
|
'settings.keybindings': string;
|
|
161
|
+
'settings.keybindingsDesc': string;
|
|
162
|
+
'settings.diffView': string;
|
|
163
|
+
'settings.diffViewDesc': string;
|
|
164
|
+
'settings.diffPreview': string;
|
|
141
165
|
'panel.keyDesc': string;
|
|
142
166
|
'panel.key.jumpUp': string;
|
|
143
167
|
'panel.key.jumpDown': string;
|
|
@@ -17,9 +17,9 @@ export interface DiffApprovalPort {
|
|
|
17
17
|
/** Revert one operation. */
|
|
18
18
|
revert(sessionId: SessionId, id: string): Promise<DiffApprovalActionValue>;
|
|
19
19
|
/** Keep one diff block (accept its change into the tracked baseline). */
|
|
20
|
-
blockKeep(sessionId: SessionId, id: string, block: DiffApprovalBlockRange): Promise<DiffApprovalActionValue>;
|
|
20
|
+
blockKeep(sessionId: SessionId, id: string, block: DiffApprovalBlockRange, removeWhenResolved?: boolean): Promise<DiffApprovalActionValue>;
|
|
21
21
|
/** Revert one diff block (restore its old lines in the file). */
|
|
22
|
-
blockRevert(sessionId: SessionId, id: string, block: DiffApprovalBlockRange): Promise<DiffApprovalActionValue>;
|
|
22
|
+
blockRevert(sessionId: SessionId, id: string, block: DiffApprovalBlockRange, removeWhenResolved?: boolean): Promise<DiffApprovalActionValue>;
|
|
23
23
|
/** Undo the session's last keep/revert (restore the before state). */
|
|
24
24
|
undo(sessionId: SessionId): Promise<DiffApprovalActionValue>;
|
|
25
25
|
/** Redo the session's last undone keep/revert (re-apply the after state). */
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
export declare const NAV_LEAD_ROWS_DEFAULT = 2;
|
|
4
4
|
export declare const NAV_LEAD_ROWS_MIN = 0;
|
|
5
5
|
export declare const NAV_LEAD_ROWS_MAX = 10;
|
|
6
|
+
/** The code block's fixed row height used by the virtual window and jump math.
|
|
7
|
+
* A hardcoded px base; the settings UI offers 10–36 (a low floor would clip the
|
|
8
|
+
* code text, so the range is loose but never degenerate). */
|
|
9
|
+
export declare const DIFF_LINE_HEIGHT_DEFAULT = 22;
|
|
10
|
+
export declare const DIFF_LINE_HEIGHT_MIN = 10;
|
|
11
|
+
export declare const DIFF_LINE_HEIGHT_MAX = 36;
|
|
12
|
+
/** Font-size scale range: a percentage of the current value, stepped by 10. */
|
|
13
|
+
export declare const DIFF_FONT_SCALE_DEFAULT = 100;
|
|
14
|
+
export declare const DIFF_FONT_SCALE_MIN = 50;
|
|
15
|
+
export declare const DIFF_FONT_SCALE_MAX = 200;
|
|
6
16
|
/**
|
|
7
17
|
* Whether copying a reference should also paste it into the chat input and
|
|
8
18
|
* focus it. Defaults to on; only an explicit `'0'` disables it.
|
|
@@ -40,6 +50,34 @@ export declare function setWrapEnabled(lang: string, value: boolean): void;
|
|
|
40
50
|
export declare function tabWidth(): number;
|
|
41
51
|
/** Persist the diff's tab width (in spaces). */
|
|
42
52
|
export declare function setTabWidth(value: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* The diff code font size as a percentage of the current (theme) size. Defaults
|
|
55
|
+
* to 100 (the current look); the settings UI steps it by ±10.
|
|
56
|
+
* @returns the font-size scale, as a percentage (e.g. 100, 110, 90).
|
|
57
|
+
*/
|
|
58
|
+
export declare function diffFontScale(): number;
|
|
59
|
+
/** Persist the diff's code font-size scale (a percentage). */
|
|
60
|
+
export declare function setDiffFontScale(value: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* The diff code line height in px (the fixed row height the virtual window and
|
|
63
|
+
* jump math are keyed to). Defaults to 22 (the pre-customization value).
|
|
64
|
+
* @returns the line height in px.
|
|
65
|
+
*/
|
|
66
|
+
export declare function diffLineHeight(): number;
|
|
67
|
+
/** Persist the diff's code line height (px). */
|
|
68
|
+
export declare function setDiffLineHeight(value: number): void;
|
|
69
|
+
/** The added-line base color the user chose, or `undefined` (theme color). */
|
|
70
|
+
export declare function diffAddColor(): string | undefined;
|
|
71
|
+
/** Persist the added-line base color (a hex like `#22c55e`). */
|
|
72
|
+
export declare function setDiffAddColor(value: string): void;
|
|
73
|
+
/** The removed-line base color the user chose, or `undefined` (theme color). */
|
|
74
|
+
export declare function diffDelColor(): string | undefined;
|
|
75
|
+
/** Persist the removed-line base color (a hex like `#ef4444`). */
|
|
76
|
+
export declare function setDiffDelColor(value: string): void;
|
|
77
|
+
/** The theme's added-line base color, for the settings swatch default. */
|
|
78
|
+
export declare function currentDiffAddColor(): string;
|
|
79
|
+
/** The theme's removed-line base color, for the settings swatch default. */
|
|
80
|
+
export declare function currentDiffDelColor(): string;
|
|
43
81
|
/**
|
|
44
82
|
* Whether the whole-file diff view uses the two-column (side-by-side) layout.
|
|
45
83
|
* Default off (single column): the unified diff. Only an explicit `'1'` enables
|
|
@@ -20,9 +20,6 @@ export interface PendingDiffSnapshot {
|
|
|
20
20
|
* superseded the redo history; the panel surfaces it once (deferred if the
|
|
21
21
|
* panel is closed) via a bottom-right notice. */
|
|
22
22
|
redoCleared?: boolean;
|
|
23
|
-
/** Latched file id whose last block just resolved; the panel prompts once to
|
|
24
|
-
* remove-or-keep it, then acknowledges to clear the latch. */
|
|
25
|
-
justResolved?: string | undefined;
|
|
26
23
|
}
|
|
27
24
|
/** The injected face the panel component receives from the plugin body. */
|
|
28
25
|
export interface PendingPanelFace {
|
|
@@ -37,9 +34,9 @@ export interface PendingPanelFace {
|
|
|
37
34
|
/** Revert one operation (restore its prior content, or remove a created file). */
|
|
38
35
|
onRevert: (sessionId: SessionId, id: string) => Promise<void>;
|
|
39
36
|
/** Keep one diff block (accept its change into the tracked baseline). */
|
|
40
|
-
onBlockKeep: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange) => Promise<void>;
|
|
37
|
+
onBlockKeep: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange, removeWhenResolved?: boolean) => Promise<void>;
|
|
41
38
|
/** Revert one diff block (restore its old lines in the file). */
|
|
42
|
-
onBlockRevert: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange) => Promise<void>;
|
|
39
|
+
onBlockRevert: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange, removeWhenResolved?: boolean) => Promise<void>;
|
|
43
40
|
/** Open one file with its default application or reveal it in the folder. */
|
|
44
41
|
onOpen: (sessionId: SessionId, id: string, action: DiffApprovalOpenAction) => Promise<void>;
|
|
45
42
|
/** Paste a copied reference into the session's chat input and focus it. */
|
|
@@ -52,8 +49,6 @@ export interface PendingPanelFace {
|
|
|
52
49
|
onImportVcs: (sessionId: SessionId, includeUntracked: boolean) => Promise<VcsImportValue>;
|
|
53
50
|
/** Acknowledge the redo-cleared notice so it is only surfaced once. */
|
|
54
51
|
onAckRedoCleared: () => void;
|
|
55
|
-
/** Acknowledge the just-resolved prompt so it is only surfaced once. */
|
|
56
|
-
onAckJustResolved: () => void;
|
|
57
52
|
/** Collapse the DSH sidebar (no-op when already collapsed) before the modal
|
|
58
53
|
* opens or fullscreens, so an expanded sidebar can't overlap the modal. */
|
|
59
54
|
collapseSidebar: () => void;
|
|
@@ -19,9 +19,9 @@ export interface PendingDiffStore extends HostObservable<PendingDiffSnapshot> {
|
|
|
19
19
|
/** Revert one operation. */
|
|
20
20
|
revert: (sessionId: SessionId, id: string) => Promise<void>;
|
|
21
21
|
/** Keep one diff block, then refresh so the entry's diff reflects the accept. */
|
|
22
|
-
blockKeep: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange) => Promise<void>;
|
|
22
|
+
blockKeep: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange, removeWhenResolved?: boolean) => Promise<void>;
|
|
23
23
|
/** Revert one diff block, then refresh so the entry's diff reflects the undo. */
|
|
24
|
-
blockRevert: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange) => Promise<void>;
|
|
24
|
+
blockRevert: (sessionId: SessionId, id: string, block: DiffApprovalBlockRange, removeWhenResolved?: boolean) => Promise<void>;
|
|
25
25
|
/** Undo the session's last keep/revert, then refresh; resolves to the affected entry id when it is still pending. */
|
|
26
26
|
undo: (sessionId: SessionId) => Promise<string | undefined>;
|
|
27
27
|
/** Redo the session's last undone keep/revert, then refresh; resolves to the affected entry id when it is still pending. */
|
|
@@ -34,8 +34,6 @@ export interface PendingDiffStore extends HostObservable<PendingDiffSnapshot> {
|
|
|
34
34
|
reset: () => void;
|
|
35
35
|
/** Acknowledge a redo-cleared notice so the panel surfaces it only once. */
|
|
36
36
|
clearRedoCleared: () => void;
|
|
37
|
-
/** Acknowledge the just-resolved prompt so it is only surfaced once. */
|
|
38
|
-
clearJustResolved: () => void;
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
39
|
* Create the store over the review-channel port.
|
package/lib/types/types.d.ts
CHANGED
|
@@ -88,6 +88,11 @@ export interface DiffApprovalBlockTarget {
|
|
|
88
88
|
sessionId: SessionId;
|
|
89
89
|
id: string;
|
|
90
90
|
block: DiffApprovalBlockRange;
|
|
91
|
+
/** When true and this action clears the entry's last remaining change, remove
|
|
92
|
+
* the entry from the pending list as part of the same request. When false or
|
|
93
|
+
* absent, a fully-resolved entry stays listed (the panel's remove-and-keep
|
|
94
|
+
* prompt sets this from the user's choice). */
|
|
95
|
+
removeWhenResolved?: boolean | undefined;
|
|
91
96
|
}
|
|
92
97
|
/** Outcome of one keep/revert/undo/redo request. */
|
|
93
98
|
export type DiffApprovalActionOutcome = 'kept' | 'reverted' | 'missing' | 'undone' | 'redone' | 'nothing';
|
package/package.json
CHANGED