Repository: TabbyML/tabby
File: clients/tabby-chat-panel/src/index.ts (TypeScript)

Code before:
  targetCol: number
}
export interface ClientApiMethods {
  navigate: (context: Context, opts?: NavigateOpts) => void
  refresh: () => Promise<void>

  onSubmitMessage: (msg: string, relevantContext?: Context[]) => Promise<void>

  // apply content into active editor, version 1, not support smart apply
  onApplyInEditor: (content: string) => void

  // version 2, support smart apply and normal apply
  onApplyInEditorV2?: (
    content: string,
    opts?: { languageId: string, smart: boolean }
  ) => void

  // On current page is loaded.
  onLoaded: (params?: OnLoadedParams | undefined) => void

  // On user copy content to clipboard.
  onCopy: (content: string) => void

  onKeyboardEvent: (type: 'keydown' | 'keyup' | 'keypress', event: KeyboardEventInit) => void
  // navigate to lsp definition by symbol
  onNavigateSymbol: (filepaths: string[], keyword: string) => void

  // on hover symbol return symbol info if exist
  onHoverSymbol: (filepaths: string[], keyword: string) => Promise<SymbolInfo | undefined>
}

export interface ClientApi extends ClientApiMethods {
  // this is inner function cover by tabby-threads
  // the function doesn't need to expose to client but can call by client
  hasCapability: (method: keyof ClientApiMethods) => Promise<boolean>
}

export const clientApiKeys: (keyof ClientApiMethods)[] = [
  'navigate',
  'refresh',
  'onSubmitMessage',
  'onApplyInEditor',
  'onApplyInEditorV2',
  'onLoaded',
  'onCopy',
  'onKeyboardEvent',
]

export interface ChatMessage {
  message: string


Review comment (suggestion):
```suggestion
  onNavigateSymbol?: (filepaths: string[], keyword: string) => void
```

Code after:
  targetCol: number
}
export interface ClientApiMethods {
  navigate: (context: Context, opts?: NavigateOpts) => void
  refresh: () => Promise<void>

  onSubmitMessage: (msg: string, relevantContext?: Context[]) => Promise<void>

  // apply content into active editor, version 1, not support smart apply
  onApplyInEditor: (content: string) => void

  // version 2, support smart apply and normal apply
  onApplyInEditorV2?: (
    content: string,
    opts?: { languageId: string, smart: boolean }
  ) => void

  // On current page is loaded.
  onLoaded: (params?: OnLoadedParams | undefined) => void

  // On user copy content to clipboard.
  onCopy: (content: string) => void

  onKeyboardEvent: (type: 'keydown' | 'keyup' | 'keypress', event: KeyboardEventInit) => void

  // find symbol definition location by hint filepaths and keyword
  onLookupSymbol?: (hintFilepaths: string[], keyword: string) => Promise<SymbolInfo | undefined>
}

export interface ClientApi extends ClientApiMethods {
  // this is inner function cover by tabby-threads
  // the function doesn't need to expose to client but can call by client
  hasCapability: (method: keyof ClientApiMethods) => Promise<boolean>
}

export const clientApiKeys: (keyof ClientApiMethods)[] = [
  'navigate',
  'refresh',
  'onSubmitMessage',
  'onApplyInEditor',
  'onApplyInEditorV2',
  'onLoaded',
  'onCopy',
  'onKeyboardEvent',
]

export interface ChatMessage {
  message: string

  // Client side context - displayed in user message
  selectContext?: Context