feat(window): support des fenêtres plugin-hébergées (backend)

Étend le port/usecases window et layout.customPluginLayout pour ouvrir et
piloter des fenêtres OS hébergeant un layout plugin, en réutilisant
contributes.layouts plutôt qu'un système de fenêtres parallèle. Câble la
commande Tauri et l'état app-tauri correspondants.

Cargo test -p domain --test window : 5/5
Cargo test -p application --test window_usecases : 7/7
Cargo test -p infrastructure --test window_state_store : 1/1
Cargo test -p app-tauri view_window_tests : 8/8

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 00:39:42 +02:00
parent 3ea1d58b38
commit 551eb09ad2
14 changed files with 884 additions and 95 deletions

View File

@ -14,8 +14,9 @@ use domain::ports::{
use domain::{
AgentId, BackgroundTask, BackgroundTaskState, BackgroundTaskWakePolicy, ContentHash,
DomainEvent, PluginContributionSet, PluginDescriptor, PluginId, PluginInstallSource,
PluginLifecycleState, PluginManifest, PluginMcpServerSpec, PluginRegistryEntry,
PluginTrustLevel, Project, ProjectId, ProjectPath, RemovalOutcome, StagedPluginPackage, TaskId,
PluginLayoutType, PluginLifecycleState, PluginManifest, PluginMcpServerSpec,
PluginRegistryEntry, PluginTrustLevel, Project, ProjectId, ProjectPath, RemovalOutcome,
StagedPluginPackage, TaskId,
};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
@ -159,6 +160,20 @@ pub struct PluginRuntimePlugin {
pub contributes: PluginContributionSet,
}
/// Runtime-validated plugin layout contribution.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PluginRuntimeLayoutContribution {
/// Plugin id.
pub plugin_id: String,
/// Provider display name.
pub provider_plugin_display_name: String,
/// Layout type.
pub layout_type: String,
/// Layout display label.
pub label: String,
}
/// Input for plugin-owned storage reads/deletes.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
@ -2801,6 +2816,49 @@ pub(crate) async fn runtime_plugin_from_entry(
})
}
/// Validates that a plugin layout contribution exists and is active at runtime.
///
/// This is the canonical application-layer rule for every surface that wants to
/// host a plugin layout, whether inside a named project layout or a detached OS
/// window.
pub async fn ensure_runtime_plugin_layout_contribution(
packages: &dyn PluginPackageStore,
registry: &dyn PluginRegistryStore,
validator: &dyn PluginManifestValidator,
plugin_id: &PluginId,
layout_type: &PluginLayoutType,
) -> Result<PluginRuntimeLayoutContribution, AppError> {
let registry = registry.load_registry().await.map_err(map_registry)?;
for entry in registry.plugins {
if entry.id != *plugin_id || !entry.lifecycle_state.is_runtime_active() {
continue;
}
let runtime = runtime_plugin_from_entry(packages, validator, entry).await?;
if let Some(layout) = runtime
.contributes
.layouts
.iter()
.find(|layout| layout.layout_type == *layout_type)
{
return Ok(PluginRuntimeLayoutContribution {
plugin_id: runtime.id,
provider_plugin_display_name: runtime.display_name,
layout_type: layout.layout_type.as_str().to_owned(),
label: layout.label.clone(),
});
}
return Err(AppError::Invalid(format!(
"plugin `{}` does not contribute layout `{}`",
plugin_id.as_str(),
layout_type.as_str()
)));
}
Err(AppError::Invalid(format!(
"plugin `{}` is not active at runtime",
plugin_id.as_str()
)))
}
fn checked_plugin_asset_url(
packages: &dyn PluginPackageStore,
plugin_id: &PluginId,