Skip to content

Desktop: send the answerer's courtesy 73 (fix dead-write in QSO complete())#570

Merged
patrickrb merged 2 commits into
devfrom
optio/task-12db66aa-4e51-4094-9da9-153631d2726c
Jul 13, 2026
Merged

Desktop: send the answerer's courtesy 73 (fix dead-write in QSO complete())#570
patrickrb merged 2 commits into
devfrom
optio/task-12db66aa-4e51-4094-9da9-153631d2726c

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

Root cause

The desktop QSO auto-sequencer's answerer flow (we reply to a CQ → send our grid → send R+report) is supposed to send a final courtesy "73" (WSJT-X Tx5) once the DX sends RR73. The RReport arm of process_rx did exactly that:

TxStage::RReport => match content {
    Content::Rr73 | Content::Rrr | Content::Bye73 => {
        self.tx_message = Some(format!("{} {} 73", dx, self.my_call)); // <- queue 73
        self.stage = TxStage::Bye73;
        return self.complete(&dx);
    }
    ...

…but complete() then unconditionally ran the return-to-CQ / stop cleanup, overwriting both tx_message and stage. So the queued "73" was a dead write: the answerer never transmitted it and instead jumped straight back to calling CQ, and TxStage::Bye73 was unreachable.

This diverged from:

  • iOS (ios/FT8AFKit/Sources/FT8Engine/QsoEngine.swift) — its complete() guards the cleanup with if stage != .bye73, and processRx wraps up on the next slot via an early Bye73 handler. Its unit test explicitly asserts the "73" is sent then CQ resumes.
  • WSJT-X, which sends the courtesy 73.

The desktop qso.rs was the reference port; iOS mirrored it and fixed this, but desktop still shipped the bug.

Fix

A faithful port of the iOS structure (no protocol/DSP change, pure state-machine sequencing):

  • Extract the return-to-CQ / stop cleanup into finish_qso().
  • complete() now calls finish_qso() only when stage != Bye73, so a queued courtesy 73 survives to be transmitted on the answerer's next TX slot.
  • process_rx wraps the QSO up (via finish_qso()) on the following slot, once the Bye73 message has had its TX slot.

Scope: only the answerer's RReport → RR73 path changes. The CQ-initiator path (Rr73 → 73) still completes immediately with no courtesy 73, and every other complete() caller is unaffected (their stage is never Bye73). The QSO is still logged exactly once, on the same slot as before — no change to the emitted QsoRecord. engine.rs keeps qso.active true through the 73 (stage Bye73), so maybe_transmit sends it, then the next cycle returns to CQ.

Testing

  • Extended answerer_full_sequence_logs_qso (which was a partial port of the iOS test that had dropped the tx_message/stage/next-slot assertions) to assert the courtesy 73 is queued ("K1ABC K0XYZ 73", stage Bye73) and that the next slot returns to CQ ("CQ K0XYZ EN37", stage Cq).
  • Built + ran the real qso.rs #[cfg(test)] suite in-sandbox via a #[path]-include harness (the full Tauri crate can't link webkit/dbus headless). 7/7 pass with the fix; the extended test fails on the pre-fix source (left: Some("CQ K0XYZ EN37"), right: Some("K1ABC K0XYZ 73")), confirming it catches the regression.

Risk

Low. Pure Rust logic, no platform cfg, no DSP/interop/encoder change — it makes the answerer emit the standard FT8 courtesy 73 that WSJT-X and the iOS port already send. Behavior is unchanged for the CQ-initiator role and for a non-auto_return_to_cq operator (the 73 is still sent, then the engine stops).

🤖 Generated with Claude Code

The QSO auto-sequencer's answerer path (we reply to a CQ, send our grid,
then R+report) is meant to send a final courtesy "73" (WSJT-X Tx5) once
the DX sends RR73. The `RReport` arm in `process_rx` set
`tx_message = "<dx> <me> 73"` and `stage = Bye73` for exactly that, then
called `complete()` — but `complete()` unconditionally ran the
return-to-CQ / stop cleanup, overwriting both. So the queued 73 was a
dead write: the answerer never transmitted it and jumped straight back to
calling CQ (and `TxStage::Bye73` was unreachable).

