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): display git repo connected status in chat side panel #3550

Merged
merged 39 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9a8448f
feat(ui): resolve indexed repository of IDE workspace
liangfung Dec 12, 2024
eb6a1ac
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2024
55d58ab
update: sync git url
liangfung Dec 12, 2024
1deab14
update: lint
liangfung Dec 12, 2024
9671198
update: lint
liangfung Dec 12, 2024
81cdbf4
update: animation
liangfung Dec 12, 2024
6deb747
update
liangfung Dec 15, 2024
12c9a89
feat(ui): add repo select in chat sidebar
liangfung Dec 14, 2024
33da2ba
update
liangfung Dec 15, 2024
1fce982
update: set default repo
liangfung Dec 16, 2024
0521493
update: code_query
liangfung Dec 17, 2024
16dc9ff
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 17, 2024
4f7751b
update: focus
liangfung Dec 17, 2024
58b82ed
update: type
liangfung Dec 17, 2024
bd34f11
Update ee/tabby-ui/components/chat/repo-select.tsx
wsxiaoys Dec 17, 2024
86d3290
Apply suggestions from code review
wsxiaoys Dec 17, 2024
4375419
update
liangfung Dec 17, 2024
7a92b16
update: styling
liangfung Dec 17, 2024
0dc6629
Update ee/tabby-ui/components/chat/repo-select.tsx
wsxiaoys Dec 17, 2024
1111c8d
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 17, 2024
0bb466f
update: optional
liangfung Dec 17, 2024
a9b5871
update
liangfung Dec 17, 2024
a2b3b93
update: chat panel api
liangfung Dec 17, 2024
fce7a5a
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 17, 2024
cd90e84
update: init
liangfung Dec 17, 2024
69c9d2e
update: init
liangfung Dec 18, 2024
c1af81e
update: revert
liangfung Dec 18, 2024
b24c6b0
update
liangfung Dec 18, 2024
6f96841
Update clients/tabby-chat-panel/src/index.ts
liangfung Dec 18, 2024
d615a44
Update clients/tabby-chat-panel/src/index.ts
liangfung Dec 18, 2024
a38b499
Update clients/tabby-chat-panel/src/index.ts
liangfung Dec 18, 2024
d9a4868
update: rename
liangfung Dec 18, 2024
7c9fa1c
update
liangfung Dec 18, 2024
6c737c4
update: test
liangfung Dec 18, 2024
c3e2dfe
update
liangfung Dec 18, 2024
3d292b8
update: remove
liangfung Dec 18, 2024
2c666a8
update: test
liangfung Dec 18, 2024
f61f185
update
liangfung Dec 18, 2024
8b47b04
update: test cases
liangfung Dec 19, 2024
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
11 changes: 11 additions & 0 deletions clients/tabby-chat-panel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ export interface SymbolInfo {
target: FileLocation
}

/**
* Includes information about a git repository in workspace folder
*/
export interface GitRepository {
url: string
}

