-
Notifications
You must be signed in to change notification settings - Fork 364
feat(ask): start chat from selected code range #1553
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
865aac8
eedef3a
35956de
2b7bc80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ import { useRouter } from "next/navigation"; | |
| import { createChat } from "./actions"; | ||
| import { isServiceError } from "@/lib/utils"; | ||
| import { createPathWithQueryParams } from "@/lib/utils"; | ||
| import { AttachmentData, SearchScope, SetChatStatePayload } from "./types"; | ||
| import { AttachmentData, SearchScope, SetChatStatePayload, Source } from "./types"; | ||
| import { DISABLED_MCP_SERVER_IDS_LOCAL_STORAGE_KEY, SELECTED_SEARCH_SCOPES_LOCAL_STORAGE_KEY, SET_CHAT_STATE_SESSION_STORAGE_KEY } from "./constants"; | ||
| import { useSessionStorage } from "usehooks-ts"; | ||
|
|
||
|
|
@@ -64,8 +64,38 @@ export const useCreateNewChatThread = () => { | |
| router.push(url); | ||
| }, [router, toast, setChatState]); | ||
|
|
||
| const createChatFromSource = useCallback(async (source: Source) => { | ||
| const inputMessage = createUIMessage( | ||
| 'Explain this selected code.', | ||
| [], | ||
| [], | ||
| [], | ||
| [], | ||
| [source], | ||
| ); | ||
|
|
||
| setIsLoading(true); | ||
| const response = await createChat({ source: 'sourcebot-web-client' }); | ||
| if (isServiceError(response)) { | ||
| toast({ | ||
| description: `❌ Failed to create chat. Reason: ${response.message}`, | ||
| }); | ||
| setIsLoading(false); | ||
| return; | ||
| } | ||
|
|
||
| setChatState({ | ||
| inputMessage, | ||
| selectedSearchScopes: [], | ||
| disabledMcpServerIds: [], | ||
| }); | ||
|
|
||
| router.push(`/chat/${response.id}`); | ||
| }, [router, setChatState, toast]); | ||
|
cursor[bot] marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In-flight lock never releasedMedium Severity
Reviewed by Cursor Bugbot for commit 2b7bc80. Configure here. |
||
|
|
||
| return { | ||
| createNewChatThread, | ||
| createChatFromSource, | ||
| isLoading, | ||
| }; | ||
| } | ||


Uh oh!
There was an error while loading. Please reload this page.