How to resend a message between dialog items in XPCE

I’ve been struggling with some basic XPCE code. I have this small snippet that contains two text boxes. I want to send text from one text item to the other every time it changes.

% swipl-win.exe
:- use_module(library(pce)).
:- initialization main.

main :-
    new(D, dialog),
    send(D, append, new(A, text_item(a, "a"))),
    send(D, append, new(B, text_item(b, "b"))),
    send(A, message, and(
        message(B, selection, A?selection),
        message(D, return, @nil)
    get(D, confirm, _),


We send a message when A changes to B, after which we return a message to the top-level dialog and backtrack to a state before we sent the message. Presumably, XPCE will retain the UI state from after the message was sent.

I can type something into text item A and see it reflected in B when I press enter. If I try editing A again, B refuses to change its value. What am I missing in order for B to start receiving messages from A again?