export interface ServerApi {
init: (request: InitRequest) => void
sendMessage: (message: ChatMessage) => void
Expand Down Expand Up @@ -224,6 +231,9 @@ export interface ClientApiMethods {
* @returns Whether the file location is opened successfully.
*/
openInEditor: (target: FileLocation) => Promise<boolean>

// Provide all repos found in workspace folders.
readWorkspaceGitRepositories?: () => Promise<GitRepository[]>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findClosestGitRepository(workspace: GitRepositories[], gitUrl: String);

}

export interface ClientApi extends ClientApiMethods {
Expand Down Expand Up @@ -258,6 +268,7 @@ export function createClient(target: HTMLIFrameElement, api: ClientApiMethods):
onKeyboardEvent: api.onKeyboardEvent,
lookupSymbol: api.lookupSymbol,
openInEditor: api.openInEditor,
readWorkspaceGitRepositories: api.readWorkspaceGitRepositories,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-schema/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@
}

async fn repository_list(ctx: &Context) -> Result<Vec<Repository>> {
let user = check_user(ctx).await?;
let user = check_user_allow_auth_token(ctx).await?;

Check warning on line 544 in ee/tabby-schema/src/schema/mod.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/schema/mod.rs#L544

Added line #L544 was not covered by tests

ctx.locator
.repository()
Expand Down
12 changes: 12 additions & 0 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export default function ChatPage() {
const [supportsOnApplyInEditorV2, setSupportsOnApplyInEditorV2] =
useState(false)
const [supportsOnLookupSymbol, setSupportsOnLookupSymbol] = useState(false)
const [
supportsProvideWorkspaceGitRepoInfo,
setSupportsProvideWorkspaceGitRepoInfo
] = useState(false)

const sendMessage = (message: ChatMessage) => {
if (chatRef.current) {
Expand Down Expand Up @@ -238,6 +242,9 @@ export default function ChatPage() {
?.hasCapability('onApplyInEditorV2')
.then(setSupportsOnApplyInEditorV2)
server?.hasCapability('lookupSymbol').then(setSupportsOnLookupSymbol)
server
?.hasCapability('readWorkspaceGitRepositories')
.then(setSupportsProvideWorkspaceGitRepoInfo)
}

checkCapabilities()
Expand Down Expand Up @@ -395,6 +402,11 @@ export default function ChatPage() {
(supportsOnLookupSymbol ? server?.lookupSymbol : undefined)
}
openInEditor={isInEditor && server?.openInEditor}
readWorkspaceGitRepositories={
isInEditor && supportsProvideWorkspaceGitRepoInfo
? server?.readWorkspaceGitRepositories
: undefined
}
/>
</ErrorBoundary>
)
Expand Down
26 changes: 25 additions & 1 deletion ee/tabby-ui/components/chat/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
IconCheck,
IconEye,
IconEyeOff,
IconFileText,
IconRefresh,
IconRemove,
IconShare,
Expand All @@ -32,6 +33,7 @@ import { FooterText } from '@/components/footer'

import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'
import { ChatContext } from './chat'
import { RepoSelect } from './repo-select'

export interface ChatPanelProps
extends Pick<UseChatHelpers, 'stop' | 'input' | 'setInput'> {
Expand Down Expand Up @@ -70,11 +72,16 @@ function ChatPanelRenderer(
relevantContext,
removeRelevantContext,
activeSelection,
onCopyContent
onCopyContent,
selectedRepoId,
setSelectedRepoId,
repos,
initialized
} = React.useContext(ChatContext)
const enableActiveSelection = useChatStore(
state => state.enableActiveSelection
)

const [persisting, setPerisiting] = useState(false)
const { width } = useWindowSize()
const isExtraSmallScreen = typeof width === 'number' && width < 376
Expand Down Expand Up @@ -124,6 +131,14 @@ function ChatPanelRenderer(
}
}

const onSelectRepo = (sourceId: string | undefined) => {
setSelectedRepoId(sourceId)

setTimeout(() => {
chatInputRef.current?.focus()
})
}

React.useImperativeHandle(
ref,
() => {
Expand Down Expand Up @@ -220,8 +235,15 @@ function ChatPanelRenderer(
<div className="border-t bg-background px-4 py-2 shadow-lg sm:space-y-4 sm:rounded-t-xl sm:border md:py-4">
<div className="flex flex-wrap gap-2">
<AnimatePresence presenceAffectsLayout>
<RepoSelect
value={selectedRepoId}
onChange={onSelectRepo}
repos={repos}
isInitializing={!initialized}
/>
{activeSelection ? (
<motion.div
key="active-selection"
initial={{ opacity: 0, scale: 0.9, y: -5 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
transition={{
Expand All @@ -240,6 +262,7 @@ function ChatPanelRenderer(
}
)}
>
<IconFileText />
<ContextLabel
context={activeSelection}
className="flex-1 truncate"
Expand Down Expand Up @@ -300,6 +323,7 @@ function ChatPanelRenderer(
setInput={setInput}
isLoading={isLoading}
chatInputRef={chatInputRef}
isInitializing={!initialized}
/>
<FooterText className="hidden sm:block" />
</div>
Expand Down
Loading
Loading