fix(mobile): keep quick-commands button steady while capabilities load (#9979)

* fix(mobile): keep quick-commands button steady while capabilities load

The tab-row quick-commands button only rendered once the capability probe
resolved true, so it popped in after the row was already visible (and
vanished during reconnect re-probes). Render it whenever support is not
confirmed absent and disable it until the probe settles — pre-quick-commands
hosts strip agentPrompt, so the action (not the button) must wait for
confirmation. Confirmed-unsupported hosts still hide it entirely.

* fix(mobile): explain unsupported quick commands on tap instead of hiding

Per feedback on the disabled/hidden states: the button now always renders
and stays tappable. Tapping against a desktop that confirmed no support
shows "Desktop update required for quick commands" (mirroring the browser
streaming copy); tapping while the capability probe is still resolving says
to try again in a moment. The sheet still opens only once support is
confirmed, since pre-quick-commands hosts strip agentPrompt.

* docs(pr): add QA screenshots for quick-commands button states

* test(mobile): lock quick-commands button stability

Add a focused source-contract test for the always-mounted tab action and confirmed-support sheet gate. Keep the non-obvious safety comment concise, and remove PR screenshots now hosted as GitHub user attachments.

* test(mobile): structurally guard quick-command action mount
This commit is contained in:
Brennan Benson
2026-07-22 14:18:59 -07:00
committed by GitHub
parent c6d280348a
commit 11310eef63
2 changed files with 83 additions and 7 deletions
+17 -7
View File
@@ -4525,14 +4525,24 @@ export default function SessionScreen() {
>
<Plus size={16} color={colors.textSecondary} strokeWidth={2.2} />
</Pressable>
{quickCommandsSupported === true ? (
<QuickCommandsTabButton
disabled={
creating || creatingBrowser || creatingMarkdown || connState !== 'connected'
{/* Why: stable placement matters, while old hosts must stay gated because they strip agentPrompt. */}
<QuickCommandsTabButton
disabled={
creating || creatingBrowser || creatingMarkdown || connState !== 'connected'
}
onPress={() => {
if (quickCommandsSupported === true) {
setShowQuickCommands(true)
return
}
onPress={() => setShowQuickCommands(true)}
/>
) : null}
showToast(
quickCommandsSupported === false
? 'Desktop update required for quick commands'
: 'Checking desktop capabilities — try again in a moment',
1600
)
}}
/>
</View>
)}
</SafeAreaView>
@@ -0,0 +1,66 @@
import { readFileSync } from 'node:fs'
import ts from 'typescript'
import { describe, expect, it } from 'vitest'
const fileUrl = new URL('../../app/h/[hostId]/session/[worktreeId].tsx', import.meta.url)
const source = readFileSync(fileUrl, 'utf8')
const sourceFile = ts.createSourceFile(
fileUrl.href,
source,
ts.ScriptTarget.Latest,
true,
ts.ScriptKind.TSX
)
function findQuickCommandsTabButtons(): ts.JsxSelfClosingElement[] {
const matches: ts.JsxSelfClosingElement[] = []
function visit(node: ts.Node): void {
if (
ts.isJsxSelfClosingElement(node) &&
node.tagName.getText(sourceFile) === 'QuickCommandsTabButton'
) {
matches.push(node)
}
ts.forEachChild(node, visit)
}
visit(sourceFile)
return matches
}
function getQuickCommandsTabSource(): string {
const start = source.indexOf('accessibilityLabel="New tab"')
expect(start).toBeGreaterThanOrEqual(0)
const end = source.indexOf('{/* Content-row host', start)
expect(end).toBeGreaterThan(start)
return source.slice(start, end)
}
describe('quick-commands tab stability', () => {
it('keeps the button mounted while preserving the capability gate', () => {
const tabSource = getQuickCommandsTabSource()
const buttons = findQuickCommandsTabButtons()
expect(buttons).toHaveLength(1)
const tabBar = buttons[0].parent
expect(ts.isJsxElement(tabBar)).toBe(true)
if (!ts.isJsxElement(tabBar)) {
return
}
expect(tabBar.openingElement.tagName.getText(sourceFile)).toBe('View')
const style = tabBar.openingElement.attributes.properties.find(
(attribute): attribute is ts.JsxAttribute =>
ts.isJsxAttribute(attribute) && attribute.name.getText(sourceFile) === 'style'
)
expect(style?.initializer?.getText(sourceFile)).toBe('{styles.tabBar}')
expect(tabSource).toContain('if (quickCommandsSupported === true)')
expect(tabSource).toContain('setShowQuickCommands(true)')
expect(tabSource).toContain('Desktop update required for quick commands')
expect(tabSource).toContain('Checking desktop capabilities — try again in a moment')
})
it('only presents the sheet after support is confirmed', () => {
expect(source).toContain('visible={showQuickCommands && quickCommandsSupported === true}')
})
})