diff --git a/client/web-sveltekit/src/lib/cody/CodySidebarChat.svelte b/client/web-sveltekit/src/lib/cody/CodyChat.svelte similarity index 93% rename from client/web-sveltekit/src/lib/cody/CodySidebarChat.svelte rename to client/web-sveltekit/src/lib/cody/CodyChat.svelte index 0a6a100c912..de984283407 100644 --- a/client/web-sveltekit/src/lib/cody/CodySidebarChat.svelte +++ b/client/web-sveltekit/src/lib/cody/CodyChat.svelte @@ -21,8 +21,8 @@ function getTelemetrySourceClient(): string { import type { LineOrPositionOrRange } from '@sourcegraph/common' - export let repository: CodySidebar_ResolvedRevision - export let filePath: string + export let repository: CodySidebar_ResolvedRevision | undefined = undefined + export let filePath: string | undefined = undefined export let lineOrPosition: LineOrPositionOrRange | undefined = undefined let container: HTMLDivElement @@ -38,8 +38,8 @@ function getTelemetrySourceClient(): string { }) function render( - repository: CodySidebar_ResolvedRevision, - filePath: string, + repository?: CodySidebar_ResolvedRevision, + filePath?: string, lineOrPosition?: LineOrPositionOrRange ) { if (!root) { @@ -54,7 +54,7 @@ function getTelemetrySourceClient(): string { { accessToken: '', initialContext: { - repositories: [repository], + repositories: repository ? [repository] : [], fileURL: filePath ? (!filePath.startsWith('/') ? `/${filePath}` : filePath) : undefined, // Line range - 1 because of Cody Web initial context file range bug fileRange: hasFileRangeSelection @@ -108,7 +108,6 @@ function getTelemetrySourceClient(): string { --vscode-keybindingLabel-foreground: var(--body-color); line-height: 1.55; - padding-bottom: 2rem; flex: 1; min-height: 0; @@ -249,4 +248,14 @@ function getTelemetrySourceClient(): string { --vscode-list-activeSelectionBackground: #031824; } } + + :global([data-cody-web-chat]) { + height: 100%; + overflow: auto; + background-color: var(--vscode-editor-background); + font-size: var(--vscode-font-size); + font-family: var(--vscode-font-family); + color: var(--vscode-editor-foreground); + padding-bottom: 2rem; + } diff --git a/client/web-sveltekit/src/lib/cody/CodySidebar.svelte b/client/web-sveltekit/src/lib/cody/CodySidebar.svelte index 590a11d1535..a2c51fb2ffb 100644 --- a/client/web-sveltekit/src/lib/cody/CodySidebar.svelte +++ b/client/web-sveltekit/src/lib/cody/CodySidebar.svelte @@ -44,7 +44,7 @@ export const CODY_SIDEBAR_ID = uniqueID("cody-sidebar"); {#if $user} - {#await import('./CodySidebarChat.svelte')} + {#await import('./CodyChat.svelte')} {:then module} diff --git a/client/web-sveltekit/src/lib/routes.ts b/client/web-sveltekit/src/lib/routes.ts index f9bcfc6480d..3502c14c1ba 100644 --- a/client/web-sveltekit/src/lib/routes.ts +++ b/client/web-sveltekit/src/lib/routes.ts @@ -66,6 +66,11 @@ export const svelteKitRoutes: SvelteKitRoute[] = [ pattern: new RegExp('^/(backstage|chakraui|cncf|julia|kubernetes|o3de|stackstorm|stanford|temporal)/?$'), isRepoRoot: false, }, + { + id: '/cody/chat', + pattern: new RegExp('^/cody/chat/?$'), + isRepoRoot: false, + }, { id: '/search', pattern: new RegExp('^/search/?$'), diff --git a/client/web-sveltekit/src/routes/cody/chat/+page.svelte b/client/web-sveltekit/src/routes/cody/chat/+page.svelte new file mode 100644 index 00000000000..166c6daabb8 --- /dev/null +++ b/client/web-sveltekit/src/routes/cody/chat/+page.svelte @@ -0,0 +1,63 @@ + + + + Cody Chat - Sourcegraph + + +
+
+

+ + Cody Chat + +

+ + +
+ + {#await import('$lib/cody/CodyChat.svelte')} + + {:then module} + + {:catch} + Failed to load Cody Chat + {/await} +
+ + diff --git a/client/web-sveltekit/src/routes/cody/chat/+page.ts b/client/web-sveltekit/src/routes/cody/chat/+page.ts new file mode 100644 index 00000000000..5ed014fb221 --- /dev/null +++ b/client/web-sveltekit/src/routes/cody/chat/+page.ts @@ -0,0 +1,20 @@ +import { redirect } from '@sveltejs/kit' + +import type { PageLoad } from './$types' + +export const load: PageLoad = async ({ parent }) => { + const dashboardRoute = window.context.sourcegraphDotComMode ? '/cody/manage' : '/cody/dashboard' + const data = await parent() + + if (!data.user) { + redirect(302, '/sign-in') + } + + if (!window.context?.codyEnabledForCurrentUser) { + redirect(303, dashboardRoute) + } + + return { + dashboardRoute, + } +} diff --git a/client/web/src/sveltekit/routes.ts b/client/web/src/sveltekit/routes.ts index f9bcfc6480d..3502c14c1ba 100644 --- a/client/web/src/sveltekit/routes.ts +++ b/client/web/src/sveltekit/routes.ts @@ -66,6 +66,11 @@ export const svelteKitRoutes: SvelteKitRoute[] = [ pattern: new RegExp('^/(backstage|chakraui|cncf|julia|kubernetes|o3de|stackstorm|stanford|temporal)/?$'), isRepoRoot: false, }, + { + id: '/cody/chat', + pattern: new RegExp('^/cody/chat/?$'), + isRepoRoot: false, + }, { id: '/search', pattern: new RegExp('^/search/?$'), diff --git a/cmd/frontend/internal/app/ui/sveltekit/routes.go b/cmd/frontend/internal/app/ui/sveltekit/routes.go index 24324d969ca..a001d342264 100644 --- a/cmd/frontend/internal/app/ui/sveltekit/routes.go +++ b/cmd/frontend/internal/app/ui/sveltekit/routes.go @@ -73,6 +73,11 @@ var svelteKitRoutes = []svelteKitRoute{ Pattern: regexp.MustCompile("^/(backstage|chakraui|cncf|julia|kubernetes|o3de|stackstorm|stanford|temporal)/?$"), Tag: tags.EnableOptIn | tags.EnableRollout | tags.Dotcom, }, + { + Id: "/cody/chat", + Pattern: regexp.MustCompile("^/cody/chat/?$"), + Tag: tags.EnableOptIn | tags.EnableRollout, + }, { Id: "/search", Pattern: regexp.MustCompile("^/search/?$"),