Skip to content

Commit

Permalink
to: smart apply in editor also pass language id
Browse files Browse the repository at this point in the history
a
  • Loading branch information
Sma1lboy committed Sep 11, 2024
1 parent 7a7b3ed commit 4b848cc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion clients/tabby-chat-panel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ClientApi {
onApplyInEditor: (content: string) => void

// smart apply into editor
onSmartApplyInEditor: (content: string) => void
onSmartApplyInEditor: (languageId: string, content: string) => void

// On current page is loaded.
onLoaded: () => void
Expand Down Expand Up @@ -82,6 +82,7 @@ export function createClient(target: HTMLIFrameElement, api: ClientApi): ServerA
onApplyInEditor: api.onApplyInEditor,
onLoaded: api.onLoaded,
onCopy: api.onCopy,
onSmartApplyInEditor: api.onSmartApplyInEditor,
},
})
}
Expand Down
4 changes: 2 additions & 2 deletions ee/tabby-ui/components/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type ChatContextValue = {
container?: HTMLDivElement
onCopyContent?: (value: string) => void
onApplyInEditor?: (value: string) => void
onSmartApplyInEditor?: (value: string) => void
onSmartApplyInEditor?: (languageId: string, value: string) => void
relevantContext: Context[]
removeRelevantContext: (index: number) => void
}
Expand Down Expand Up @@ -73,7 +73,7 @@ interface ChatProps extends React.ComponentProps<'div'> {
onCopyContent?: (value: string) => void
onSubmitMessage?: (msg: string, relevantContext?: Context[]) => Promise<void>
onApplyInEditor?: (value: string) => void
onSmartApplyInEditor?: (value: string) => void
onSmartApplyInEditor?: (languageId: string, value: string) => void
}

function ChatRenderer(
Expand Down
4 changes: 3 additions & 1 deletion ee/tabby-ui/components/message-markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export interface MessageMarkdownProps {
attachmentCode?: Maybe<Array<AttachmentCodeItem>>
onCopyContent?: ((value: string) => void) | undefined
onApplyInEditor?: ((value: string) => void) | undefined
onSmartApplyInEditor?: ((value: string) => void) | undefined
onSmartApplyInEditor?:
| ((languageId: string, value: string) => void)
| undefined
onCodeCitationClick?: (code: MessageAttachmentCode) => void
onCodeCitationMouseEnter?: (index: number) => void
onCodeCitationMouseLeave?: (index: number) => void
Expand Down
4 changes: 2 additions & 2 deletions ee/tabby-ui/components/ui/codeblock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface Props {
value: string
onCopyContent?: (value: string) => void
onApplyInEditor?: (value: string) => void
onSmartApplyInEditor?: (value: string) => void
onSmartApplyInEditor?: (languageId: string, value: string) => void
}

interface languageMap {
Expand Down Expand Up @@ -102,7 +102,7 @@ const CodeBlock: FC<Props> = memo(
variant="ghost"
size="icon"
className="text-xs hover:bg-[#3C382F] hover:text-[#F4F4F5] focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
onClick={() => onSmartApplyInEditor(value)}
onClick={() => onSmartApplyInEditor(language, value)}
>
<IconSmartApplyInEditor />
<span className="sr-only">Smart Apply in Editor</span>
Expand Down

0 comments on commit 4b848cc

Please sign in to comment.