Files
dingoandClaude Opus 5.5 bb8c2fc359 Fix M9.8c review findings in the engineering client
Resolve pointer ownership per SDL event so same-batch panel clicks, wheel and
click-to-focus typing never reach the world; keep the Tab toggle independent of
idempotent external capture release; own launcher phase and remote session
together so Local fixture ends any remote attempt; wrap notices beside a
reserved close column within a bounded stack. Adds client-panels test and
host/session, same-batch and host-order Tab regressions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:10:32 -04:00

62 lines
2.2 KiB
C++

#pragma once
// M9.8c host-side ownership of the launcher phase together with the remote session,
// so the visible mode and the session lifetime cannot diverge (ADR-0084). Entering the
// local fixture, cancelling or failing drops the session at once: no retries, grant use
// or intentions continue behind a LOCAL FIXTURE banner. Dropping a session leaves its
// unresolved intentions unknown. `Session` provides
// step(time_point, const Intention&, UiState&, Launcher&).
#include "evo/client/input.hpp"
#include "evo/client/launcher.hpp"
#include "evo/client/ui_state.hpp"
#include <chrono>
#include <optional>
#include <utility>
namespace evo::client {
template <class Session> class SessionHost {
public:
[[nodiscard]] const Launcher& launcher() const noexcept {
return launcher_;
}
[[nodiscard]] Session* session() noexcept {
return session_ ? &*session_ : nullptr;
}
[[nodiscard]] const Session* session() const noexcept {
return session_ ? &*session_ : nullptr;
}
// Adopts a freshly opened session (from choosing or failed). Any previous session
// is dropped first; on refusal no session remains.
[[nodiscard]] bool connect(std::optional<Session> opened) {
session_.reset();
if (!opened || !launcher_.begin_connect())
return false;
session_.emplace(std::move(*opened));
return true;
}
void enter_fixture() noexcept {
session_.reset();
launcher_.start_fixture();
}
void cancel() noexcept {
session_.reset();
launcher_.cancel();
}
// Services the session only while connecting or connected; a failure observed
// during the step ends it immediately (Retry opens a new one).
void step(std::chrono::steady_clock::time_point now, const Intention& intention, UiState& ui) {
if (session_ && live())
session_->step(now, intention, ui, launcher_);
if (!live())
session_.reset();
}
private:
[[nodiscard]] bool live() const noexcept {
return launcher_.phase() == LaunchPhase::connecting ||
launcher_.phase() == LaunchPhase::connected;
}
Launcher launcher_;
std::optional<Session> session_;
};
} // namespace evo::client