Skip to content

Commit 1f7a80e

Browse files
committed
Merge branch 'main' of https://github.com/continuedev/continue into vite-install-note
2 parents 0e5c9e8 + 8951394 commit 1f7a80e

File tree

18 files changed

+577
-520
lines changed

18 files changed

+577
-520
lines changed

.github/workflows/submit-github-dependency-graph.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Submit Gradle Dependency Graph For Dependabot
22

33
on:
44
push:
5-
branches: ['main']
5+
branches: ["main"]
66

77
permissions:
88
contents: write
@@ -11,15 +11,15 @@ jobs:
1111
dependency-submission:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Checkout sources
15-
uses: actions/checkout@v4
16-
- name: Setup Java
17-
uses: actions/setup-java@v4
18-
with:
19-
distribution: 'temurin'
20-
java-version: 17
21-
- name: Generate and submit dependency graph
22-
uses: gradle/actions/dependency-submission@v4
23-
with:
24-
# The gradle project is not in the root of the repository.
25-
build-root-directory: extensions/intellij
14+
- name: Checkout sources
15+
uses: actions/checkout@v4
16+
- name: Setup Java
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: "temurin"
20+
java-version: 17
21+
- name: Generate and submit dependency graph
22+
uses: gradle/actions/dependency-submission@v4
23+
with:
24+
# The gradle project is not in the root of the repository.
25+
build-root-directory: extensions/intellij

