@devries-cameron20 / t3code-1 / commits / 16ff4b45ee
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(mobile): fully typed /model keeps its suggestion (#37280)

Co-authored-by: Grok 4.7 <noreply@x.ai> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 15, 2026 at 18:20 UTC 16ff4b45ee8839968c9db2cc44b20d81160fafbf
2 files changed +13 -56
packages/shared/src/composerTrigger.test.ts
+12 -13
@@ -34,22 +34,21 @@ describe("detectComposerTrigger", () => {
34 expect(detectComposerTrigger(text, cursor)).toBeNull();
35 });
36
37 - it("keeps a slash in the line-leading model picker query", () => {
38 - expect(detectComposerTrigger("/model openai/gpt", 17)).toMatchObject({
39 - kind: "slash-model",
40 - query: "openai/gpt",
37 + it.each([
38 + ["/model", 0],
39 + ["Question\n/MODEL", 9],
40 + ])("offers typed %j as a slash command", (text, rangeStart) => {
41 + expect(detectComposerTrigger(text, text.length)).toEqual({
42 + kind: "slash-command",
43 + query: text.slice(rangeStart + 1),
44 + rangeStart,
45 + rangeEnd: text.length,
46 });
47 });
48
44 - it.each(["/Model opus", "/MODEL opus"])(
45 - "opens the model picker for capitalized %j the same as /model",
46 - (text) => {
47 - expect(detectComposerTrigger(text, text.length)).toMatchObject({
48 - kind: "slash-model",
49 - query: "opus",
50 - });
51 - },
52 - );
49 + it("does not reopen a menu after /model arguments", () => {
50 + expect(detectComposerTrigger("/Model opus", "/Model opus".length)).toBeNull();
51 + });
52
53 it.each(["Use /", "Use /review"])("detects the inline slash token in %j", (text) => {
54 expect(detectComposerTrigger(text, text.length)).toEqual({
packages/shared/src/composerTrigger.ts
+1 -43
@@ -1,9 +1,4 @@
1 -export type ComposerTriggerKind =
2 - | "path"
3 - | "pull-request"
4 - | "slash-command"
5 - | "slash-model"
6 - | "skill";
1 +export type ComposerTriggerKind = "path" | "pull-request" | "slash-command" | "skill";
2 export type ComposerSlashCommand = "model" | "plan" | "default";
3
4 export interface ComposerTrigger {
@@ -76,43 +71,6 @@ export function detectComposerTrigger(
71 isWhitespaceChar?: (char: string) => boolean,
72 ): ComposerTrigger | null {
73 const cursor = clampCursor(text, cursorInput);
79 - const lineStart = text.lastIndexOf("\n", Math.max(0, cursor - 1)) + 1;
80 - const linePrefix = text.slice(lineStart, cursor);
81 -
82 - if (linePrefix.startsWith("/")) {
83 - const commandMatch = /^\/(\S*)$/.exec(linePrefix);
84 - if (commandMatch && isPathWord(text, lineStart, cursor, isWhitespaceChar ?? isWhitespace)) {
85 - return null;
86 - }
87 - if (commandMatch) {
88 - const commandQuery = commandMatch[1] ?? "";
89 - if (commandQuery.toLowerCase() === "model") {
90 - return {
91 - kind: "slash-model",
92 - query: "",
93 - rangeStart: lineStart,
94 - rangeEnd: cursor,
95 - };
96 - }
97 - return {
98 - kind: "slash-command",
99 - query: commandQuery,
100 - rangeStart: lineStart,
101 - rangeEnd: cursor,
102 - };
103 - }
104 -
105 - const modelMatch = /^\/model(?:\s+(.*))?$/i.exec(linePrefix);
106 - if (modelMatch) {
107 - return {
108 - kind: "slash-model",
109 - query: (modelMatch[1] ?? "").trim(),
110 - rangeStart: lineStart,
111 - rangeEnd: cursor,
112 - };
113 - }
114 - }
115 -
74 const wsCheck = isWhitespaceChar ?? isWhitespace;
75 let tokenIdx = cursor - 1;
76 while (tokenIdx >= 0 && !wsCheck(text[tokenIdx] ?? "")) {