Skip to content

Commit 738a2c8

Browse files
committed
fix: preserve start message in /new without workspace name
When user types "/new\nmessage here", the message was being lost because the parser only extracted startMessage when a workspace name was provided. Now correctly extract and pass startMessage, trunkBranch, and runtime flags even when no workspace name is specified (creation modal flow). Added tests: - /new with message but no workspace name - /new with flags and message but no workspace name _Generated with `mux`_
1 parent 72f3337 commit 738a2c8

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

src/utils/slashCommands/parser.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,32 @@ describe("commandParser", () => {
179179
});
180180
});
181181
});
182+
it("should preserve start message when no workspace name provided", () => {
183+
expectParse("/new\nBuild authentication system", {
184+
type: "new",
185+
workspaceName: undefined,
186+
trunkBranch: undefined,
187+
runtime: undefined,
188+
startMessage: "Build authentication system",
189+
});
190+
});
191+
192+
it("should preserve start message and flags when no workspace name", () => {
193+
expectParse("/new -t develop\nImplement feature X", {
194+
type: "new",
195+
workspaceName: undefined,
196+
trunkBranch: "develop",
197+
runtime: undefined,
198+
startMessage: "Implement feature X",
199+
});
200+
});
201+
202+
it("should preserve start message with runtime flag when no workspace name", () => {
203+
expectParse('/new -r "ssh dev.example.com"\nDeploy to staging', {
204+
type: "new",
205+
workspaceName: undefined,
206+
trunkBranch: undefined,
207+
runtime: "ssh dev.example.com",
208+
startMessage: "Deploy to staging",
209+
});
210+
});

src/utils/slashCommands/registry.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,24 @@ const newCommandDefinition: SlashCommandDefinition = {
539539

540540
// No workspace name provided - return undefined to open modal
541541
if (parsed._.length === 0) {
542+
// Get trunk branch from -t flag
543+
let trunkBranch: string | undefined;
544+
if (parsed.t !== undefined && typeof parsed.t === "string" && parsed.t.trim().length > 0) {
545+
trunkBranch = parsed.t.trim();
546+
}
547+
548+
// Get runtime from -r flag
549+
let runtime: string | undefined;
550+
if (parsed.r !== undefined && typeof parsed.r === "string" && parsed.r.trim().length > 0) {
551+
runtime = parsed.r.trim();
552+
}
553+
542554
return {
543555
type: "new",
544556
workspaceName: undefined,
545-
trunkBranch: undefined,
546-
runtime: undefined,
547-
startMessage: undefined,
557+
trunkBranch,
558+
runtime,
559+
startMessage: remainingLines,
548560
};
549561
}
550562

0 commit comments

Comments
 (0)