core/autocomplete/templating/filtering.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SnippetPayload } from "../snippets";
33
import {
44
AutocompleteCodeSnippet,
55
AutocompleteSnippet,
6+
AutocompleteSnippetType,
67
} from "../snippets/types";
78
import { HelperVars } from "../util/HelperVars";
89
import { formatOpenedFilesContext } from "./formatOpenedFilesContext";
@@ -130,21 +131,16 @@ export const getSnippets = (
130131
const finalSnippets = [];
131132
let remainingTokenCount = getRemainingTokenCount(helper);
132133

134+
// tracks already added filepaths for deduplication
135+
const addedFilepaths = new Set<string>();
136+
133137
// Process snippets in priority order
134138
for (const { key } of snippetOrder) {
135139
// Special handling for recentlyOpenedFiles
136140
if (key === "recentlyOpenedFiles" && helper.options.useRecentlyOpened) {
137-
const recentlyOpenedFilesSnippets =
138-
payload.recentlyOpenedFileSnippets.filter(
139-
(snippet) =>
140-
!(snippet as AutocompleteCodeSnippet).filepath?.startsWith(
141-
"output:extension-output-Continue.continue",
142-
),
143-
);
144-
145141
// Custom trimming
146142
const processedSnippets = formatOpenedFilesContext(
147-
recentlyOpenedFilesSnippets,
143+
payload.recentlyOpenedFileSnippets,
148144
remainingTokenCount,
149145
helper,
150146
finalSnippets,
@@ -160,18 +156,18 @@ export const getSnippets = (
160156

161157
if (remainingTokenCount >= snippetSize) {
162158
finalSnippets.push(snippet);
159+
addedFilepaths.add(snippet.filepath);
163160
remainingTokenCount -= snippetSize;
164161
} else {
165-
break; // Out of tokens
162+
continue; // Not enough tokens, try again with next snippet
166163
}
167164
}
168165
} else {
169166
// Normal processing for other snippet types
170167
const snippetsToProcess = snippets[key].filter(
171168
(snippet) =>
172-
!(snippet as AutocompleteCodeSnippet).filepath?.startsWith(
173-
"output:extension-output-Continue.continue",
174-
),
169+
snippet.type !== AutocompleteSnippetType.Code ||
170+
!addedFilepaths.has(snippet.filepath),
175171
);
176172

177173
for (const snippet of snippetsToProcess) {
@@ -182,9 +178,14 @@ export const getSnippets = (
182178

183179
if (remainingTokenCount >= snippetSize) {
184180
finalSnippets.push(snippet);
181+
182+
if ((snippet as AutocompleteCodeSnippet).filepath) {
183+
addedFilepaths.add((snippet as AutocompleteCodeSnippet).filepath);
184+
}
185+
185186
remainingTokenCount -= snippetSize;
186187
} else {
187-
break; // Out of tokens
188+
continue; // Not enough tokens, try again with next snippet
188189
}
189190
}
190191
}

core/autocomplete/templating/formatOpenedFilesContext.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { countTokens, pruneStringFromBottom } from "../../llm/countTokens";
22
import {
33
AutocompleteCodeSnippet,
44
AutocompleteSnippet,
5+
AutocompleteSnippetType,
56
} from "../snippets/types";
67
import { HelperVars } from "../util/HelperVars";
78

@@ -20,13 +21,23 @@ export function formatOpenedFilesContext(
2021
recentlyOpenedFilesSnippets: AutocompleteCodeSnippet[],
2122
remainingTokenCount: number,
2223
helper: HelperVars,
23-
alreadyAddedSnippets: AutocompleteSnippet[], // TODO use this to deduplicate context
24+
alreadyAddedSnippets: AutocompleteSnippet[],
2425
TOKEN_BUFFER: number,
2526
): AutocompleteCodeSnippet[] {
2627
if (recentlyOpenedFilesSnippets.length === 0) {
2728
return [];
2829
}
2930

31+
// deduplication; if a snippet is already added, don't include it here
32+
for (const snippet of alreadyAddedSnippets) {
33+
if (snippet.type !== AutocompleteSnippetType.Code) {
34+
continue;
35+
}
36+
recentlyOpenedFilesSnippets = recentlyOpenedFilesSnippets.filter(
37+
(s) => s.filepath !== snippet.filepath,
38+
);
39+
}
40+
3041
// Calculate how many full snippets would fit within the remaining token count
3142
let numSnippetsThatFit = 0;
3243
let totalTokens = 0;

core/autocomplete/templating/validation.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
AutocompleteClipboardSnippet,
3+
AutocompleteCodeSnippet,
34
AutocompleteSnippet,
45
AutocompleteSnippetType,
56
} from "../snippets/types";
@@ -25,5 +26,13 @@ export const isValidSnippet = (snippet: AutocompleteSnippet): boolean => {
2526
return isValidClipboardSnippet(snippet);
2627
}
2728

29+
if (
30+
(snippet as AutocompleteCodeSnippet).filepath?.startsWith(
31+
"output:extension-output-Continue.continue",
32+
)
33+
) {
34+
return false;
35+
}
36+
2837
return true;
2938
};

core/data/log.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ const TEST_EVENT: DevDataLogEvent = {
2020
};
2121

2222
const TEST_AGENT_INTERACTION_EVENT: DevDataLogEvent = {
23-
name: 'chatInteraction',
23+
name: "chatInteraction",
2424
data: {
2525
prompt: "Hello, world!",
2626
completion: "Hello, world!",
2727
modelProvider: "openai",
2828
modelTitle: "gpt-4",
2929
sessionId: "1234",
30-
tools: ['test-tool1']
30+
tools: ["test-tool1"],
3131
},
32-
}
33-
32+
};
33+
3434
const SCHEMA = "0.2.0";
3535

3636
describe("DataLogger", () => {
@@ -171,22 +171,25 @@ describe("DataLogger", () => {
171171
expect(fileContent).toContain('"eventName":"tokensGenerated"');
172172
});
173173

174-
it('should write agent interaction data to local file', async () => {
174+
it("should write agent interaction data to local file", async () => {
175175
// Call the method to log data locally
176176
await dataLogger.logLocalData(TEST_AGENT_INTERACTION_EVENT);
177177

178178
// Verify the file was created
179-
const filepath = getDevDataFilePath(TEST_AGENT_INTERACTION_EVENT.name, SCHEMA);
179+
const filepath = getDevDataFilePath(
180+
TEST_AGENT_INTERACTION_EVENT.name,
181+
SCHEMA,
182+
);
180183
expect(fs.existsSync(filepath)).toBe(true);
181184

182185
// Read file contents and verify
183186
const fileContent = fs.readFileSync(filepath, "utf8");
184-
console.log('debug1 filecontent', fileContent)
187+
console.log("debug1 filecontent", fileContent);
185188
expect(fileContent).toContain('"eventName":"chatInteraction"');
186189
expect(fileContent).toContain('"prompt":"Hello, world!"');
187190
expect(fileContent).toContain('"completion":"Hello, world!"');
188191
expect(fileContent).toContain('"tools":["test-tool1"]');
189-
})
192+
});
190193
});
191194

192195
describe("logDevData", () => {

0 commit comments

Comments
 (0)