Skip to content

Commit 813bff2

Browse files
committed
fix(mobile): hide reconnect-mcp until the thread has a session
hasThread is true for any selected thread, including ones with a null session. The menu offered /reconnect-mcp there, but the send handler can only reject it with 'Start a thread first'. Thread session state into the slash-command builder and only show the command when a session exists.
1 parent 565f437 commit 813bff2

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎apps/mobile/src/features/threads/NewTaskDraftScreen.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ export function NewTaskDraftScreen(props: {
383383
projectCwd: composerWorkspaceCwd,
384384
selectedProviderStatus: flow.selectedProviderStatus,
385385
hasThread: false,
386+
hasSession: false,
386387
hasCompactableConversation: false,
387388
offersUsageLimits: offersUsageLimits,
388389
enabled: isComposerFocused && !isComposerInteractionLocked,

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
388388
pullRequestRepository: project?.repositoryIdentity?.displayName ?? null,
389389
selectedProviderStatus,
390390
hasThread: true,
391+
hasSession: props.selectedThread.session !== null,
391392
hasCompactableConversation: props.hasCompactableConversation,
392393
onChangeDraftMessage: props.onChangeDraftMessage,
393394
onUpdateInteractionMode:

‎apps/mobile/src/features/threads/use-composer-command-menu.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe("mobile slash commands", () => {
3737
query: "pl",
3838
atMessageStart: true,
3939
hasThread: true,
40+
hasSession: true,
4041
allowInteractionMode,
4142
selectedProviderStatus: antigravity,
4243
});
@@ -62,6 +63,7 @@ describe("mobile slash commands", () => {
6263
query: "plan",
6364
atMessageStart: false,
6465
hasThread: false,
66+
hasSession: false,
6567
allowInteractionMode: true,
6668
selectedProviderStatus: antigravity,
6769
}),
@@ -73,6 +75,7 @@ describe("mobile slash commands", () => {
7375
query: "plan",
7476
atMessageStart: true,
7577
hasThread: true,
78+
hasSession: true,
7679
allowInteractionMode: true,
7780
selectedProviderStatus: {
7881
driver: ProviderDriverKind.make("codex"),
@@ -101,7 +104,7 @@ describe("mobile slash commands", () => {
101104
).toEqual({ text: "/plan ", cursor: 6, interactionMode: null });
102105
});
103106

104-
it("offers MCP reconnect for existing threads on any provider", () => {
107+
it("offers MCP reconnect only for threads with a session", () => {
105108
const claude = {
106109
driver: ProviderDriverKind.make("claudeAgent"),
107110
slashCommands: [],
@@ -111,15 +114,27 @@ describe("mobile slash commands", () => {
111114
query: "reconnect",
112115
atMessageStart: true,
113116
hasThread: true,
117+
hasSession: true,
114118
allowInteractionMode: false,
115119
selectedProviderStatus: claude,
116120
}).map((item) => item.id),
117121
).toEqual(["cmd:reconnect-mcp"]);
122+
expect(
123+
buildComposerSlashCommandItems({
124+
query: "reconnect",
125+
atMessageStart: true,
126+
hasThread: true,
127+
hasSession: false,
128+
allowInteractionMode: false,
129+
selectedProviderStatus: claude,
130+
}),
131+
).toEqual([]);
118132
expect(
119133
buildComposerSlashCommandItems({
120134
query: "reconnect",
121135
atMessageStart: true,
122136
hasThread: false,
137+
hasSession: false,
123138
allowInteractionMode: false,
124139
selectedProviderStatus: claude,
125140
}),

‎apps/mobile/src/features/threads/use-composer-command-menu.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export function buildComposerSlashCommandItems(input: {
5151
readonly query: string;
5252
readonly atMessageStart: boolean;
5353
readonly hasThread: boolean;
54+
/** Whether the thread has a provider session (false for threads with no message yet). */
55+
readonly hasSession: boolean;
5456
readonly hasCompactableConversation?: boolean;
5557
/** Whether T3 itself offers /usage-limits for the selected provider. */
5658
readonly offersUsageLimits?: boolean;
@@ -85,7 +87,7 @@ export function buildComposerSlashCommandItems(input: {
8587
label: "/default",
8688
description: "Switch to default mode",
8789
},
88-
...(input.hasThread
90+
...(input.hasThread && input.hasSession
8991
? [
9092
{
9193
id: "cmd:reconnect-mcp",
@@ -180,6 +182,7 @@ export function useComposerCommandMenu({
180182
pullRequestRepository = null,
181183
selectedProviderStatus,
182184
hasThread,
185+
hasSession,
183186
hasCompactableConversation,
184187
offersUsageLimits = false,
185188
enabled = true,
@@ -195,6 +198,7 @@ export function useComposerCommandMenu({
195198
readonly pullRequestRepository?: string | null;
196199
readonly selectedProviderStatus: ServerProvider | null;
197200
readonly hasThread: boolean;
201+
readonly hasSession: boolean;
198202
readonly hasCompactableConversation: boolean;
199203
/** Whether T3 itself offers /usage-limits for the selected provider. */
200204
readonly offersUsageLimits?: boolean;
@@ -346,6 +350,7 @@ export function useComposerCommandMenu({
346350
query: q,
347351
atMessageStart: trigger.rangeStart === 0,
348352
hasThread,
353+
hasSession,
349354
hasCompactableConversation,
350355
offersUsageLimits,
351356
allowInteractionMode: onUpdateInteractionMode !== undefined,
@@ -465,6 +470,7 @@ export function useComposerCommandMenu({
465470
return [];
466471
}, [
467472
hasThread,
473+
hasSession,
468474
hasCompactableConversation,
469475
onUpdateInteractionMode,
470476
pathSearch.entries,

0 commit comments

Comments
 (0)