This diverged from the iOS port (`FT8Engine/QsoEngine.swift`), whose
`complete()` guards the reset with `if stage != .bye73` and whose
`processRx` wraps up on the next slot via an early `Bye73` handler — and
from WSJT-X, which sends the courtesy 73.

Fix (a faithful port of the iOS structure):
- Extract the return-to-CQ / stop cleanup into `finish_qso()`.
- `complete()` now only calls `finish_qso()` when `stage != Bye73`, so a
  queued courtesy 73 survives to be transmitted next slot.
- `process_rx` wraps the QSO up (via `finish_qso()`) on the following
  slot once the Bye73 message has had its TX slot.

Only the answerer's RReport->RR73 path changes; the CQ-initiator path
(Rr73->73) still completes immediately with no courtesy 73, and every
other `complete()` caller is unaffected (their stage is never Bye73).

The existing `answerer_full_sequence_logs_qso` test was a partial port of
the iOS test that dropped the tx_message/stage/next-slot assertions; it is
now extended to assert the courtesy 73 is queued (`"K1ABC K0XYZ 73"`,
stage `Bye73`) and that the next slot returns to CQ. Verified failing on
the pre-fix source and passing after via a `#[path]`-include harness
(`cargo test`, 7/7 green).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.46479% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.92%. Comparing base (601a649) to head (8843c39).
⚠️ Report is 32 commits behind head on dev.

Files with missing lines Patch % Lines
desktop/src-tauri/src/engine.rs 0.00% 13 Missing ⚠️
desktop/src-tauri/src/qso.rs 94.82% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #570      +/-   ##
============================================
+ Coverage     27.60%   27.92%   +0.31%     
  Complexity      165      165              
============================================
  Files           175      175              
  Lines         23333    23434     +101     
  Branches       3192     3192              
============================================
+ Hits           6442     6544     +102     
+ Misses        16698    16697       -1     
  Partials        193      193              
Flag Coverage Δ
desktop 57.31% <77.46%> (+1.07%) ⬆️
native 9.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
desktop/src-tauri/src/qso.rs 86.96% <94.82%> (+6.96%) ⬆️
desktop/src-tauri/src/engine.rs 6.51% <0.00%> (-0.07%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the desktop FT8 QSO auto-sequencer’s answerer flow so that when the DX sends RR73, the engine correctly queues and transmits the courtesy 73 (Tx5) before returning to CQ/idle, aligning desktop behavior with WSJT-X and the iOS implementation.

Changes:

  • Refactors QSO wrap-up logic into a new finish_qso() helper.
  • Updates complete()/process_rx() sequencing so a queued courtesy 73 isn’t immediately overwritten by return-to-CQ cleanup.
  • Extends the answerer sequence unit test to assert the Bye73 stage/queued message and the following slot’s return to CQ.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread desktop/src-tauri/src/qso.rs
process_rx() wrapped the QSO up (returned to CQ / stopped) whenever
stage == Bye73, on the assumption that the intervening TX slot always
sent the queued 73. But maybe_transmit() can bail — missed TX window
(now % CYCLE_MS > TX_LATEST_MS), wrong parity, rig already transmitting,
or an encode/playback failure — leaving the 73 queued but unsent. The
next process_rx() then clobbered it, so the answerer's courtesy 73 (and
a manual Tx5 73) could still be skipped in exactly those late-slot cases.

Gate finish_qso() on a new bye73_sent flag instead of on stage==Bye73
alone. The scheduler now calls QsoEngine::notify_transmitted() only when
start_transmit() actually keys up (it now returns bool), which latches
bye73_sent for the pending 73. Until then process_rx() keeps the 73
queued so maybe_transmit() retransmits it next eligible slot, matching
how every other stage retries. notify_transmitted() is a no-op off
Bye73, so in-progress sequences are unaffected.

Tests: existing answerer sequence now signals the transmit; added
bye73_not_finished_until_actually_transmitted (late-slot stays armed,
no double-log, finishes after notify) and notify_transmitted_is_noop_off_bye73.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@patrickrb
patrickrb merged commit e5317af into dev Jul 13, 2026
19 checks passed
@patrickrb
patrickrb deleted the optio/task-12db66aa-4e51-4094-9da9-153631d2726c branch July 13, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants