Repository navigation
feat(web): add send-and-start shortcut for chats without projects #17060
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
Closed
TDanks2000
wants to merge
3
commits into
pingdotgg:main
from
TDanks2000:feat/send-new-chat-without-project
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { EnvironmentId, ProjectId } from "@t3tools/contracts"; | ||
| import { beforeEach, describe, expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| const state = vi.hoisted(() => ({ | ||
| openScratch: vi.fn(), | ||
| newThread: vi.fn(), | ||
| toast: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("react", () => ({ useCallback: (callback: unknown) => callback })); | ||
| vi.mock("~/state/environments", () => ({ useEnvironments: () => ({ environments: [] }) })); | ||
| vi.mock("~/state/projects", () => ({ projectEnvironment: { openScratch: {} } })); | ||
| vi.mock("~/state/use-atom-command", () => ({ useAtomCommand: () => state.openScratch })); | ||
| vi.mock("./useHandleNewThread", () => ({ useNewThreadHandler: () => state.newThread })); | ||
| vi.mock("~/components/ui/toast", () => ({ | ||
| stackedThreadToast: (input: unknown) => input, | ||
| toastManager: { add: state.toast }, | ||
| })); | ||
|
|
||
| import { useScratchProject } from "./useScratchProject"; | ||
|
|
||
| const environmentId = EnvironmentId.make("remote-environment"); | ||
| const projectId = ProjectId.make("scratch-project"); | ||
| const success = { _tag: "Success", value: { environmentId, id: projectId } }; | ||
|
|
||
| beforeEach(() => { | ||
| vi.resetAllMocks(); | ||
| state.newThread.mockResolvedValue({ draftId: "fresh-draft", threadId: "fresh-thread" }); | ||
| }); | ||
|
|
||
| describe("startScratchThread", () => { | ||
| it("opens a scratch composer on the requested environment", async () => { | ||
| state.openScratch.mockResolvedValue(success); | ||
| expect(await useScratchProject().startScratchThread(environmentId)).toBe(true); | ||
| expect(state.newThread).toHaveBeenCalledWith({ environmentId, projectId }); | ||
| }); | ||
|
|
||
| it("does not navigate when the user moves on during the scratch RPC", async () => { | ||
| let resolveProjectOpen: (result: typeof success) => void = () => undefined; | ||
| const pending = new Promise<typeof success>((resolve) => { | ||
| resolveProjectOpen = resolve; | ||
| }); | ||
| state.openScratch.mockReturnValue(pending); | ||
| let stillCurrent = true; | ||
| const start = useScratchProject().startScratchThread(environmentId, () => stillCurrent); | ||
| stillCurrent = false; | ||
| resolveProjectOpen(success); | ||
| expect(await start).toBe(false); | ||
| expect(state.newThread).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("does not open a project when the sending composer is already stale", async () => { | ||
| expect(await useScratchProject().startScratchThread(environmentId, () => false)).toBe(false); | ||
| expect(state.openScratch).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("reports failure to open the composer without claiming it opened", async () => { | ||
| state.openScratch.mockResolvedValue(success); | ||
| state.newThread.mockRejectedValue(new Error("Disconnected")); | ||
| expect(await useScratchProject().startScratchThread(environmentId)).toBe(false); | ||
| expect(state.toast).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| title: "Could not start without a project", | ||
| description: "Disconnected", | ||
| }), | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Track draft identity before opening the next composer.
If a user edits the cleared draft and then clears it while a send or scratch RPC is pending,
canOpenNextComposerreturns true. The completed send can then navigate away after the user changed the composer. Capture the cleared draft and a send generation for the single-model and plan-follow-up paths. Check both in this predicate, as the multi-model path does.🤖 Prompt for AI Agents