iOS: private-AX snapshot drops focused for a keyboard-focused text input (bridge reads only hasFocus)

Aberta Para iniciantes
#4,112 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
74/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
ios, objective-c
Domínio
mobile-dev, testing

Direção de pesquisa

Comece em RunnerAXSnapshotBridge.m, em dictionaryForSnapshot: por volta da linha 730, e compare o mapeamento de focused com o comportamento de focusBool descrito na issue. Confirme que a alteração faz com que snapshots private-AX informem como focado um campo de texto com foco do teclado e, em seguida, verifique se o foco informado corresponde ao produtor do XCTest.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug ready-for-agent

What happens

On an iOS simulator, focused flips to false for a focused text input whenever the snapshot comes from the runner's private-AX backend. The field is being edited: the keyboard is visible and the selection grabbers are in the tree. But is focused / toBeFocused keeps failing until the backend switches back.

Cause

RunnerAXSnapshotBridge.m dictionaryForSnapshot: sets focused only from hasFocus:

result[@"focused"] = [self boolNumberForKey:@"hasFocus" snapshot:snapshot defaultValue:NO];

#2925 changed the XCTest producers (focusBool) to hasKeyboardFocus || hasFocus. The private-AX producer was left on hasFocus. A text input under the software keyboard holds hasKeyboardFocus, not hasFocus. #3163 fixed the same gap in the host-side snapshot-source/tree.ts decoder, but the runner's Objective-C bridge still has it on main (line 730).

The bug only shows when the XCTest channel is penalized. One queries_backend_timeout sends every snapshot to private-ax for snapshotXCTestChannelPenaltyDuration (120 s). A focus assertion that lands inside that window fails every poll. Outside it, the tree backend answers correctly. On a busy React Native screen this makes the failure intermittent.

Evidence (0.21.28, iOS 27.0 simulator, Xcode 27.1)

I instrumented both producers to log the raw KVC values for the composer textbox on every snapshot, then ran one chat thread-reply test 20 times:

backend hasFocus hasKeyboardFocus snapshot focused
xctest (tree) 0 1 true
private-ax 0 1 absent
  • 4 of 20 runs failed toBeFocused. Each failure started right after SNAPSHOT_XCTEST_CHANNEL_PENALIZED reason=queries_backend_timeout, and every snapshot in the failing window was PRIVATE_AX_SNAPSHOT_USED.
  • With the private-AX snapshot, [snapshot valueForKey:@"hasKeyboardFocus"] returns 1 on the focused field.
  • After changing that one line to hasKeyboardFocus || hasFocus, the same test passed 20/20, with the private-AX backend serving 200+ snapshots in every run.

Fix

result[@"focused"] = @([[self boolNumberForKey:@"hasKeyboardFocus" snapshot:snapshot defaultValue:NO] boolValue]
                       || [[self boolNumberForKey:@"hasFocus" snapshot:snapshot defaultValue:NO] boolValue]);

This matches focusBool, so both producers report the same focused for the same element. We carry it as a bun patch on 0.21.28 until a release ships it.

Related: #4110 (we drive the same patched runner remotely).

Linguagem predominante
TypeScript
Estrelas
5.2k
Forks
359
Merge médio
13h 37min
PRs com merge (30d)
665

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de callstack/agent-device

Todas as issues de callstack/agent-device

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.