Repository navigation
fix(web): dropped folders open on this computer's server when the desktop app's own environment is off #38722
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
Changes from all commits
370f6af
5423301
aa90d0b
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 |
|---|---|---|
|
|
@@ -3,14 +3,16 @@ import { | |
| findProjectByPath, | ||
| inferProjectTitleFromPath, | ||
| } from "@t3tools/client-runtime/state/projects"; | ||
| import { useAtomValue } from "@effect/atom-react"; | ||
| import type { DesktopAppActivationRequest } from "@t3tools/contracts"; | ||
| import { msg } from "gt-react"; | ||
|
|
||
| import { handleDesktopAppActivationRequest } from "../desktopAppActivation"; | ||
| import { m } from "../i18n/messages"; | ||
| import { newProjectId } from "../lib/utils"; | ||
| import { readProjects, waitForProject } from "../state/entities"; | ||
| import { usePrimaryEnvironment } from "../state/environments"; | ||
| import { useEnvironment } from "../state/environments"; | ||
| import { localEnvironmentIdAtom } from "../state/primaryEnvironment"; | ||
| import { projectEnvironment } from "../state/projects"; | ||
| import { useEnvironmentShellHasSnapshot } from "../state/shell"; | ||
| import { useAtomCommand } from "../state/use-atom-command"; | ||
|
|
@@ -19,38 +21,36 @@ import { reportProjectFailure } from "./useProjectGroupUpdate"; | |
| import { useNewThreadHandler } from "./useHandleNewThread"; | ||
|
|
||
| /** | ||
| * Opens a folder on this computer as a project in the primary environment: an | ||
| * Opens a folder on this computer as a project in this computer's environment: an | ||
| * existing project opens (and unarchives), a new one is added. Used by `t3 <dir>` | ||
| * activations and folders dropped on the sidebar. `ready` is false until the | ||
| * primary environment's projects have loaded, so a known folder is not added twice. | ||
| * activations and folders dropped on the sidebar. `ready` is false until that | ||
| * environment's projects have loaded, so a known folder is not added twice. | ||
| */ | ||
| export function useOpenLocalWorkspace() { | ||
| const primaryEnvironment = usePrimaryEnvironment(); | ||
| const localEnvironment = useEnvironment(useAtomValue(localEnvironmentIdAtom)); | ||
| const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false }); | ||
| const updateProject = useOrchestrationCommand(projectEnvironment.update, { | ||
| label: "project unarchive", | ||
| }); | ||
| const openThread = useNewThreadHandler(); | ||
| const shellHasSnapshot = useEnvironmentShellHasSnapshot( | ||
| primaryEnvironment?.environmentId ?? null, | ||
| ); | ||
| const shellHasSnapshot = useEnvironmentShellHasSnapshot(localEnvironment?.environmentId ?? null); | ||
| const ready = | ||
| primaryEnvironment?.connection.phase === "connected" && | ||
| primaryEnvironment.serverConfig !== null && | ||
| localEnvironment?.connection.phase === "connected" && | ||
| localEnvironment.serverConfig !== null && | ||
| shellHasSnapshot; | ||
|
Comment on lines
+36
to
40
Contributor
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. Require a live local shell before the folder fallback reports ready.
Gate
|
||
|
|
||
| const open = (request: DesktopAppActivationRequest) => | ||
| handleDesktopAppActivationRequest(request, { | ||
| getTarget: () => { | ||
| if ( | ||
| primaryEnvironment?.connection.phase !== "connected" || | ||
| primaryEnvironment.serverConfig === null | ||
| localEnvironment?.connection.phase !== "connected" || | ||
| localEnvironment.serverConfig === null | ||
| ) { | ||
| return null; | ||
| } | ||
| return { | ||
| environmentId: primaryEnvironment.environmentId, | ||
| platform: primaryEnvironment.serverConfig.environment.platform.os, | ||
| environmentId: localEnvironment.environmentId, | ||
| platform: localEnvironment.serverConfig.environment.platform.os, | ||
| }; | ||
| }, | ||
| findProject: (environmentId, workspaceRoot) => | ||
|
|
||
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.
Seed the requested prompt before returning a recovered draft.
When an abandoned open with
promptrecovers an existing empty draft,resultIfAbandonedreturns that draft's IDs without callingseedPrompt. The composer stays empty even though the caller asked for the prompt to be set.seedPromptalready keeps any user-written text, so calling it on the recovered draft preserves that text.Suggested fix