Skip to content

Commit 59377c8

Browse files
authored
Merge pull request #2871 from continuedev/dev
Find widget
2 parents 17620fc + 447d1f6 commit 59377c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1662
-882
lines changed

core/protocol/ideWebview.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
2323
text: string;
2424
streamId: string;
2525
curSelectedModelTitle: string;
26-
filepath: string;
26+
filepath?: string;
2727
},
2828
void,
2929
];
@@ -60,7 +60,9 @@ export type EditStatus = "not-started" | "streaming" | "accepting" | "done";
6060

6161
export interface ApplyState {
6262
streamId: string;
63-
status: "streaming" | "done" | "closed";
63+
status?: "streaming" | "done" | "closed";
64+
numDiffs?: number;
65+
filepath?: string;
6466
}
6567

6668
export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {

core/protocol/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {
22
ToCoreFromWebviewProtocol,
33
ToWebviewFromCoreProtocol,
4-
} from "./coreWebview.js";
5-
import { ToWebviewOrCoreFromIdeProtocol } from "./ide.js";
6-
import { ToCoreFromIdeProtocol, ToIdeFromCoreProtocol } from "./ideCore.js";
4+
} from "./coreWebview";
5+
import { ToWebviewOrCoreFromIdeProtocol } from "./ide";
6+
import { ToCoreFromIdeProtocol, ToIdeFromCoreProtocol } from "./ideCore";
77
import {
88
ToIdeFromWebviewProtocol,
99
ToWebviewFromIdeProtocol,
10-
} from "./ideWebview.js";
10+
} from "./ideWebview";
1111

1212
export type IProtocol = Record<string, [any, any]>;
1313

