implements PLN-0137
This commit is contained in:
parent
d54dadf2a5
commit
57c9af939b
@ -12,6 +12,9 @@ pub use services::async_work::{
|
||||
AsyncWorkJobKind, AsyncWorkJobOutcome, AsyncWorkLane, AsyncWorkLaneConfig,
|
||||
AsyncWorkLaneController, AsyncWorkLaneError, AsyncWorkLaneTelemetry, AsyncWorkPriority,
|
||||
};
|
||||
pub use services::foreground::{
|
||||
ForegroundOwner, ForegroundStack, ForegroundStackError, ResidentGame, ResidentGameState,
|
||||
};
|
||||
pub use services::fs;
|
||||
pub use services::game_library::{
|
||||
GameLibrary, GameLibraryDiagnostic, GameLibraryEntry, discover_games_root,
|
||||
|
||||
@ -2,7 +2,8 @@ use crate::CrashReport;
|
||||
use crate::os::SystemOS;
|
||||
use crate::os::{LifecycleError, LifecycleOperation};
|
||||
use crate::process::{ProcessId, ProcessState};
|
||||
use crate::task::{TaskId, TaskState};
|
||||
use crate::services::foreground::{ForegroundOwner, ForegroundStackError, ResidentGame};
|
||||
use crate::task::{TaskId, TaskKind, TaskState};
|
||||
|
||||
pub struct LifecycleFacade<'a> {
|
||||
pub(in crate::os) os: &'a mut SystemOS,
|
||||
@ -23,19 +24,92 @@ impl<'a> LifecycleFacade<'a> {
|
||||
}
|
||||
|
||||
pub fn set_foreground_task(&mut self, task_id: TaskId) -> Result<(), LifecycleError> {
|
||||
match task_kind_for_task(self.os, task_id)? {
|
||||
TaskKind::Game => return self.set_game_foreground_task(task_id),
|
||||
TaskKind::Shell => return self.set_shell_foreground_task(task_id),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_game_foreground_task(&mut self, task_id: TaskId) -> Result<(), LifecycleError> {
|
||||
let process_id = process_id_for_task(self.os, task_id)?;
|
||||
|
||||
if task_kind_for_task(self.os, task_id)? != TaskKind::Game {
|
||||
return Err(LifecycleError::InvalidTransition {
|
||||
task_id,
|
||||
from: self.task_state(task_id).unwrap_or(TaskState::Closed),
|
||||
operation: LifecycleOperation::SetForeground,
|
||||
});
|
||||
}
|
||||
|
||||
self.os.foreground_stack.set_game_foreground(task_id).map_err(map_foreground_error)?;
|
||||
self.os.task_manager.set_foreground(task_id);
|
||||
self.os.process_manager.mark_running(process_id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_shell_foreground_task(&mut self, task_id: TaskId) -> Result<(), LifecycleError> {
|
||||
let process_id = process_id_for_task(self.os, task_id)?;
|
||||
|
||||
if task_kind_for_task(self.os, task_id)? != TaskKind::Shell {
|
||||
return Err(LifecycleError::InvalidTransition {
|
||||
task_id,
|
||||
from: self.task_state(task_id).unwrap_or(TaskState::Closed),
|
||||
operation: LifecycleOperation::SetForeground,
|
||||
});
|
||||
}
|
||||
|
||||
self.os.foreground_stack.set_shell_foreground(task_id).map_err(map_foreground_error)?;
|
||||
self.os.task_manager.set_foreground(task_id);
|
||||
self.os.process_manager.mark_running(process_id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn foreground_owner(&self) -> ForegroundOwner {
|
||||
self.os.foreground_stack.owner()
|
||||
}
|
||||
|
||||
pub fn resident_game(&self) -> Option<ResidentGame> {
|
||||
self.os.foreground_stack.resident_game()
|
||||
}
|
||||
|
||||
pub fn resident_game_task(&self) -> Option<TaskId> {
|
||||
self.os.foreground_stack.resident_game_task()
|
||||
}
|
||||
|
||||
pub fn request_home_from_game(&mut self, task_id: TaskId) -> Result<(), LifecycleError> {
|
||||
let process_id = process_id_for_task(self.os, task_id)?;
|
||||
|
||||
self.os.foreground_stack.request_home_from_game(task_id).map_err(map_foreground_error)?;
|
||||
self.os.task_manager.mark_suspended(task_id);
|
||||
self.os.process_manager.mark_suspended(process_id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn return_to_hub(&mut self) {
|
||||
self.os.foreground_stack.return_to_hub();
|
||||
self.os.task_manager.clear_foreground();
|
||||
}
|
||||
|
||||
pub fn suspend_task(&mut self, task_id: TaskId) -> Result<(), LifecycleError> {
|
||||
let process_id = process_id_for_task(self.os, task_id)?;
|
||||
|
||||
self.os.task_manager.mark_suspended(task_id);
|
||||
self.os.process_manager.mark_suspended(process_id);
|
||||
match self.os.foreground_stack.owner() {
|
||||
ForegroundOwner::Game(owner) if owner == task_id => {
|
||||
self.os
|
||||
.foreground_stack
|
||||
.request_home_from_game(task_id)
|
||||
.map_err(map_foreground_error)?;
|
||||
}
|
||||
ForegroundOwner::Shell(owner) if owner == task_id => {
|
||||
self.os.foreground_stack.return_to_hub();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -54,8 +128,24 @@ impl<'a> LifecycleFacade<'a> {
|
||||
|
||||
let process_id = process_id_for_task(self.os, task_id)?;
|
||||
|
||||
self.os.task_manager.set_foreground(task_id);
|
||||
self.os.process_manager.mark_running(process_id);
|
||||
match task_kind_for_task(self.os, task_id)? {
|
||||
TaskKind::Game => {
|
||||
self.os
|
||||
.foreground_stack
|
||||
.set_game_foreground(task_id)
|
||||
.map_err(map_foreground_error)?;
|
||||
self.os.task_manager.set_foreground(task_id);
|
||||
self.os.process_manager.mark_running(process_id);
|
||||
}
|
||||
TaskKind::Shell => {
|
||||
self.os
|
||||
.foreground_stack
|
||||
.set_shell_foreground(task_id)
|
||||
.map_err(map_foreground_error)?;
|
||||
self.os.task_manager.set_foreground(task_id);
|
||||
self.os.process_manager.mark_running(process_id);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -65,6 +155,12 @@ impl<'a> LifecycleFacade<'a> {
|
||||
|
||||
self.os.task_manager.close_task(task_id);
|
||||
self.os.process_manager.mark_stopped(process_id);
|
||||
if self.os.foreground_stack.resident_game_task() == Some(task_id) {
|
||||
self.os.foreground_stack.clear_resident_game(task_id);
|
||||
} else if matches!(self.os.foreground_stack.owner(), ForegroundOwner::Shell(owner) if owner == task_id)
|
||||
{
|
||||
self.os.foreground_stack.return_to_hub();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -78,11 +174,22 @@ impl<'a> LifecycleFacade<'a> {
|
||||
|
||||
self.os.task_manager.mark_crashed(task_id);
|
||||
self.os.process_manager.mark_crashed(process_id);
|
||||
if self.os.foreground_stack.resident_game_task() == Some(task_id) {
|
||||
self.os.foreground_stack.clear_resident_game(task_id);
|
||||
} else if matches!(self.os.foreground_stack.owner(), ForegroundOwner::Shell(owner) if owner == task_id)
|
||||
{
|
||||
self.os.foreground_stack.return_to_hub();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn task_kind_for_task(os: &SystemOS, task_id: TaskId) -> Result<TaskKind, LifecycleError> {
|
||||
let task = os.task_manager.get(task_id).ok_or(LifecycleError::TaskNotFound(task_id))?;
|
||||
Ok(task.kind)
|
||||
}
|
||||
|
||||
fn process_id_for_task(os: &SystemOS, task_id: TaskId) -> Result<ProcessId, LifecycleError> {
|
||||
let task = os.task_manager.get(task_id).ok_or(LifecycleError::TaskNotFound(task_id))?;
|
||||
|
||||
@ -92,3 +199,17 @@ fn process_id_for_task(os: &SystemOS, task_id: TaskId) -> Result<ProcessId, Life
|
||||
|
||||
Ok(task.process_id)
|
||||
}
|
||||
|
||||
fn map_foreground_error(error: ForegroundStackError) -> LifecycleError {
|
||||
match error {
|
||||
ForegroundStackError::ResidentGameAlreadyExists { existing, requested } => {
|
||||
LifecycleError::ResidentGameAlreadyExists { existing, requested }
|
||||
}
|
||||
ForegroundStackError::ForegroundShellAlreadyExists { existing, requested } => {
|
||||
LifecycleError::ForegroundShellAlreadyExists { existing, requested }
|
||||
}
|
||||
ForegroundStackError::TaskIsNotResidentGame(task_id) => {
|
||||
LifecycleError::TaskIsNotResidentGame(task_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ impl<'a> SessionsFacade<'a> {
|
||||
let task_id = self.os.task_manager.create_game_task(process_id, app_id, title);
|
||||
self.os
|
||||
.lifecycle()
|
||||
.set_foreground_task(task_id)
|
||||
.set_game_foreground_task(task_id)
|
||||
.expect("newly created game task should have an associated process");
|
||||
|
||||
task_id
|
||||
@ -24,7 +24,7 @@ impl<'a> SessionsFacade<'a> {
|
||||
let task_id = self.os.task_manager.create_shell_task(process_id, app_id, title);
|
||||
self.os
|
||||
.lifecycle()
|
||||
.set_foreground_task(task_id)
|
||||
.set_shell_foreground_task(task_id)
|
||||
.expect("newly created shell task should have an associated process");
|
||||
|
||||
task_id
|
||||
@ -36,7 +36,7 @@ impl<'a> SessionsFacade<'a> {
|
||||
let task_id = self.os.task_manager.create_shell_task(process_id, app_id, title);
|
||||
self.os
|
||||
.lifecycle()
|
||||
.set_foreground_task(task_id)
|
||||
.set_shell_foreground_task(task_id)
|
||||
.expect("newly created native shell task should have an associated process");
|
||||
|
||||
task_id
|
||||
|
||||
@ -15,4 +15,7 @@ pub enum LifecycleError {
|
||||
TaskNotFound(TaskId),
|
||||
ProcessNotFound(ProcessId),
|
||||
InvalidTransition { task_id: TaskId, from: TaskState, operation: LifecycleOperation },
|
||||
ResidentGameAlreadyExists { existing: TaskId, requested: TaskId },
|
||||
ForegroundShellAlreadyExists { existing: TaskId, requested: TaskId },
|
||||
TaskIsNotResidentGame(TaskId),
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ use crate::VirtualMachineRuntime;
|
||||
use crate::fs::{FsState, VirtualFS};
|
||||
use crate::os::{FsFacade, LifecycleFacade, SessionsFacade, VmFacade, WindowFacade};
|
||||
use crate::process::ProcessManager;
|
||||
use crate::services::foreground::ForegroundStack;
|
||||
use crate::services::memcard::MemcardService;
|
||||
use crate::services::windows::WindowManager;
|
||||
use crate::task::TaskManager;
|
||||
@ -14,6 +15,7 @@ pub struct SystemOS {
|
||||
pub(super) vm_runtime: VirtualMachineRuntime,
|
||||
pub(super) process_manager: ProcessManager,
|
||||
pub(super) task_manager: TaskManager,
|
||||
pub(super) foreground_stack: ForegroundStack,
|
||||
pub(super) window_manager: WindowManager,
|
||||
pub(super) log_service: LogService,
|
||||
pub(super) fs: VirtualFS,
|
||||
@ -33,6 +35,7 @@ impl SystemOS {
|
||||
),
|
||||
process_manager: ProcessManager::new(),
|
||||
task_manager: TaskManager::new(),
|
||||
foreground_stack: ForegroundStack::new(),
|
||||
window_manager: WindowManager::new(),
|
||||
log_service,
|
||||
fs: VirtualFS::new(),
|
||||
@ -135,6 +138,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::os::{LifecycleError, LifecycleOperation};
|
||||
use crate::process::ProcessState;
|
||||
use crate::services::foreground::{ForegroundOwner, ResidentGame, ResidentGameState};
|
||||
use crate::task::{TaskId, TaskState};
|
||||
|
||||
fn process_state_for_task(os: &SystemOS, task_id: TaskId) -> ProcessState {
|
||||
@ -157,6 +161,102 @@ mod tests {
|
||||
assert_eq!(process_state_for_task(&os, task_id), ProcessState::Running);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn foreground_stack_starts_at_hub() {
|
||||
let os = SystemOS::new(None);
|
||||
|
||||
assert_eq!(os.foreground_stack.owner(), ForegroundOwner::Hub);
|
||||
assert_eq!(os.foreground_stack.resident_game(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn game_session_registers_single_resident_game() {
|
||||
let mut os = SystemOS::new(None);
|
||||
let task_id = os.sessions().create_vm_game_task(42, "Sector Crawl");
|
||||
|
||||
assert_eq!(os.lifecycle().foreground_owner(), ForegroundOwner::Game(task_id));
|
||||
assert_eq!(
|
||||
os.lifecycle().resident_game(),
|
||||
Some(ResidentGame { task_id, state: ResidentGameState::Foreground })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn second_resident_game_is_rejected() {
|
||||
let mut os = SystemOS::new(None);
|
||||
let first = os.sessions().create_vm_game_task(42, "Sector Crawl");
|
||||
let process_id = os.process_manager.spawn_vm_game(43, "Second");
|
||||
let second = os.task_manager.create_game_task(process_id, 43, "Second");
|
||||
|
||||
assert_eq!(
|
||||
os.lifecycle().set_game_foreground_task(second),
|
||||
Err(LifecycleError::ResidentGameAlreadyExists { existing: first, requested: second })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn home_request_moves_game_to_resident_suspended_and_hub_foreground() {
|
||||
let mut os = SystemOS::new(None);
|
||||
let task_id = os.sessions().create_vm_game_task(42, "Sector Crawl");
|
||||
|
||||
os.lifecycle().request_home_from_game(task_id).expect("home request should succeed");
|
||||
|
||||
assert_eq!(os.lifecycle().foreground_owner(), ForegroundOwner::Hub);
|
||||
assert_eq!(
|
||||
os.lifecycle().resident_game(),
|
||||
Some(ResidentGame { task_id, state: ResidentGameState::PausedSuspended })
|
||||
);
|
||||
assert_eq!(
|
||||
os.task_manager.get(task_id).expect("task should exist").state,
|
||||
TaskState::Suspended
|
||||
);
|
||||
assert_eq!(process_state_for_task(&os, task_id), ProcessState::Suspended);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shell_foreground_keeps_game_resident_and_marks_it_suspended() {
|
||||
let mut os = SystemOS::new(None);
|
||||
let game = os.sessions().create_vm_game_task(42, "Sector Crawl");
|
||||
os.lifecycle().request_home_from_game(game).expect("home request should succeed");
|
||||
let shell = os.sessions().create_vm_shell_task(7, "Settings");
|
||||
|
||||
assert_eq!(os.lifecycle().foreground_owner(), ForegroundOwner::Shell(shell));
|
||||
assert_eq!(
|
||||
os.lifecycle().resident_game(),
|
||||
Some(ResidentGame { task_id: game, state: ResidentGameState::PausedSuspended })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn second_foreground_shell_is_rejected() {
|
||||
let mut os = SystemOS::new(None);
|
||||
let first = os.sessions().create_vm_shell_task(7, "Settings");
|
||||
let process_id = os.process_manager.spawn_vm_shell(8, "Files");
|
||||
let second = os.task_manager.create_shell_task(process_id, 8, "Files");
|
||||
|
||||
assert_eq!(
|
||||
os.lifecycle().set_shell_foreground_task(second),
|
||||
Err(LifecycleError::ForegroundShellAlreadyExists {
|
||||
existing: first,
|
||||
requested: second,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn closing_foreground_shell_returns_to_hub() {
|
||||
let mut os = SystemOS::new(None);
|
||||
let shell = os.sessions().create_vm_shell_task(7, "Settings");
|
||||
|
||||
os.lifecycle().close_task(shell).expect("close should succeed");
|
||||
|
||||
assert_eq!(os.lifecycle().foreground_owner(), ForegroundOwner::Hub);
|
||||
assert_eq!(
|
||||
os.task_manager.get(shell).expect("shell should remain").state,
|
||||
TaskState::Closed
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn suspend_task_marks_task_and_process_suspended() {
|
||||
let mut os = SystemOS::new(None);
|
||||
|
||||
189
crates/console/prometeu-system/src/services/foreground.rs
Normal file
189
crates/console/prometeu-system/src/services/foreground.rs
Normal file
@ -0,0 +1,189 @@
|
||||
use crate::task::TaskId;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ForegroundOwner {
|
||||
Hub,
|
||||
Game(TaskId),
|
||||
Shell(TaskId),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ResidentGameState {
|
||||
Foreground,
|
||||
PausedSuspended,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ResidentGame {
|
||||
pub task_id: TaskId,
|
||||
pub state: ResidentGameState,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ForegroundStackError {
|
||||
ResidentGameAlreadyExists { existing: TaskId, requested: TaskId },
|
||||
ForegroundShellAlreadyExists { existing: TaskId, requested: TaskId },
|
||||
TaskIsNotResidentGame(TaskId),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ForegroundStack {
|
||||
owner: ForegroundOwner,
|
||||
resident_game: Option<ResidentGame>,
|
||||
}
|
||||
|
||||
impl Default for ForegroundStack {
|
||||
fn default() -> Self {
|
||||
Self { owner: ForegroundOwner::Hub, resident_game: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl ForegroundStack {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn owner(&self) -> ForegroundOwner {
|
||||
self.owner
|
||||
}
|
||||
|
||||
pub fn resident_game(&self) -> Option<ResidentGame> {
|
||||
self.resident_game
|
||||
}
|
||||
|
||||
pub fn resident_game_task(&self) -> Option<TaskId> {
|
||||
self.resident_game.map(|game| game.task_id)
|
||||
}
|
||||
|
||||
pub fn set_game_foreground(&mut self, task_id: TaskId) -> Result<(), ForegroundStackError> {
|
||||
if let Some(game) = self.resident_game
|
||||
&& game.task_id != task_id
|
||||
{
|
||||
return Err(ForegroundStackError::ResidentGameAlreadyExists {
|
||||
existing: game.task_id,
|
||||
requested: task_id,
|
||||
});
|
||||
}
|
||||
|
||||
self.resident_game = Some(ResidentGame { task_id, state: ResidentGameState::Foreground });
|
||||
self.owner = ForegroundOwner::Game(task_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn request_home_from_game(&mut self, task_id: TaskId) -> Result<(), ForegroundStackError> {
|
||||
match self.resident_game {
|
||||
Some(game) if game.task_id == task_id => {
|
||||
self.resident_game =
|
||||
Some(ResidentGame { task_id, state: ResidentGameState::PausedSuspended });
|
||||
self.owner = ForegroundOwner::Hub;
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(ForegroundStackError::TaskIsNotResidentGame(task_id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_shell_foreground(&mut self, task_id: TaskId) -> Result<(), ForegroundStackError> {
|
||||
if let ForegroundOwner::Shell(existing) = self.owner
|
||||
&& existing != task_id
|
||||
{
|
||||
return Err(ForegroundStackError::ForegroundShellAlreadyExists {
|
||||
existing,
|
||||
requested: task_id,
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(game) = self.resident_game {
|
||||
self.resident_game = Some(ResidentGame {
|
||||
task_id: game.task_id,
|
||||
state: ResidentGameState::PausedSuspended,
|
||||
});
|
||||
}
|
||||
self.owner = ForegroundOwner::Shell(task_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn return_to_hub(&mut self) {
|
||||
self.owner = ForegroundOwner::Hub;
|
||||
}
|
||||
|
||||
pub fn clear_resident_game(&mut self, task_id: TaskId) {
|
||||
if self.resident_game_task() == Some(task_id) {
|
||||
self.resident_game = None;
|
||||
}
|
||||
|
||||
if self.owner == ForegroundOwner::Game(task_id) {
|
||||
self.owner = ForegroundOwner::Hub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn foreground_stack_starts_at_hub() {
|
||||
let stack = ForegroundStack::new();
|
||||
|
||||
assert_eq!(stack.owner(), ForegroundOwner::Hub);
|
||||
assert_eq!(stack.resident_game(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn setting_game_foreground_registers_resident_game() {
|
||||
let mut stack = ForegroundStack::new();
|
||||
let game = TaskId(7);
|
||||
|
||||
stack.set_game_foreground(game).expect("game should become foreground");
|
||||
|
||||
assert_eq!(stack.owner(), ForegroundOwner::Game(game));
|
||||
assert_eq!(
|
||||
stack.resident_game(),
|
||||
Some(ResidentGame { task_id: game, state: ResidentGameState::Foreground })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn second_resident_game_is_rejected() {
|
||||
let mut stack = ForegroundStack::new();
|
||||
|
||||
stack.set_game_foreground(TaskId(1)).expect("first game should be accepted");
|
||||
|
||||
assert_eq!(
|
||||
stack.set_game_foreground(TaskId(2)),
|
||||
Err(ForegroundStackError::ResidentGameAlreadyExists {
|
||||
existing: TaskId(1),
|
||||
requested: TaskId(2),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn home_request_moves_resident_game_to_paused_suspended() {
|
||||
let mut stack = ForegroundStack::new();
|
||||
let game = TaskId(3);
|
||||
|
||||
stack.set_game_foreground(game).expect("game should be foreground");
|
||||
stack.request_home_from_game(game).expect("home request should suspend game");
|
||||
|
||||
assert_eq!(stack.owner(), ForegroundOwner::Hub);
|
||||
assert_eq!(
|
||||
stack.resident_game(),
|
||||
Some(ResidentGame { task_id: game, state: ResidentGameState::PausedSuspended })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shell_foreground_keeps_resident_game() {
|
||||
let mut stack = ForegroundStack::new();
|
||||
let game = TaskId(3);
|
||||
let shell = TaskId(4);
|
||||
|
||||
stack.set_game_foreground(game).expect("game should be foreground");
|
||||
stack.request_home_from_game(game).expect("home request should suspend game");
|
||||
stack.set_shell_foreground(shell).expect("shell should become foreground");
|
||||
|
||||
assert_eq!(stack.owner(), ForegroundOwner::Shell(shell));
|
||||
assert_eq!(stack.resident_game_task(), Some(game));
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
pub mod async_work;
|
||||
pub mod foreground;
|
||||
pub mod fs;
|
||||
pub mod game_library;
|
||||
pub mod memcard;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
{"type":"discussion","id":"DSC-0043","status":"open","ticket":"system-os-cartridge-switch-orchestrator","title":"SystemOS Cartridge Switch Orchestrator","created_at":"2026-07-03","updated_at":"2026-07-03","tags":["runtime","os","lifecycle","game","cartridge","architecture"],"agendas":[{"id":"AGD-0044","file":"AGD-0044-systemos-cartridge-switch-orchestrator.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03"}],"decisions":[],"plans":[],"lessons":[]}
|
||||
{"type":"discussion","id":"DSC-0039","status":"abandoned","ticket":"render-pipeline-family-and-future-3d","title":"Render Pipeline Family and Future 3D","created_at":"2026-06-04","updated_at":"2026-06-04","tags":["gfx","renderer","runtime","architecture","pipeline"],"agendas":[{"id":"AGD-0039","file":"AGD-0039-render-pipeline-family-and-future-3d.md","status":"abandoned","created_at":"2026-06-04","updated_at":"2026-06-04","_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}],"decisions":[],"plans":[],"lessons":[],"_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}
|
||||
{"type":"discussion","id":"DSC-0040","status":"done","ticket":"vm-render-parallel-execution-boundary","title":"VM and Render Parallel Execution Boundary","created_at":"2026-06-04","updated_at":"2026-06-06","tags":["runtime","renderer","vm","concurrency","architecture","perf"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0048","file":"discussion/lessons/DSC-0040-vm-render-parallel-execution-boundary/LSN-0048-render-workers-need-a-closed-packet-contract.md","status":"done","created_at":"2026-06-06","updated_at":"2026-06-06"}]}
|
||||
{"type":"discussion","id":"DSC-0041","status":"in_progress","ticket":"foreground-stack-game-pause-shell-vm-backed","title":"Foreground Stack, Game Pause, and VM-Backed Shell Coexistence","created_at":"2026-06-05","updated_at":"2026-07-03","tags":["runtime","os","lifecycle","shell","game","vm","foreground","architecture"],"agendas":[{"id":"AGD-0041","file":"AGD-0041-foreground-stack-game-pause-shell-vm-backed.md","status":"accepted","created_at":"2026-06-05","updated_at":"2026-07-03"}],"decisions":[{"id":"DEC-0037","file":"DEC-0037-foreground-stack-and-game-pause-contract.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03","ref_agenda":"AGD-0041"}],"plans":[{"id":"PLN-0136","file":"PLN-0136-route-desktop-home-key-outside-guest-input.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0137","file":"PLN-0137-implement-systemos-foreground-stack-state.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0138","file":"PLN-0138-specify-foreground-pause-and-home-contract.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0139","file":"PLN-0139-validate-game-home-shell-game-end-to-end.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0140","file":"PLN-0140-deliver-game-pause-resume-and-suspension.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0141","file":"PLN-0141-integrate-render-audio-and-input-pause-boundaries.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]}],"lessons":[]}
|
||||
{"type":"discussion","id":"DSC-0041","status":"in_progress","ticket":"foreground-stack-game-pause-shell-vm-backed","title":"Foreground Stack, Game Pause, and VM-Backed Shell Coexistence","created_at":"2026-06-05","updated_at":"2026-07-03","tags":["runtime","os","lifecycle","shell","game","vm","foreground","architecture"],"agendas":[{"id":"AGD-0041","file":"AGD-0041-foreground-stack-game-pause-shell-vm-backed.md","status":"accepted","created_at":"2026-06-05","updated_at":"2026-07-03"}],"decisions":[{"id":"DEC-0037","file":"DEC-0037-foreground-stack-and-game-pause-contract.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03","ref_agenda":"AGD-0041"}],"plans":[{"id":"PLN-0136","file":"PLN-0136-route-desktop-home-key-outside-guest-input.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0137","file":"PLN-0137-implement-systemos-foreground-stack-state.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0138","file":"PLN-0138-specify-foreground-pause-and-home-contract.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0139","file":"PLN-0139-validate-game-home-shell-game-end-to-end.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0140","file":"PLN-0140-deliver-game-pause-resume-and-suspension.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]},{"id":"PLN-0141","file":"PLN-0141-integrate-render-audio-and-input-pause-boundaries.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0037"]}],"lessons":[]}
|
||||
{"type":"discussion","id":"DSC-0042","status":"done","ticket":"real-render-worker-establishment","title":"Real Render Worker Establishment","created_at":"2026-06-06","updated_at":"2026-06-20","tags":["runtime","renderer","worker","concurrency","host","hal","architecture"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0049","file":"discussion/lessons/DSC-0042-real-render-worker-establishment/LSN-0049-render-worker-publication-boundary.md","status":"done","created_at":"2026-06-20","updated_at":"2026-06-20"}]}
|
||||
{"type":"discussion","id":"DSC-0038","status":"done","ticket":"render-frame-packet-boundary","title":"Logical Render Pipelines and Command Packets","created_at":"2026-05-25","updated_at":"2026-06-04","tags":["gfx","renderer","runtime","frame-composer","architecture","ui","pipeline"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0047","file":"discussion/lessons/DSC-0038-render-frame-packet-boundary/LSN-0047-typed-render-submissions-preserve-domain-boundaries.md","status":"done","created_at":"2026-06-04","updated_at":"2026-06-04"}]}
|
||||
{"type":"discussion","id":"DSC-0035","status":"done","ticket":"task-owned-shell-windows","title":"Agenda - Task-Owned Shell Windows","created_at":"2026-05-15","updated_at":"2026-05-15","tags":["runtime","os","task","window-manager","shell","lifecycle"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0044","file":"discussion/lessons/DSC-0035-task-owned-shell-windows/LSN-0044-task-window-liveness-belongs-to-the-task.md","status":"done","created_at":"2026-05-15","updated_at":"2026-05-15"}]}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
id: PLN-0137
|
||||
ticket: foreground-stack-game-pause-shell-vm-backed
|
||||
title: Implement SystemOS Foreground Stack State
|
||||
status: open
|
||||
status: done
|
||||
created: 2026-07-03
|
||||
ref_decisions: [DEC-0037]
|
||||
tags: [runtime, os, lifecycle, foreground, shell, game]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user