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(chat-panel): add provide at function feature api in chat panel #3601

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Changes from 8 commits
Commits
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
58 changes: 58 additions & 0 deletions clients/tabby-chat-panel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,47 @@ export interface GitRepository {
*/
export type ChatCommand = 'explain' | 'fix' | 'generate-docs' | 'generate-tests'

/**
* A symbol kind from vscode standard
*/
export enum SymbolKind {
/**
* The `File` symbol kind.
*/
File = 0,
}

/**
* Represents a file reference (file path plus an optional 1-based line range) for retrieving file content.
* If `range` is not provided, the entire file is considered.
*/
export interface FileRange {
/**
* A {@link Filepath} identifying the location of the file.
*/
filepath: Filepath

/**
* A 1-based line range specifying a subset of the file content.
*/
range?: LineRange
}

/**
* Defines optional parameters used to filter or limit the results of a file query.
*/
export interface AtInputOpts {
/**
* A search query string used for filtering results.
*/
query?: string

/**
* The maximum number of results to return.
*/
limit?: number
}

export interface ServerApi {
init: (request: InitRequest) => void

Expand Down Expand Up @@ -278,6 +319,21 @@ export interface ClientApiMethods {
* @returns The active selection of active editor.
*/
getActiveEditorSelection: () => Promise<EditorFileContext | null>

/**
* Returns a list of file information matching the specified query.
* @param opts An optional {@link AtInputOpts} object that includes a search query and a limit for the results.
* @returns An array of {@link FileRange} objects, or `null` if no matching files are found.
*/
listFileInWorkspace?: (opts?: AtInputOpts) => Promise<FileRange[] | null>
Sma1lboy marked this conversation as resolved.
Show resolved Hide resolved

/**
* Returns the content of a file within the specified range.
* If `range` is not provided, the entire file content is returned.
* @param info A {@link FileRange} object that includes the file path and optionally a 1-based line range.
* @returns The content of the file as a string, or `null` if the file or range cannot be accessed.
*/
readFileContent?: (info: FileRange) => Promise<string | null>
}

export interface ClientApi extends ClientApiMethods {
Expand All @@ -303,6 +359,8 @@ export function createClient(target: HTMLIFrameElement, api: ClientApiMethods):
openExternal: api.openExternal,
readWorkspaceGitRepositories: api.readWorkspaceGitRepositories,
getActiveEditorSelection: api.getActiveEditorSelection,
provideFileAtInfo: api.listFileInWorkspace,
provideRangeContent: api.readFileContent,
},
})
}
Expand Down
Loading