extensions/vscode/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/vscode/src/ContinueGUIWebviewViewProvider.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,7 @@ export class ContinueGUIWebviewViewProvider
182182
</head>
183183
<body>
184184
<div id="root"></div>
185-
186-
${`<script>
187-
function log(level, ...args) {
188-
const text = args.map(arg =>
189-
typeof arg === 'object' ? JSON.stringify(arg) : String(arg)
190-
).join(' ');
191-
vscode.postMessage({ messageType: 'log', level, text, messageId: "log" });
192-
}
193-
194-
window.console.log = (...args) => log('log', ...args);
195-
window.console.info = (...args) => log('info', ...args);
196-
window.console.warn = (...args) => log('warn', ...args);
197-
window.console.error = (...args) => log('error', ...args);
198-
window.console.debug = (...args) => log('debug', ...args);
199-
200-
console.debug('Logging initialized');
201-
</script>`}
185+
202186
${
203187
inDevelopmentMode
204188
? `<script type="module">

extensions/vscode/src/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ const commandsMap: (
283283

284284
verticalDiffManager.clearForFilepath(fullPath, true);
285285
await diffManager.acceptDiff(fullPath);
286+
286287
await sidebar.webviewProtocol.request("setEditStatus", {
287288
status: "done",
288289
});

extensions/vscode/src/diff/vertical/handler.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,25 @@ import type { VerticalDiffCodeLens } from "./manager";
1313
export interface VerticalDiffHandlerOptions {
1414
input?: string;
1515
instant?: boolean;
16-
onStatusUpdate: (status: ApplyState["status"]) => void;
16+
onStatusUpdate: (
17+
status?: ApplyState["status"],
18+
numDiffs?: ApplyState["numDiffs"],
19+
) => void;
1720
}
1821

1922
export class VerticalDiffHandler implements vscode.Disposable {
2023
private currentLineIndex: number;
2124
private cancelled = false;
22-
25+
private newLinesAdded = 0;
26+
private get diffBlocks() {
27+
return this.editorToVerticalDiffCodeLens.get(this.filepath) || [];
28+
}
2329
public get range(): vscode.Range {
2430
const startLine = Math.min(this.startLine, this.endLine);
2531
const endLine = Math.max(this.startLine, this.endLine);
2632
return new vscode.Range(startLine, 0, endLine, Number.MAX_SAFE_INTEGER);
2733
}
2834

29-
private newLinesAdded = 0;
30-
3135
constructor(
3236
private startLine: number,
3337
private endLine: number,
@@ -92,15 +96,13 @@ export class VerticalDiffHandler implements vscode.Disposable {
9296
}
9397

9498
if (this.deletionBuffer.length || this.insertedInCurrentBlock > 0) {
95-
const blocks = this.editorToVerticalDiffCodeLens.get(this.filepath) || [];
96-
97-
blocks.push({
99+
this.diffBlocks.push({
98100
start: this.currentLineIndex - this.insertedInCurrentBlock,
99101
numRed: this.deletionBuffer.length,
100102
numGreen: this.insertedInCurrentBlock,
101103
});
102104

103-
this.editorToVerticalDiffCodeLens.set(this.filepath, blocks);
105+
this.editorToVerticalDiffCodeLens.set(this.filepath, this.diffBlocks);
104106
}
105107

106108
if (this.deletionBuffer.length === 0) {
@@ -267,7 +269,7 @@ export class VerticalDiffHandler implements vscode.Disposable {
267269
},
268270
);
269271

270-
this.options.onStatusUpdate("closed");
272+
this.options.onStatusUpdate("closed", this.diffBlocks.length);
271273

272274
this.cancelled = true;
273275
this.refreshCodeLens();
@@ -336,7 +338,7 @@ export class VerticalDiffHandler implements vscode.Disposable {
336338
}
337339

338340
async run(diffLineGenerator: AsyncGenerator<DiffLine>) {
339-
let diffLines = []
341+
let diffLines = [];
340342
try {
341343
// As an indicator of loading
342344
this.updateIndexLineDecorations();
@@ -345,7 +347,7 @@ export class VerticalDiffHandler implements vscode.Disposable {
345347
if (this.isCancelled) {
346348
return;
347349
}
348-
diffLines.push(diffLine)
350+
diffLines.push(diffLine);
349351
await this.queueDiffLine(diffLine);
350352
}
351353

@@ -355,7 +357,7 @@ export class VerticalDiffHandler implements vscode.Disposable {
355357

356358
this.refreshCodeLens();
357359

358-
this.options.onStatusUpdate("done");
360+
this.options.onStatusUpdate("done", this.diffBlocks.length);
359361

360362
// Reject on user typing
361363
// const listener = vscode.workspace.onDidChangeTextDocument((e) => {
@@ -368,7 +370,7 @@ export class VerticalDiffHandler implements vscode.Disposable {
368370
this.clearForFilepath(this.filepath, false);
369371
throw e;
370372
}
371-
return diffLines
373+
return diffLines;
372374
}
373375

374376
async acceptRejectBlock(
@@ -404,6 +406,9 @@ export class VerticalDiffHandler implements vscode.Disposable {
404406

405407
// Shift the codelens objects
406408
this.shiftCodeLensObjects(startLine, offset);
409+
410+
const status = this.diffBlocks.length === 0 ? "closed" : undefined;
411+
this.options.onStatusUpdate(status, this.diffBlocks.length);
407412
}
408413

409414
private shiftCodeLensObjects(startLine: number, offset: number) {
@@ -443,7 +448,6 @@ export class VerticalDiffHandler implements vscode.Disposable {
443448
}
444449

445450
public hasDiffForCurrentFile(): boolean {
446-
const diffBlocks = this.editorToVerticalDiffCodeLens.get(this.filepath);
447-
return diffBlocks !== undefined && diffBlocks.length > 0;
451+
return this.diffBlocks.length > 0;
448452
}
449453
}

extensions/vscode/src/diff/vertical/manager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@ export class VerticalDiffManager {
213213
endLine,
214214
{
215215
instant,
216-
onStatusUpdate: (status) =>
216+
onStatusUpdate: (status, numDiffs) =>
217217
this.webviewProtocol.request("updateApplyState", {
218218
streamId,
219219
status,
220+
numDiffs,
220221
}),
221222
},
222223
);
@@ -331,11 +332,12 @@ export class VerticalDiffManager {
331332
endLine,
332333
{
333334
input,
334-
onStatusUpdate: (status) =>
335+
onStatusUpdate: (status, numDiffs) =>
335336
streamId &&
336337
this.webviewProtocol.request("updateApplyState", {
337338
streamId,
338339
status,
340+
numDiffs,
339341
}),
340342
},
341343
);

extensions/vscode/src/extension/VsCodeMessenger.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,34 @@ export class VsCodeMessenger {
159159
});
160160

161161
this.onWebview("applyToFile", async ({ data }) => {
162-
const fullPath = getFullyQualifiedPath(ide, data.filepath);
162+
let filepath = data.filepath;
163163

164-
if (!fullPath) {
165-
return;
166-
}
164+
// If there is a filepath, verify it exists and then open the file
165+
if (filepath) {
166+
const fullPath = getFullyQualifiedPath(ide, filepath);
167167

168-
const fileExists = await this.ide.fileExists(fullPath);
168+
if (!fullPath) {
169+
return;
170+
}
169171

170-
// If it's a new file, no need to apply, just write directly
171-
if (!fileExists) {
172-
await this.ide.writeFile(fullPath, data.text);
173-
await this.ide.openFile(fullPath);
172+
const fileExists = await this.ide.fileExists(fullPath);
174173

175-
await webviewProtocol.request("updateApplyState", {
176-
streamId: data.streamId,
177-
status: "done",
178-
});
174+
// If it's a new file, no need to apply, just write directly
175+
if (!fileExists) {
176+
await this.ide.writeFile(fullPath, data.text);
177+
await this.ide.openFile(fullPath);
179178

180-
return;
181-
}
179+
await webviewProtocol.request("updateApplyState", {
180+
streamId: data.streamId,
181+
status: "done",
182+
numDiffs: 0,
183+
});
184+
185+
return;
186+
}
182187

183-
await this.ide.openFile(fullPath);
188+
await this.ide.openFile(fullPath);
189+
}
184190

185191
// Get active text editor
186192
const editor = vscode.window.activeTextEditor;
@@ -198,6 +204,7 @@ export class VsCodeMessenger {
198204
await webviewProtocol.request("updateApplyState", {
199205
streamId: data.streamId,
200206
status: "done",
207+
numDiffs: 0,
201208
});
202209
return;
203210
}

gui/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gui/src/components/Footer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { defaultModelSelector } from "../redux/selectors/modelSelectors";
1111
import { RootState } from "../redux/store";
1212
import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial";
1313
import { ROUTES } from "../util/navigation";
14-
import ButtonWithTooltip from "./ButtonWithTooltip";
14+
import HeaderButtonWithToolTip from "./gui/HeaderButtonWithToolTip";
1515
import FreeTrialProgressBar from "./loaders/FreeTrialProgressBar";
1616
import ProfileSwitcher from "./ProfileSwitcher";
1717

@@ -60,30 +60,30 @@ function Footer() {
6060

6161
<div className="flex gap-1">
6262
{configError && (
63-
<ButtonWithTooltip
63+
<HeaderButtonWithToolTip
6464
tooltipPlacement="top-end"
6565
text="Config error"
6666
onClick={onClickError}
6767
>
6868
<ExclamationTriangleIcon className="h-4 w-4" />
69-
</ButtonWithTooltip>
69+
</HeaderButtonWithToolTip>
7070
)}
7171

72-
<ButtonWithTooltip
72+
<HeaderButtonWithToolTip
7373
tooltipPlacement="top-end"
7474
text="More"
7575
onClick={onClickMore}
7676
>
7777
<EllipsisHorizontalCircleIcon className="h-4 w-4" />
78-
</ButtonWithTooltip>
78+
</HeaderButtonWithToolTip>
7979

80-
<ButtonWithTooltip
80+
<HeaderButtonWithToolTip
8181
tooltipPlacement="top-end"
8282
onClick={onClickSettings}
8383
text="Configure Continue"
8484
>
8585
<Cog6ToothIcon className="h-4 w-4" />
86-
</ButtonWithTooltip>
86+
</HeaderButtonWithToolTip>
8787
</div>
8888
</footer>
8989
);

gui/src/components/History/HistoryTableRow.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useDispatch } from "react-redux";
55
import { useNavigate } from "react-router-dom";
66
import { Input } from "..";
77
import useHistory from "../../hooks/useHistory";
8-
import ButtonWithTooltip from "../ButtonWithTooltip";
8+
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
99

1010
function lastPartOfPath(path: string): string {
1111
const sep = path.includes("/") ? "/" : "\\";
@@ -101,24 +101,24 @@ export function HistoryTableRow({
101101

102102
{hovered && !editing && (
103103
<div className="bg-vsc-background absolute right-2 top-1/2 ml-auto flex -translate-y-1/2 transform items-center gap-x-2 rounded-full py-1.5 pl-4 pr-4 shadow-md">
104-
<ButtonWithTooltip
104+
<HeaderButtonWithToolTip
105105
text="Edit"
106106
onClick={async (e) => {
107107
e.stopPropagation();
108108
setEditing(true);
109109
}}
110110
>
111111
<PencilSquareIcon width="1.3em" height="1.3em" />
112-
</ButtonWithTooltip>
113-
<ButtonWithTooltip
112+
</HeaderButtonWithToolTip>
113+
<HeaderButtonWithToolTip
114114
text="Delete"
115115
onClick={async () => {
116116
await deleteSession(session.sessionId);
117117
onDelete(session.sessionId);
118118
}}
119119
>
120120
<TrashIcon width="1.3em" height="1.3em" />
121-
</ButtonWithTooltip>
121+
</HeaderButtonWithToolTip>
122122
</div>
123123
)}
124124
</div>

gui/src/components/Layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ const Layout = () => {
228228
message={dialogMessage}
229229
/>
230230

231-
<GridDiv>
231+
<GridDiv className="">
232232
<PostHogPageView />
233233
<Outlet />
234234

0 commit comments

Comments
 (0)