Walkthrough: the button that stopped working
This walkthrough follows one bug from the first report to a verified fix, using only Sonde’s tools against the running application. The bug is the kind that is hard to find by reading code or by looking at the screen, and easy to find by asking the application what is actually there.
What it demonstrates:
- seeing the application the way the code sees it (the object tree), not only the way it looks (screenshots)
- using the application’s own log as the test oracle, with
event_wait - testing a theory in the running process before editing any code
- checking a fix by running exactly the same steps again
Who it’s for: anyone who wants to see what Sonde is good for, from application developers to people driving it through an AI agent. You need the project built (see developing.md) and about 15 minutes.
Try it yourself first? The application,
examples/acme-orders, contains the bug. If you want to hunt for it yourself, stop after Set up and come back when you are stuck. Don’t readexamples/acme-orders/main.cpp; that would spoil it.
All outputs below are real, though some are trimmed to the relevant lines.
Object ids (@0x…), timestamps and event sequence numbers will be different
when you run it.
The report
“Since the coupon feature went in, customers say ‘Place order’ sometimes does nothing. Clicking does nothing, but Ctrl+Return works. QA can’t reproduce it reliably, and the code review found nothing.”
Set up
From the repository root, after building:
SONDE_HTTP=8799 build/examples/acme-orders/acme-orders &
Add QT_QPA_PLATFORM=offscreen in front to run it without a window on screen.
Everything in this walkthrough still works, screenshots included.
We’ll talk to it with sonde, a small command-line MCP client that is
built with Sonde, at build/sonde, and keeps one session between calls:
export SONDE_URL=http://127.0.0.1:8799/mcp
alias mcp=build/sonde
mcp tools
app_info Application info
event_read Read events
event_wait Wait for an event
input_keys Press keys
...
input_text Type text
You could do the same with an AI agent instead. In Claude Code:
claude mcp add --transport http acme http://127.0.0.1:8799/mcp, then paste
the report above and ask it to investigate; it has the same tools available.
See Doing this with an AI agent.
Step 1: look at the application
mcp window_screenshot
[image saved to sonde-1.png at 10:42:07.311]
@0x7d8c96460 QMainWindow "Acme Orders", 360x300 px. Image pixels are window coordinates.

The screenshot shows what a user sees. object_tree shows what the code sees,
including the objectNames we can use to target things:
mcp object_tree '{"root": "orderWindow", "className": "QWidget"}'
@0x16f6adcb8 QMainWindow#orderWindow windowTitle="Acme Orders"
@0x7d8c1cbd0 QWidget
@0x7d909ed90 QLabel text="Quantity:"
@0x7d9050330 QSpinBox#quantity text="1"
@0x7d9050120 QLineEdit#qt_spinbox_lineedit text="1"
@0x7d93689c0 QLabel text="Coupon:"
@0x7d8db2820 QLineEdit#couponEdit placeholderText="Coupon code"
@0x7d8db2880 QPushButton#applyCoupon text="Apply"
@0x7d909edc0 QLabel text="Total:"
@0x7d8db28b0 QLabel#totalLabel text="$12.50"
@0x7d9347c00 QPushButton#placeOrder text="Place order"
@0x7d9369bf0 QStatusBar
@0x7d9369c20 QSizeGrip
(1 hidden subtree(s) omitted; pass visibleOnly=false to include)
Keep that last line in mind. Something hidden exists in this window.
Step 2: get a baseline
Before chasing a bug, check that the feature works when the bug is not triggered. Otherwise you can’t tell “broken” from “never worked”.
We want proof that an order was placed, and the application logs every order. So first note where the event log is now:
mcp event_read '{"limit": 1}'
1 event(s); lastSequence=2; buffer holds #1..#2; ...
#2 03:32:28.840 warning log: This plugin does not support propagateSizeHints()
Then click the button, and wait for the log line the click should produce.
Use the lastSequence you got as sinceSequence:
mcp input_click '{"object": "QPushButton[text=Place order]"}'
mcp event_wait '{"sinceSequence": 2, "contains": "Order placed", "timeoutMs": 2000}'
Clicked at (180, 249) in @0x7d8c96460 QMainWindow "Acme Orders" on @0x7d9347c00 QPushButton#placeOrder text="Place order"
#3 03:32:39.318 info log[acme.order]: Order placed: quantity 1 total "$12.50" {"file":".../examples/acme-orders/main.cpp","function":"void OrderWindow::placeOrder()","line":124}
Two things to notice:
input_clicktargeted the button by its label, not by pixel position, and its reply says what it actually hit.- In a debug build, the log event includes the source location of the
qCInfothat produced it. That is a free pointer into the code.
Step 3: reproduce the report
Now follow the report’s steps: apply a coupon, then try to order.
mcp input_text '{"object": "couponEdit", "text": "save10"}'
mcp input_click '{"object": "applyCoupon"}'
mcp --image toast.png window_screenshot
Typed 6 character(s) in @0x7d8c96460 QMainWindow "Acme Orders". Focus: @0x7d8db2820 QLineEdit#couponEdit text="save10"
Clicked at (311, 53.5) in @0x7d8c96460 QMainWindow "Acme Orders" on @0x7d8db2880 QPushButton#applyCoupon text="Apply"

