Skip to content

Add opt-in deferred speech reports with SpeakAfter() - #2858

Open
CMDR-Evolution wants to merge 2 commits into
EDCD:developfrom
CMDR-Evolution:hotfix/saa-mapping-order
Open

CMDR-Evolution wants to merge 2 commits into
EDCD:developfrom
CMDR-Evolution:hotfix/saa-mapping-order

Conversation

@CMDR-Evolution

@CMDR-Evolution CMDR-Evolution commented Oct 22, 2026 •

Copy link
Copy Markdown

This proposes an optional SpeakAfter(scriptToSpeak, maximumDelayMs, scriptToWaitFor?, args?) Cottle function for deferred speech reporting.

Core event delivery remains unchanged. A personality can schedule a separate mapping report, released after matching SAA surface signals have finished processing or a configurable timeout. The report is evaluated then, retaining the original mapping event while reading updated state.

The implementation includes same-body matching, cancellation, protection against duplicate execution, and documentation with combined-report examples. Default personalities are unchanged.

All 28 focused tests pass in an isolated harness using the production speech code and real Cottle. Full Windows and in-game validation remain outstanding, including whether 200 ms is sufficient in practice.

This is a proposed starting point for review; the API and implementation are open to adjustment.

Keep core mapping state immediate and release the mapping notification after matching SAA signals or a one-second fallback. Cover separate journal reads, body identity, replay, rings, context changes, and timer races with focused tests.
@Tkael

Tkael commented Nov 9, 2026

Copy link
Copy Markdown
Member

Does the genera need to be available to a body mapping report? Why not use surface signals as a follow-on event as it is currently?

@CMDR-Evolution

CMDR-Evolution commented Nov 9, 2026 •

Copy link
Copy Markdown
Author

Does the genera need to be available to a body mapping report? Why not use surface signals as a follow-on event as it is currently?

Hey TKael.
It's better having the biological details when mapping as it's related information for the body and allows richer reports for bodies. It cuts down TTS length as the planetary identification doesn't need to be mentioned twice (and that's how it was before).

From our chat on Discord, I assume a very small amount of time could be enough, like 300ms, or maybe even less than that. Please see the journal times in my opening comment at the top.

After the change earlier this year, I tried to work-around the issue over a few months, to force Body report to stem from Surface signals detected via Body mapped from either an event based route, or SAA (only when post FSS for confirmed biological signals),. However, there were edge cases which couldn't be covered such as pre-scanned systems, so I had to revert the work-around.

@Tkael

Tkael commented Nov 9, 2026

Copy link
Copy Markdown
Member

Please do not merge develop into your branch! https://github.com/EDCD/EDDI/blob/develop/docs/Contributing.md#work-in-progress-conventions

Please force push to undo that commit.

@CMDR-Evolution
CMDR-Evolution force-pushed the hotfix/saa-mapping-order branch from 15c71ab to 8a04745 Compare November 9, 2026 23:28
@CMDR-Evolution

Copy link
Copy Markdown
Author

Please do not merge develop into your branch! https://github.com/EDCD/EDDI/blob/develop/docs/Contributing.md#work-in-progress-conventions

Please force push to undo that commit.

My apologies, Tkael. I resolved the conflicts through GitHub’s UI without realising that it would merge develop into my branch. I’m still learning the contribution workflow.

I’ve now force-pushed the branch back to the original commit, undoing the merge as requested. I’ve also read the contribution guidelines and will leave the conflicts for you to handle. Thanks for pointing me in the right direction.

@Tkael

Tkael commented Nov 15, 2026

Copy link
Copy Markdown
Member

Thanks for explaining the use case. I've checked the history and found no mapping-specific reorder rule that was removed. However, speech generation ran in an unawaited background task starting in 4.1.0; 4.1.7 removed that background execution and introduced awaited speech handling. That could explain why later events previously supplied information before your mapping report evaluated it, although that ordering wasn’t guaranteed.

The concern with this PR is that it changes notification order for every monitor and responder, including VoiceAttack. Other user's may rely on Body mapped establishing context before surface signals are handled.

Your combined-report requirement is reasonable but I'm hesitant to change core event order to support it, particularly since this would introduce a new ordering guarantee rather than restore an earlier one.

@CMDR-Evolution

Copy link
Copy Markdown
Author

Thanks for looking into the history and explaining that, Tkael. I understand now that the earlier behaviour wasn’t a guaranteed ordering, and I appreciate the concern about changing it for other responders and VoiceAttack.

Would you be open to an optional approach confined to the Speech Responder, where Body mapped is processed and delivered normally, but a personality can request a deferred combined mapping report? Any immediate context or state setup would still happen in the original script, with only the reporting portion deferred.

The report could run as soon as matching SAA surface signals have been processed, using the system address and body ID to match them. If they haven’t arrived, perhaps a short fallback of around 200 ms could release the ordinary mapping report.

The intention would be to schedule the report for later evaluation while allowing event processing to continue, rather than pause the event handler. This would keep the normal event order for other monitors and responders, with the combined reporting behaviour enabled only by personalities that want it.

Would that be a more acceptable direction, or is there another approach you would prefer? I’d be happy to revise the proposal around your guidance before making further changes.

@Tkael

Tkael commented Nov 15, 2026

Copy link
Copy Markdown
Member

Yes, I was thinking that a custom Cottle function for delaying and then enqueuing new speech might be a possibility to explore (perhaps something like SpeakAfter(scriptToSpeak, maximumDelayMs, scriptToWaitFor?)). I haven't developed it yet and I'm not sure yet whether it would adequately address your use case.

Keep core event delivery unchanged. Add deferred script evaluation in the
Speech Responder with configurable fallback, same-body SAA matching,
original event context, explicit arguments, and lifecycle cancellation.
Include focused tests and personality integration examples.
@CMDR-Evolution CMDR-Evolution changed the title Defer body mapping reports until matching SAA signals are processed Add opt-in deferred speech reports with SpeakAfter() Nov 16, 2026
@CMDR-Evolution

Copy link
Copy Markdown
Author

Thanks a lot, Tkael. That sounds like a promising approach for what I need, and could be usable elsewhere too. I’ve revised this PR with an initial implementation of your SpeakAfter() suggestion, along with tests and usage examples, to give you something concrete to review.

Please feel free to tweak or reshape it however you think best.

@Tkael Tkael self-assigned this Nov 22, 2026
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