Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tabby-ui): add mention functionality in tabby chat ui #3607

Merged
merged 24 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0d0c81a
feat(chat): add mention functionality with category selection and sty…
Sma1lboy Dec 21, 2024
3eea537
feat(chat): implement mention functionality with category support and…
Sma1lboy Dec 24, 2024
d491b37
feat(chat): add input management methods to PromptFormRef interface
Sma1lboy Dec 24, 2024
a5f01c6
refactor(chat): remove unused FileList, CategoryMenu, mention compone…
Sma1lboy Dec 24, 2024
f9b5bc4
refactor(chat): Revert Webviewhelper to a previous version
Sma1lboy Dec 24, 2024
0468316
Merge branch 'main' into feat-at-function-in-tabby-ui
Sma1lboy Jan 9, 2025
96e6ecb
refactor(chat): remove unused mention components and styles
Sma1lboy Jan 10, 2025
7d10eed
refactor(chat): remove PopoverMentionList component and its associate…
Sma1lboy Jan 10, 2025
c6b2413
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 10, 2025
b0eac5f
refactor(chat): enhance at-mention handling and improve file item pro…
Sma1lboy Jan 13, 2025
5f0a8d2
refactor(chat): implement file mention functionality and enhance ment…
Sma1lboy Jan 13, 2025
088a9aa
chore: fix some potential normalize issue
Sma1lboy Jan 13, 2025
52de94d
refactor(chat): update chatInputRef type to use PromptFormRef for imp…
Sma1lboy Jan 13, 2025
08f3175
Merge branch 'main' into feat-at-function-in-tabby-ui
Sma1lboy Jan 14, 2025
f2aaba0
update
liangfung Jan 15, 2025
39daf96
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 15, 2025
6bedc1e
update
liangfung Jan 15, 2025
41685d8
fix(chat): update fileItemToSourceItem to handle filepath extraction …
Sma1lboy Jan 16, 2025
e7a0c11
update
liangfung Jan 17, 2025
db1fab5
Merge branch 'main' into feat-at-function-in-tabby-ui
liangfung Jan 17, 2025
2a00236
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 17, 2025
6187bff
update
liangfung Jan 17, 2025
2dd4430
updae
liangfung Jan 17, 2025
5087067
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(chat): Revert Webviewhelper to a previous version
Sma1lboy committed Dec 24, 2024
commit f9b5bc4827830d2ae566393006ee23c517a2f821
112 changes: 0 additions & 112 deletions clients/vscode/src/chat/WebviewHelper.ts
Original file line number Diff line number Diff line change
@@ -43,7 +43,6 @@ import {
vscodeRangeToChatPanelPositionRange,
chatPanelLocationToVSCodeRange,
} from "./utils";
import path from "path";

export class WebviewHelper {
webview?: Webview;
@@ -729,117 +728,6 @@ export class WebviewHelper {
}
return infoList;
},
provideSymbolAtInfo: async (opts?: AtInputOpts): Promise<SymbolAtInfo[] | null> => {
const maxResults = opts?.limit || 50;
const query = opts?.query?.toLowerCase();

const editor = window.activeTextEditor;
if (!editor) return null;
const document = editor.document;

// Try document symbols first
const documentSymbols = await commands.executeCommand<DocumentSymbol[] | SymbolInformation[]>(
"vscode.executeDocumentSymbolProvider",
document.uri,
);

let results: SymbolAtInfo[] = [];

if (documentSymbols && documentSymbols.length > 0) {
const processSymbol = (symbol: DocumentSymbol | SymbolInformation) => {
if (results.length >= maxResults) return;

const symbolName = symbol.name.toLowerCase();
if (query && !symbolName.includes(query)) return;

if (getAllowedSymbolKinds().includes(symbol.kind)) {
results.push(vscodeSymbolToSymbolAtInfo(symbol, document.uri, this.gitProvider));
}
if (isDocumentSymbol(symbol)) {
symbol.children.forEach(processSymbol);
}
};
documentSymbols.forEach(processSymbol);
}

// Try workspace symbols if no document symbols found
if (results.length === 0 && query) {
const workspaceSymbols = await commands.executeCommand<SymbolInformation[]>(
"vscode.executeWorkspaceSymbolProvider",
query,
);

if (workspaceSymbols) {
results = workspaceSymbols
.filter((symbol) => getAllowedSymbolKinds().includes(symbol.kind))
.slice(0, maxResults)
.map((symbol) => vscodeSymbolToSymbolAtInfo(symbol, symbol.location.uri, this.gitProvider));
}
}

return results.length > 0 ? results : null;
},

provideFileAtInfo: async (opts?: AtInputOpts): Promise<FileAtInfo[] | null> => {
const maxResults = opts?.limit || 50;
const query = opts?.query;

const globPattern = "**/*";
const excludePattern = "**/node_modules/**";
try {
const files = await workspace.findFiles(globPattern, excludePattern);

const filteredFiles = query
? files.filter((uri) => {
const a = path.basename(uri.fsPath);
const b = query.toLowerCase();
this.logger.info("uri:" + a + " " + "query:" + b + " result:" + a.toLowerCase().startsWith(b));
this.logger.info(b);
return a.toLowerCase().startsWith(b);
})
: files;

const sortedFiles = filteredFiles.sort((a, b) => {
const nameA = a.fsPath.toLowerCase();
const nameB = b.fsPath.toLowerCase();
return nameA < nameB ? -1 : nameA > nameB ? 1 : 0;
});

const limitedFiles = sortedFiles.slice(0, maxResults);

return limitedFiles.map((uri) => uriToFileAtInfo(uri, this.gitProvider));
} catch (error) {
this.logger.error("Failed to find files:", error);
return null;
}
},
getSymbolAtInfoContent: async (info: SymbolAtInfo): Promise<string | null> => {
try {
const uri = chatPanelFilepathToLocalUri(info.location.filepath, this.gitProvider);
if (!uri) return null;

const document = await workspace.openTextDocument(uri);
const range = chatPanelLocationToVSCodeRange(info.location.location);
if (!range) return null;

return document.getText(range);
} catch (error) {
this.logger.error("Failed to get symbol content:", error);
return null;
}
},
getFileAtInfoContent: async (info: FileAtInfo): Promise<string | null> => {
try {
const uri = chatPanelFilepathToLocalUri(info.filepath, this.gitProvider);
if (!uri) return null;

const document = await workspace.openTextDocument(uri);
return document.getText();
} catch (error) {
this.logger.error("Failed to get file content:", error);
return null;
}
},
});
}
}