A confirmation message (a “toast”) appears over the button for a moment. Wait a couple of seconds for it to go away, take another screenshot, and click again:
sleep 2
mcp --image after.png window_screenshot
mcp input_click '{"object": "placeOrder"}'
mcp event_wait '{"sinceSequence": 3, "contains": "Order placed", "timeoutMs": 3000}'
Clicked at (180, 249) in @0x7d8c96460 QMainWindow "Acme Orders" on @0x7d9347cc0 QLabel#toast
Timed out after 3000 ms; no matching events. lastSequence=4
Reproduced: no order was placed. And the click reply already gives the
answer away. We asked for placeOrder, the click landed at the centre of
the button, and what was under the pointer there was QLabel#toast.
Newer versions say it outright. This walkthrough was recorded before
input_clickreported where the press actually went. It does now. Here is the same click from a later run (so the ids differ from the rest of this page):Clicked at (180, 249) in @0xbc8d44060 QMainWindow "Acme Orders" on @0xbc9131cb0 QLabel#toast Delivered to (in order; each object before the last ignored the event and Qt passed it on): press: @0xbc9131cb0 QLabel#toast -> @0xbc90cd140 QWidget -> @0x16b9e9cd8 QMainWindow#orderWindow Note: the press did not reach @0xbc9131a40 QPushButton#placeOrder text="Place order" or anything inside it; something else is receiving input at that point.The toast received the press, ignored it, and Qt passed it up through the central widget to the main window. The button never saw it.
layout_explainon the button says the same thing from the layout side (also from a later run):@0x8fac2aa30 QPushButton#placeOrder text="Place order" ! held at its minimumSize ! overlapped by siblings stacked above it (see siblingsAbove) siblingsAbove: ["@0x8fae187e0 QLabel#toast"]and on the toast, that no layout manages it:
"note":"this widget is not managed by its parent's layout".Steps 5 and 6 below work all this out from first principles, which is still worth reading: that is how you check a report like this one.
Step 4: notice why nobody could see it
Here is the screenshot taken just before that failed click:

It looks perfect. The status bar even says “Order placed. Thank you!”, but that message is left over from the order in step 2. A tester who looked at the screen after clicking would believe the order went through. This is why step 2 matters, and why we check the log rather than the screen.
Step 5: find out what is in the way
The object tree now shows the toast. It was hidden in step 1:
mcp object_tree '{"root": "orderWindow", "depth": 2}'
@0x7d9347c00 QPushButton#placeOrder text="Place order"
@0x7d9347cc0 QLabel#toast
Note that it has no text="..." in its description, and is not marked
(hidden). Ask what is at the point we clicked:
mcp object_at '{"x": 180, "y": 249}'
@0x7d9347cc0 QLabel#toast
geometry in window: 1,221 358x56
in @0x7d8c1cbd0 QWidget
in @0x16f6adcb8 QMainWindow#orderWindow windowTitle="Acme Orders"
and compare the toast with the button:
mcp object_inspect '{"object": "toast", "methods": false}'
mcp object_inspect '{"object": "placeOrder", "methods": false}'
@0x7d9347cc0 QLabel#toast
geometry: QRect = {"height":56,"width":358,"x":1,"y":221}
visible: bool = true
styleSheet: QString = "QLabel#toast { color: #1b5e20; font-weight: bold; background: transparent; }"
text: QString = ""
...
geometry: QRect = {"height":40,"width":342,"x":9,"y":229} (placeOrder)
(Output shortened to the interesting properties.)
This is the whole story:
| Property | Value | Meaning |
|---|---|---|
visible |
true |
The toast was never hidden. |
text |
"" |
Its text was cleared instead. |
styleSheet |
background: transparent |
With no text, nothing is drawn: it is invisible. |
geometry |
1,221 358×56 | It completely covers the button at 9,229 342×40. |
An invisible, empty label sits on top of the button and receives the clicks.
QLabel ignores them, so they never reach the button underneath.
Step 6: check it explains every clue
A good diagnosis explains all the symptoms, not just the main one.
- “Clicking does nothing”: the label takes the clicks.
- “Sometimes”: the toast is only created by applying a coupon.
- “Ctrl+Return works”: a keyboard shortcut doesn’t go through the mouse, so the overlay doesn’t matter. Let’s confirm:
mcp input_keys '{"keys": "Ctrl+Return"}'
mcp event_wait '{"sinceSequence": 4, "contains": "Order placed", "timeoutMs": 2000}'
Pressed Ctrl+Return in @0x7d8c96460 QMainWindow "Acme Orders". Focus: @0x7d8db2880 QPushButton#applyCoupon text="Apply"
#5 03:32:45.716 info log[acme.order]: Order placed: quantity 1 total "$11.25"
Step 7: prove it before changing code
We have a theory. Test it in the running application by hiding the toast and clicking again:
mcp object_set '{"object": "toast", "property": "visible", "value": false}'
mcp input_click '{"object": "placeOrder"}'
mcp event_wait '{"sinceSequence": 5, "contains": "Order placed", "timeoutMs": 2000}'
@0x7d9347cc0 QLabel#toast (hidden).visible = false
Clicked at (180, 249) in @0x7d8c96460 QMainWindow "Acme Orders" on @0x7d9347c00 QPushButton#placeOrder text="Place order"
#6 03:32:46.063 info log[acme.order]: Order placed: quantity 1 total "$11.25"
Hiding the toast fixes the click. The theory is confirmed, and we haven’t edited or rebuilt anything yet.
Step 8: fix it
Now open examples/acme-orders/main.cpp. Knowing exactly what to look for
(code that clears the toast instead of hiding it), the bug is the timer in
applyCoupon():
m_toast->setStyleSheet(QStringLiteral("QLabel#toast { color: #1b5e20; font-weight: bold; background: transparent; }"));
+ m_toast->setAttribute(Qt::WA_TransparentForMouseEvents); // never swallow clicks
m_toast->hide();
...
- QTimer::singleShot(1500, m_toast, [this] { m_toast->clear(); });
+ QTimer::singleShot(1500, m_toast, [this] { m_toast->hide(); });
Two changes:
- The bug:
hide()instead ofclear(). - Defence in depth:
Qt::WA_TransparentForMouseEventsmakes the toast let clicks through even while it is showing. A notification should never block the controls under it.
Read the original line again: m_toast->clear() looks perfectly reasonable.
Nothing about it says “this leaves a widget on screen”, which is why the code
review didn’t catch it.
Step 9: verify the fix
Rebuild, restart the application, and repeat the reproduction, adding a stricter case the report didn’t mention: clicking while the toast is visible.
cmake --build build --target acme-orders
kill %1; SONDE_HTTP=8799 build/examples/acme-orders/acme-orders &
mcp input_text '{"object": "couponEdit", "text": "save10"}'
mcp input_click '{"object": "applyCoupon"}'
mcp input_click '{"object": "placeOrder", "settleMs": 0}' # during the toast
sleep 2
mcp input_click '{"object": "placeOrder"}' # after the toast
mcp event_read '{"contains": "Order placed"}'
Clicked at (180, 249) in @0xc9f35de60 QMainWindow "Acme Orders" on @0xc9f36bf00 QPushButton#placeOrder text="Place order"
Clicked at (180, 249) in @0xc9f35de60 QMainWindow "Acme Orders" on @0xc9f36bf00 QPushButton#placeOrder text="Place order"
2 event(s); lastSequence=5; buffer holds #1..#5
#4 03:33:02.054 info log[acme.order]: Order placed: quantity 1 total "$11.25"
#5 03:33:04.135 info log[acme.order]: Order placed: quantity 1 total "$11.25"
Both clicks reach the button, and both orders are logged. The object specs
(couponEdit, placeOrder) still work after the rebuild, even though every
object id changed. That’s why you should target objects by name, not by id or
pixel position.
To leave the example in its original state for the next reader, undo your
edit with git checkout examples/acme-orders/main.cpp.
What made the difference
| Technique | Tool | Why it mattered here |
|---|---|---|
| Look at the object tree, not just pixels | object_tree, object_at, object_inspect |
The overlay was invisible in every screenshot. |
| Read what the tool actually did | input_click’s reply |
“on QLabel#toast” pointed at the cause on the first failure. |
| Use the log as the test oracle | event_read, event_wait |
The screen said “Order placed”; the log said no order was placed. |
| Establish a baseline first | the same tools, before the trigger | Proved the feature works until a coupon is applied. |
| Test the theory live | object_set |
Confirmed the cause without editing or rebuilding. |
| Explain every symptom | input_keys |
The keyboard clue fit the theory, which gave confidence it was complete. |
| Repeat the exact steps | the same commands | A repeatable check of the fix, not “seems fine now”. |
Applying this to your own application
The same recipe works for most “the UI doesn’t do what I expect” bugs:
- Give important widgets and QML items an
objectName. It makes them easy to target and recognise in the tree. - Log meaningful actions (
qCInfo(lcOrders) << "Order placed" ...), soevent_waitcan confirm them. Logging is cheap, and it turns “did that work?” into a question with a definite answer. - Baseline, reproduce, inspect, experiment, fix, re-run. In that order.
- When a click “does nothing”, ask what was clicked. Check the target in
input_click’s reply, or useobject_at. Overlays, disabled parents, modal dialogs and widgets that are outside their parent’s area all show up there.
Doing this with an AI agent
With the server connected to an agent (Claude Code shown here), you can hand over the whole investigation:
The Acme Orders app is running with MCP. Users report that after applying a coupon, clicking “Place order” does nothing, though Ctrl+Return works. Reproduce it, find the cause in the running app, prove it before changing code, then fix examples/acme-orders/main.cpp and verify the fix.
The agent gets the same information you did: tool descriptions, the server’s usage instructions and every tool reply. The steps in this walkthrough are a good checklist for judging its work. Did it get a baseline, prove the cause, and re-run the reproduction? Every action it takes is a tool call you can read in the transcript.
Things to try
- Apply an invalid coupon and find the warning it logs, using
event_readwithminLevel: "warning". - Change the quantity with
input_keys(Up, withobject: "quantity") orinput_text, and check the total withobject_inspect totalLabel. - Re-introduce the bug, then write a GoogleTest regression test for it, using
the
GuiTestfixture as a model (see developing.md, “Writing tests”).