Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Fix portable project persistence

Bittid53663d24864
diff --git a/fixtures/project-v1-complete.json b/fixtures/project-v1-complete.json
new file mode 100644
index 0000000..0703c42
--- /dev/null
+++ b/fixtures/project-v1-complete.json
@@ -0,0 +1,126 @@
+{
+ "schemaVersion": 1,
+ "id": "project-complete",
+ "name": "Portable Launch Film",
+ "createdAt": "2026-01-01T00:00:00.000Z",
+ "updatedAt": "2026-01-02T03:04:05.000Z",
+ "thumbnail": "thumbnails/launch.webp",
+ "settings": {
+ "aspectRatio": "16:9",
+ "resolution": "4k",
+ "frameRate": 30,
+ "backgroundColor": "#10131a"
+ },
+ "brief": {
+ "prompt": "A tactile product launch",
+ "status": "ready",
+ "targetDurationSeconds": 60,
+ "aspectRatio": "16:9",
+ "resolution": "4k"
+ },
+ "assets": [
+ {
+ "id": "asset-imported",
+ "kind": "video",
+ "name": "Macro footage",
+ "relativePath": "media/imported/macro.mp4",
+ "mimeType": "video/mp4",
+ "durationMs": 12000,
+ "width": 3840,
+ "height": 2160,
+ "createdAt": "2026-01-01T00:10:00.000Z"
+ },
+ {
+ "id": "asset-generated",
+ "kind": "generated",
+ "name": "Generated opener",
+ "relativePath": "media/generated/opener.mp4",
+ "mimeType": "video/mp4",
+ "durationMs": 8000,
+ "width": 3840,
+ "height": 2160,
+ "createdAt": "2026-01-01T00:20:00.000Z"
+ }
+ ],
+ "timeline": {
+ "tracks": [
+ {
+ "id": "track-video",
+ "kind": "video",
+ "name": "Video 1",
+ "locked": false,
+ "muted": false,
+ "clips": [
+ {
+ "id": "clip-opener",
+ "assetId": "asset-generated",
+ "trackId": "track-video",
+ "startMs": 0,
+ "durationMs": 8000,
+ "sourceStartMs": 0,
+ "label": "Opening shot"
+ }
+ ]
+ }
+ ]
+ },
+ "references": [
+ {
+ "id": "reference-tone",
+ "kind": "text",
+ "name": "Tone",
+ "content": "Precise, tactile, quietly optimistic.",
+ "relativePath": null,
+ "createdAt": "2026-01-01T00:05:00.000Z"
+ },
+ {
+ "id": "reference-product",
+ "kind": "image",
+ "name": "Product hero",
+ "content": null,
+ "relativePath": "references/product-hero.png",
+ "createdAt": "2026-01-01T00:06:00.000Z"
+ }
+ ],
+ "generationJobs": [
+ {
+ "id": "job-opener",
+ "status": "ready",
+ "providerId": "minimax-h3",
+ "creativeBrief": "Reveal the product through a slow macro push.",
+ "compiledPrompt": "integrated_multimodal_description: [Shot 1] Slow macro push toward the product.",
+ "referenceIds": ["reference-product", "reference-tone"],
+ "outputRelativePath": "media/generated/opener.mp4",
+ "error": null,
+ "createdAt": "2026-01-01T00:15:00.000Z",
+ "updatedAt": "2026-01-01T00:20:00.000Z"
+ }
+ ],
+ "agentConversation": {
+ "messages": [
+ {
+ "id": "message-user",
+ "role": "user",
+ "content": "Make the opening feel more tactile.",
+ "createdAt": "2026-01-01T00:11:00.000Z"
+ },
+ {
+ "id": "message-assistant",
+ "role": "assistant",
+ "content": "I will use a slower macro push and restrained highlights.",
+ "createdAt": "2026-01-01T00:12:00.000Z"
+ }
+ ]
+ },
+ "providerSettings": {
+ "minimax-h3": {
+ "enabled": true,
+ "model": "MiniMax-H3",
+ "options": {
+ "quality": "high",
+ "seed": 42,
+ "includeAudio": true
+ }
+ }
+ }
+}
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index b623d09..1d3f2ed 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -2286,6 +2286,7 @@ dependencies = [
"tauri-build",
"tauri-plugin-dialog",
"tempfile",
+ "windows-sys 0.59.0",
]
[[package]]
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index ae2cf1f..284ca25 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -18,6 +18,9 @@ serde_json = "1"
tauri = { version = "2", features = [] }
tauri-plugin-dialog = "2"
+[target.'cfg(windows)'.dependencies]
+windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Storage_FileSystem"] }
+
[dev-dependencies]
tempfile = "3"
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 50b2210..9eb8539 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -1,14 +1,25 @@
use serde::{Deserialize, Serialize};
use std::{
- fs,
+ collections::BTreeMap,
+ fs, io,
path::{Path, PathBuf},
+ sync::atomic::{AtomicU64, Ordering},
};
use tauri::AppHandle;
use tauri_plugin_dialog::DialogExt;
const PROJECT_FILE_NAME: &str = "polstudio.project.json";
+const PROJECT_DIRECTORIES: [&str; 6] = [
+ "media/imported",
+ "media/generated",
+ "references",
+ "thumbnails",
+ "cache",
+ "exports",
+];
+static TEMP_FILE_COUNTER: AtomicU64 = AtomicU64::new(0);
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct ProjectConfig {
schema_version: u32,
@@ -21,9 +32,17 @@ struct ProjectConfig {
brief: GenerationBrief,
assets: Vec<ProjectAsset>,
timeline: Timeline,
+ #[serde(default)]
+ references: Vec<ReusableReference>,
+ #[serde(default)]
+ generation_jobs: Vec<GenerationJob>,
+ #[serde(default)]
+ agent_conversation: AgentConversation,
+ #[serde(default)]
+ provider_settings: BTreeMap<String, ProviderSetting>,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct ProjectSettings {
aspect_ratio: String,
@@ -32,7 +51,7 @@ struct ProjectSettings {
background_color: String,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct GenerationBrief {
prompt: String,
@@ -42,7 +61,7 @@ struct GenerationBrief {
resolution: String,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct ProjectAsset {
id: String,
@@ -56,12 +75,12 @@ struct ProjectAsset {
created_at: String,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
struct Timeline {
tracks: Vec<TimelineTrack>,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
struct TimelineTrack {
id: String,
kind: String,
@@ -71,7 +90,7 @@ struct TimelineTrack {
clips: Vec<TimelineClip>,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct TimelineClip {
id: String,
@@ -83,6 +102,64 @@ struct TimelineClip {
label: String,
}
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct ReusableReference {
+ id: String,
+ kind: String,
+ name: String,
+ content: Option<String>,
+ relative_path: Option<String>,
+ created_at: String,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct GenerationJob {
+ id: String,
+ status: String,
+ provider_id: Option<String>,
+ creative_brief: String,
+ compiled_prompt: String,
+ #[serde(default)]
+ reference_ids: Vec<String>,
+ output_relative_path: Option<String>,
+ error: Option<String>,
+ created_at: String,
+ updated_at: String,
+}
+
+#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
+struct AgentConversation {
+ #[serde(default)]
+ messages: Vec<AgentMessage>,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct AgentMessage {
+ id: String,
+ role: String,
+ content: String,
+ created_at: String,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+struct ProviderSetting {
+ enabled: bool,
+ model: Option<String>,
+ #[serde(default)]
+ options: BTreeMap<String, ProviderOption>,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(untagged)]
+enum ProviderOption {
+ String(String),
+ Number(f64),
+ Boolean(bool),
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct ProjectRecord {
@@ -90,7 +167,39 @@ struct ProjectRecord {
config: ProjectConfig,
}
-fn validate_config(config: &ProjectConfig) -> Result<(), String> {
+fn normalize_project_path(value: &str) -> Result<String, String> {
+ if value.is_empty() || value.contains('\0') {
+ return Err("Project paths cannot be empty or contain null bytes.".into());
+ }
+ let scheme_or_drive_prefix = value
+ .find(':')
+ .map(|colon| {
+ colon > 0
+ && value.as_bytes()[0].is_ascii_alphabetic()
+ && value.as_bytes()[..colon]
+ .iter()
+ .all(|byte| byte.is_ascii_alphanumeric() || matches!(*byte, b'+' | b'-' | b'.'))
+ })
+ .unwrap_or(false);
+ if value.starts_with('/') || value.starts_with('\\') || scheme_or_drive_prefix {
+ return Err("Project paths must be relative to the project root.".into());
+ }
+ let mut normalized = Vec::new();
+ let portable = value.replace('\\', "/");
+ for component in portable.split('/') {
+ match component {
+ "" | "." => {}
+ ".." => return Err("Project paths cannot traverse outside the project root.".into()),
+ value => normalized.push(value),
+ }
+ }
+ if normalized.is_empty() {
+ return Err("Project paths must point to an item below the project root.".into());
+ }
+ Ok(normalized.join("/"))
+}
+
+fn validate_and_normalize_config(mut config: ProjectConfig) -> Result<ProjectConfig, String> {
if config.schema_version != 1 {
return Err(format!(
"Unsupported project schema version {}. This build supports version 1.",
@@ -103,7 +212,86 @@ fn validate_config(config: &ProjectConfig) -> Result<(), String> {
if config.brief.prompt.trim().is_empty() {
return Err("Project brief cannot be empty.".into());
}
- Ok(())
+ config.thumbnail = config
+ .thumbnail
+ .as_deref()
+ .map(normalize_project_path)
+ .transpose()?;
+ for asset in &mut config.assets {
+ if asset.id.trim().is_empty() || asset.name.trim().is_empty() {
+ return Err("Asset id and name cannot be empty.".into());
+ }
+ asset.relative_path = normalize_project_path(&asset.relative_path)?;
+ }
+ for reference in &mut config.references {
+ if reference.id.trim().is_empty() || reference.name.trim().is_empty() {
+ return Err("Reference id and name cannot be empty.".into());
+ }
+ reference.relative_path = reference
+ .relative_path
+ .as_deref()
+ .map(normalize_project_path)
+ .transpose()?;
+ match reference.kind.as_str() {
+ "text"
+ if reference
+ .content
+ .as_deref()
+ .is_some_and(|value| !value.is_empty()) => {}
+ "image" if reference.relative_path.is_some() => {}
+ "text" => return Err("Text references require content.".into()),
+ "image" => return Err("Image references require a relative path.".into()),
+ _ => return Err(format!("Unsupported reference kind '{}'.", reference.kind)),
+ }
+ }
+ for job in &mut config.generation_jobs {
+ if job.id.trim().is_empty()
+ || job.creative_brief.trim().is_empty()
+ || job.compiled_prompt.trim().is_empty()
+ {
+ return Err(
+ "Generation job id, creative brief, and compiled prompt cannot be empty.".into(),
+ );
+ }
+ if !matches!(
+ job.status.as_str(),
+ "draft" | "queued" | "generating" | "ready" | "failed" | "cancelled"
+ ) {
+ return Err(format!(
+ "Unsupported generation job status '{}'.",
+ job.status
+ ));
+ }
+ job.output_relative_path = job
+ .output_relative_path
+ .as_deref()
+ .map(normalize_project_path)
+ .transpose()?;
+ }
+ for message in &config.agent_conversation.messages {
+ if message.id.trim().is_empty() || message.content.trim().is_empty() {
+ return Err("Agent message id and content cannot be empty.".into());
+ }
+ if !matches!(message.role.as_str(), "user" | "assistant" | "system") {
+ return Err(format!(
+ "Unsupported agent message role '{}'.",
+ message.role
+ ));
+ }
+ }
+ for (provider_id, setting) in &config.provider_settings {
+ if provider_id.trim().is_empty() {
+ return Err("Provider setting ids cannot be empty.".into());
+ }
+ if setting
+ .model
+ .as_deref()
+ .is_some_and(|model| model.trim().is_empty())
+ {
+ return Err("Provider setting models cannot be empty.".into());
+ }
+ }
+ Ok(config)
}
fn read_project(folder: &Path) -> Result<ProjectRecord, String> {
@@ -114,15 +302,11 @@ fn read_project(folder: &Path) -> Result<ProjectRecord, String> {
.canonicalize()
.map_err(|error| format!("Could not resolve project folder: {error}"))?;
let config_path = canonical_folder.join(PROJECT_FILE_NAME);
- let json = fs::read_to_string(&config_path).map_err(|error| {
- format!(
- "Could not read {}: {error}",
- config_path.to_string_lossy()
- )
- })?;
+ let json = fs::read_to_string(&config_path)
+ .map_err(|error| format!("Could not read {}: {error}", config_path.to_string_lossy()))?;
let config: ProjectConfig = serde_json::from_str(&json)
.map_err(|error| format!("Project config is not valid: {error}"))?;
- validate_config(&config)?;
+ let config = validate_and_normalize_config(config)?;
Ok(ProjectRecord {
folder_path: canonical_folder.to_string_lossy().into_owned(),
config,
@@ -130,25 +314,98 @@ fn read_project(folder: &Path) -> Result<ProjectRecord, String> {
}
fn write_project(folder: &Path, config: &ProjectConfig) -> Result<(), String> {
- validate_config(config)?;
+ write_project_with_replacer(folder, config, atomic_replace)
+}
+
+fn write_project_with_replacer<F>(
+ folder: &Path,
+ config: &ProjectConfig,
+ replacer: F,
+) -> Result<(), String>
+where
+ F: FnOnce(&Path, &Path) -> io::Result<()>,
+{
+ let config = validate_and_normalize_config(config.clone())?;
if !folder.is_dir() {
return Err("Project folder does not exist.".into());
}
- let json = serde_json::to_string_pretty(config)
+ let json = serde_json::to_string_pretty(&config)
.map_err(|error| format!("Could not serialize project: {error}"))?;
let destination = folder.join(PROJECT_FILE_NAME);
- let temporary = folder.join(format!("{PROJECT_FILE_NAME}.tmp"));
- fs::write(&temporary, format!("{json}\n"))
- .map_err(|error| format!("Could not write project config: {error}"))?;
- if destination.exists() {
- fs::remove_file(&destination)
- .map_err(|error| format!("Could not replace existing project config: {error}"))?;
+ let sequence = TEMP_FILE_COUNTER.fetch_add(1, Ordering::Relaxed);
+ let temporary = folder.join(format!(
+ ".{PROJECT_FILE_NAME}.{}.{}.tmp",
+ std::process::id(),
+ sequence
+ ));
+ let write_result = (|| -> io::Result<()> {
+ use io::Write;
+ let mut file = fs::OpenOptions::new()
+ .write(true)
+ .create_new(true)
+ .open(&temporary)?;
+ file.write_all(format!("{json}\n").as_bytes())?;
+ file.sync_all()
+ })();
+ if let Err(error) = write_result {
+ let _ = fs::remove_file(&temporary);
+ return Err(format!("Could not write project config: {error}"));
+ }
+ if let Err(error) = replacer(&temporary, &destination) {
+ let _ = fs::remove_file(&temporary);
+ return Err(format!("Could not finalize project config: {error}"));
}
- fs::rename(&temporary, &destination)
- .map_err(|error| format!("Could not finalize project config: {error}"))?;
Ok(())
}
+#[cfg(not(windows))]
+fn atomic_replace(temporary: &Path, destination: &Path) -> io::Result<()> {
+ fs::rename(temporary, destination)?;
+ fs::File::open(destination.parent().expect("project file has a parent"))?.sync_all()
+}
+
+#[cfg(windows)]
+fn atomic_replace(temporary: &Path, destination: &Path) -> io::Result<()> {
+ use std::os::windows::ffi::OsStrExt;
+ use windows_sys::Win32::{
+ Foundation::GetLastError,
+ Storage::FileSystem::{
+ MoveFileExW, ReplaceFileW, MOVEFILE_WRITE_THROUGH, REPLACEFILE_WRITE_THROUGH,
+ },
+ };
+
+ let temporary_wide: Vec<u16> = temporary.as_os_str().encode_wide().chain(Some(0)).collect();
+ let destination_wide: Vec<u16> = destination
+ .as_os_str()
+ .encode_wide()
+ .chain(Some(0))
+ .collect();
+ let succeeded = unsafe {
+ if destination.exists() {
+ ReplaceFileW(
+ destination_wide.as_ptr(),
+ temporary_wide.as_ptr(),
+ std::ptr::null(),
+ REPLACEFILE_WRITE_THROUGH,
+ std::ptr::null_mut(),
+ std::ptr::null_mut(),
+ )
+ } else {
+ MoveFileExW(
+ temporary_wide.as_ptr(),
+ destination_wide.as_ptr(),
+ MOVEFILE_WRITE_THROUGH,
+ )
+ }
+ };
+ if succeeded == 0 {
+ let code = unsafe { GetLastError() };
+ Err(io::Error::from_raw_os_error(code as i32))
+ } else {
+ Ok(())
+ }
+}
+
fn safe_folder_name(name: &str) -> String {
let mut value: String = name
.chars()
@@ -193,7 +450,7 @@ fn create_project(
parent_directory: Option<String>,
config: ProjectConfig,
) -> Result<Option<ProjectRecord>, String> {
- validate_config(&config)?;
+ let config = validate_and_normalize_config(config)?;
let parent = match parent_directory {
Some(path) => PathBuf::from(path),
None => match app
@@ -208,6 +465,11 @@ fn create_project(
None => return Ok(None),
},
};
+ create_project_in(&parent, &config).map(Some)
+}
+
+fn create_project_in(parent: &Path, config: &ProjectConfig) -> Result<ProjectRecord, String> {
+ let config = validate_and_normalize_config(config.clone())?;
if !parent.is_dir() {
return Err("The selected parent folder does not exist.".into());
}
@@ -220,22 +482,19 @@ fn create_project(
}
fs::create_dir(&project_folder)
.map_err(|error| format!("Could not create project folder: {error}"))?;
- for child in ["assets", "generated", "exports", "cache"] {
- fs::create_dir(project_folder.join(child))
+ for child in PROJECT_DIRECTORIES {
+ fs::create_dir_all(project_folder.join(child))
.map_err(|error| format!("Could not create {child} folder: {error}"))?;
}
if let Err(error) = write_project(&project_folder, &config) {
let _ = fs::remove_dir_all(&project_folder);
return Err(error);
}
- read_project(&project_folder).map(Some)
+ read_project(&project_folder)
}
#[tauri::command]
-fn save_project(
- folder_path: String,
- config: ProjectConfig,
-) -> Result<(), String> {
+fn save_project(folder_path: String, config: ProjectConfig) -> Result<(), String> {
let folder = PathBuf::from(folder_path)
.canonicalize()
.map_err(|error| format!("Could not resolve project folder: {error}"))?;
@@ -261,27 +520,149 @@ mod tests {
use super::*;
fn fixture() -> ProjectConfig {
- serde_json::from_value(serde_json::json!({
- "schemaVersion": 1,
- "id": "project-1",
- "name": "Launch Film",
- "createdAt": "2026-01-01T00:00:00.000Z",
- "updatedAt": "2026-01-01T00:00:00.000Z",
- "thumbnail": null,
- "settings": { "aspectRatio": "16:9", "resolution": "4k", "frameRate": 30, "backgroundColor": "#10131a" },
- "brief": { "prompt": "A product launch", "status": "draft", "targetDurationSeconds": 60, "aspectRatio": "16:9", "resolution": "4k" },
- "assets": [],
- "timeline": { "tracks": [] }
- })).unwrap()
+ serde_json::from_str(include_str!("../../fixtures/project-v1-complete.json")).unwrap()
}
#[test]
- fn project_round_trip_uses_stable_file_name() {
+ fn complete_project_create_open_save_reopen_is_lossless() {
let root = tempfile::tempdir().unwrap();
- write_project(root.path(), &fixture()).unwrap();
- let record = read_project(root.path()).unwrap();
- assert_eq!(record.config.name, "Launch Film");
- assert!(root.path().join(PROJECT_FILE_NAME).is_file());
+ let expected = validate_and_normalize_config(fixture()).unwrap();
+ let created = create_project_in(root.path(), &expected).unwrap();
+ assert_eq!(created.config, expected);
+
+ let project_folder = PathBuf::from(&created.folder_path);
+ let opened = read_project(&project_folder).unwrap();
+ assert_eq!(opened.config, expected);
+
+ let mut saved = opened.config.clone();
+ saved.updated_at = "2026-02-03T04:05:06.000Z".into();
+ saved.agent_conversation.messages.push(AgentMessage {
+ id: "message-save".into(),
+ role: "user".into(),
+ content: "Save this portable project.".into(),
+ created_at: "2026-02-03T04:05:06.000Z".into(),
+ });
+ write_project(&project_folder, &saved).unwrap();
+ assert_eq!(read_project(&project_folder).unwrap().config, saved);
+
+ let mut directories = Vec::new();
+ fn collect_directories(root: &Path, current: &Path, output: &mut Vec<String>) {
+ for entry in fs::read_dir(current).unwrap() {
+ let path = entry.unwrap().path();
+ if path.is_dir() {
+ output.push(
+ path.strip_prefix(root)
+ .unwrap()
+ .to_string_lossy()
+ .replace('\\', "/"),
+ );
+ collect_directories(root, &path, output);
+ }
+ }
+ }
+ collect_directories(&project_folder, &project_folder, &mut directories);
+ directories.sort();
+ assert_eq!(
+ directories,
+ [
+ "cache",
+ "exports",
+ "media",
+ "media/generated",
+ "media/imported",
+ "references",
+ "thumbnails",
+ ]
+ );
+ let files: Vec<_> = fs::read_dir(&project_folder)
+ .unwrap()
+ .filter_map(Result::ok)
+ .filter(|entry| entry.path().is_file())
+ .map(|entry| entry.file_name().to_string_lossy().into_owned())
+ .collect();
+ assert_eq!(files, [PROJECT_FILE_NAME]);
+ }
+
+ #[test]
+ fn old_v1_documents_receive_empty_persistence_containers() {
+ let mut value = serde_json::to_value(fixture()).unwrap();
+ let object = value.as_object_mut().unwrap();
+ object.remove("references");
+ object.remove("generationJobs");
+ object.remove("agentConversation");
+ object.remove("providerSettings");
+ let config: ProjectConfig = serde_json::from_value(value).unwrap();
+ assert!(config.references.is_empty());
+ assert!(config.generation_jobs.is_empty());
+ assert!(config.agent_conversation.messages.is_empty());
+ assert!(config.provider_settings.is_empty());
+ }
+
+ #[test]
+ fn stored_paths_are_normalized_and_escaping_paths_are_rejected() {
+ let mut normalized = fixture();
+ normalized.assets[0].relative_path = ".\\media\\imported//macro.mp4".into();
+ assert_eq!(
+ validate_and_normalize_config(normalized).unwrap().assets[0].relative_path,
+ "media/imported/macro.mp4"
+ );
+
+ for path in [
+ "/etc/passwd",
+ "\\Windows\\system.ini",
+ "C:\\Users\\creator\\clip.mp4",
+ "https://example.com/clip.mp4",
+ "media/../../outside.mp4",
+ "references/../outside.png",
+ ] {
+ let mut escaping = fixture();
+ escaping.assets[0].relative_path = path.into();
+ assert!(
+ validate_and_normalize_config(escaping).is_err(),
+ "accepted escaping path {path}"
+ );
+ }
+
+ let mut thumbnail = fixture();
+ thumbnail.thumbnail = Some("../thumbnail.webp".into());
+ let mut reference = fixture();
+ reference.references[1].relative_path = Some("../product.png".into());
+ let mut job = fixture();
+ job.generation_jobs[0].output_relative_path = Some("C:\\output.mp4".into());
+ for config in [thumbnail, reference, job] {
+ assert!(validate_and_normalize_config(config).is_err());
+ }
+ }
+
+ #[test]
+ fn replacement_failure_preserves_original_project_json() {
+ let root = tempfile::tempdir().unwrap();
+ let original = fixture();
+ write_project(root.path(), &original).unwrap();
+ let destination = root.path().join(PROJECT_FILE_NAME);
+ let original_bytes = fs::read(&destination).unwrap();
+
+ let mut changed = original.clone();
+ changed.name = "This must not replace the original".into();
+ let error = write_project_with_replacer(root.path(), &changed, |_, _| {
+ Err(io::Error::new(
+ io::ErrorKind::PermissionDenied,
+ "simulated replacement failure",
+ ))
+ })
+ .unwrap_err();
+
+ assert!(error.contains("simulated replacement failure"));
+ assert_eq!(fs::read(&destination).unwrap(), original_bytes);
+ assert_eq!(read_project(root.path()).unwrap().config, original);
+ assert_eq!(
+ fs::read_dir(root.path())
+ .unwrap()
+ .filter_map(Result::ok)
+ .filter(|entry| entry.path().is_file())
+ .count(),
+ 1
+ );
}
#[test]
diff --git a/src/App.test.tsx b/src/App.test.tsx
new file mode 100644
index 0000000..441630a
--- /dev/null
+++ b/src/App.test.tsx
@@ -0,0 +1,27 @@
+// @vitest-environment jsdom
+
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
+import App from "./App";
+
+describe("project library controls", () => {
+ beforeEach(() => localStorage.clear());
+ afterEach(cleanup);
+
+ it("focuses search with Ctrl/Cmd+K and switches between grid and list", async () => {
+ const { container } = render(<App />);
+ await screen.findByText("Northern Light — Brand Film");
+
+ const search = screen.getByRole("textbox", { name: "Search projects" });
+ fireEvent.keyDown(window, { key: "k", ctrlKey: true });
+ expect(document.activeElement).toBe(search);
+
+ const list = screen.getByRole("button", { name: "List view" });
+ fireEvent.click(list);
+ expect(list.getAttribute("aria-pressed")).toBe("true");
+ expect(container.querySelector(".project-grid--list")).not.toBeNull();
+
+ fireEvent.click(screen.getByRole("button", { name: "More options for Northern Light — Brand Film" }));
+ await waitFor(() => expect(screen.getByRole("menuitem", { name: "Open project" })).not.toBeNull());
+ });
+});
diff --git a/src/App.tsx b/src/App.tsx
index b3f6744..8a89638 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,5 +1,5 @@
import { BookImage, FolderOpen, Grid2X2, List, Search, Sparkles } from "lucide-react";
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { EmptyPlaceholder } from "./components/EmptyPlaceholder";
import { ProjectCard } from "./components/ProjectCard";
import { ProjectWorkspace } from "./components/ProjectWorkspace";
@@ -15,7 +15,9 @@ function App() {
const [loading, setLoading] = useState(true);
const [busy, setBusy] = useState(false);
const [query, setQuery] = useState("");
+ const [projectLayout, setProjectLayout] = useState<"grid" | "list">("grid");
const [error, setError] = useState<string | null>(null);
+ const searchInput = useRef<HTMLInputElement>(null);
useEffect(() => {
void listRecentProjects()
@@ -24,6 +26,17 @@ function App() {
.finally(() => setLoading(false));
}, []);
+ useEffect(() => {
+ const focusSearch = (event: KeyboardEvent) => {
+ if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "k") {
+ event.preventDefault();
+ searchInput.current?.focus();
+ }
+ };
+ window.addEventListener("keydown", focusSearch);
+ return () => window.removeEventListener("keydown", focusSearch);
+ }, []);
+
const filteredProjects = useMemo(() => {
const normalized = query.trim().toLowerCase();
if (!normalized) return projects;
@@ -80,7 +93,7 @@ function App() {
{view === "library" && (
<main className="library">
<header className="library__topbar">
- <div className="search-field"><Search size={16} /><input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Search projects" aria-label="Search projects" /><kbd>⌘ K</kbd></div>
+ <div className="search-field"><Search size={16} /><input ref={searchInput} value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Search projects" aria-label="Search projects" /><kbd>Ctrl K</kbd></div>
<button className="secondary-button" onClick={() => void openFromFolder()}><FolderOpen size={15} /> Open project folder</button>
</header>
<div className="library__content">
@@ -91,11 +104,11 @@ function App() {
<PromptComposer busy={busy} onCreate={createFromPrompt} />
<section className="recent-projects" aria-labelledby="recent-heading">
- <div className="section-heading"><div><h2 id="recent-heading">Recent projects</h2><span>{filteredProjects.length} {filteredProjects.length === 1 ? "project" : "projects"}</span></div><div className="view-controls"><button className="icon-button icon-button--active" aria-label="Grid view"><Grid2X2 size={15} /></button><button className="icon-button" aria-label="List view"><List size={16} /></button></div></div>
+ <div className="section-heading"><div><h2 id="recent-heading">Recent projects</h2><span>{filteredProjects.length} {filteredProjects.length === 1 ? "project" : "projects"}</span></div><div className="view-controls" aria-label="Project layout"><button className={`icon-button ${projectLayout === "grid" ? "icon-button--active" : ""}`} aria-label="Grid view" aria-pressed={projectLayout === "grid"} onClick={() => setProjectLayout("grid")}><Grid2X2 size={15} /></button><button className={`icon-button ${projectLayout === "list" ? "icon-button--active" : ""}`} aria-label="List view" aria-pressed={projectLayout === "list"} onClick={() => setProjectLayout("list")}><List size={16} /></button></div></div>
{loading ? (
<div className="project-grid">{[0, 1, 2].map((item) => <div className="project-skeleton" key={item}><i /><span /><small /></div>)}</div>
) : filteredProjects.length ? (
- <div className="project-grid">{filteredProjects.map((project, index) => <ProjectCard key={`${project.config.id}-${project.folderPath}`} project={project} index={index} onOpen={setActiveProject} />)}</div>
+ <div className={`project-grid project-grid--${projectLayout}`}>{filteredProjects.map((project, index) => <ProjectCard key={`${project.config.id}-${project.folderPath}`} project={project} index={index} onOpen={setActiveProject} />)}</div>
) : (
<div className="library-empty"><FolderOpen size={24} /><h3>{query ? "No projects match your search" : "Your library is ready"}</h3><p>{query ? "Try a project name, prompt, or folder." : "Describe a video above or open an existing Pol Studio project folder."}</p>{!query && <button className="secondary-button" onClick={() => void openFromFolder()}>Open project folder</button>}</div>
)}
diff --git a/src/components/ProjectCard.tsx b/src/components/ProjectCard.tsx
index 9c5c50b..e067da8 100644
--- a/src/components/ProjectCard.tsx
+++ b/src/components/ProjectCard.tsx
@@ -1,4 +1,5 @@
import { Clock3, Folder, MoreHorizontal, Play, Ratio, Sparkles } from "lucide-react";
+import { useState } from "react";
import type { ProjectRecord } from "../lib/project";
interface ProjectCardProps {
@@ -18,11 +19,12 @@ function relativeDate(iso: string) {
}
export function ProjectCard({ project, index, onOpen }: ProjectCardProps) {
+ const [menuOpen, setMenuOpen] = useState(false);
const { config } = project;
const style = config.thumbnail ? { backgroundImage: `url(${JSON.stringify(config.thumbnail).slice(1, -1)})` } : undefined;
return (
<article className="project-card" tabIndex={0} onDoubleClick={() => onOpen(project)} onKeyDown={(event) => {
- if (event.key === "Enter") onOpen(project);
+ if (event.key === "Enter" && event.currentTarget === event.target) onOpen(project);
}}>
<button className="project-card__art-button" onClick={() => onOpen(project)} aria-label={`Open ${config.name}`}>
<div className={`project-card__art project-card__art--${artwork[index % artwork.length]}`} style={style}>
@@ -35,7 +37,18 @@ export function ProjectCard({ project, index, onOpen }: ProjectCardProps) {
<div className="project-card__body">
<div className="project-card__title-row">
<h3 title={config.name}>{config.name}</h3>
- <button className="icon-button" aria-label={`More options for ${config.name}`}><MoreHorizontal size={17} /></button>
+ <button
+ className="icon-button"
+ aria-label={`More options for ${config.name}`}
+ aria-haspopup="menu"
+ aria-expanded={menuOpen}
+ onClick={() => setMenuOpen((open) => !open)}
+ ><MoreHorizontal size={17} /></button>
+ {menuOpen && (
+ <div className="project-card__menu" role="menu">
+ <button role="menuitem" onClick={() => onOpen(project)}><Folder size={13} /> Open project</button>
+ </div>
+ )}
</div>
<p className="project-card__path" title={project.folderPath}><Folder size={12} /> {project.folderPath}</p>
<div className="project-card__meta">
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.ts
new file mode 100644
index 0000000..ea108a3
--- /dev/null
+++ b/src/components/ProjectWorkspace.test.ts
@@ -0,0 +1,30 @@
+// @vitest-environment jsdom
+
+import { fireEvent, render, screen } from "@testing-library/react";
+import { createElement } from "react";
+import { describe, expect, it } from "vitest";
+import completeFixture from "../../fixtures/project-v1-complete.json";
+import { parseProjectConfig } from "../lib/project";
+import { formatDurationTimecode } from "./ProjectWorkspace";
+import { ProjectWorkspace } from "./ProjectWorkspace";
+
+describe("project workspace timecode", () => {
+ it("formats project duration as valid hours, minutes, and seconds", () => {
+ expect(formatDurationTimecode(0)).toBe("00:00:00");
+ expect(formatDurationTimecode(59)).toBe("00:00:59");
+ expect(formatDurationTimecode(60)).toBe("00:01:00");
+ expect(formatDurationTimecode(600)).toBe("00:10:00");
+ });
+
+ it("surfaces native save failures in the workspace", async () => {
+ render(createElement(ProjectWorkspace, {
+ project: { folderPath: "C:\\Portable Launch Film", config: parseProjectConfig(completeFixture) },
+ onBack: () => undefined,
+ onSave: async () => { throw new Error("The original project file is locked."); },
+ }));
+ fireEvent.click(screen.getByRole("button", { name: "Save" }));
+ const alert = await screen.findByRole("alert");
+ expect(alert.textContent).toContain("Couldn’t save project");
+ expect(alert.textContent).toContain("The original project file is locked.");
+ });
+});
diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsx
index f685512..07b6a19 100644
--- a/src/components/ProjectWorkspace.tsx
+++ b/src/components/ProjectWorkspace.tsx
@@ -20,17 +20,33 @@ import {
import { useState } from "react";
import type { ProjectRecord } from "../lib/project";
+export function formatDurationTimecode(totalSeconds: number): string {
+ const seconds = Math.max(0, Math.floor(totalSeconds));
+ const hours = Math.floor(seconds / 3600);
+ const minutes = Math.floor((seconds % 3600) / 60);
+ const remainder = seconds % 60;
+ return [hours, minutes, remainder].map((value) => String(value).padStart(2, "0")).join(":");
+}
+
export function ProjectWorkspace({ project, onBack, onSave }: {
project: ProjectRecord;
onBack: () => void;
onSave: (project: ProjectRecord) => Promise<void>;
}) {
const [saving, setSaving] = useState(false);
+ const [saveError, setSaveError] = useState<string | null>(null);
const [agentPrompt, setAgentPrompt] = useState("");
const { config } = project;
const save = async () => {
setSaving(true);
- try { await onSave(project); } finally { setSaving(false); }
+ setSaveError(null);
+ try {
+ await onSave(project);
+ } catch (reason) {
+ setSaveError(reason instanceof Error ? reason.message : String(reason));
+ } finally {
+ setSaving(false);
+ }
};
return (
@@ -85,7 +101,7 @@ export function ProjectWorkspace({ project, onBack, onSave }: {
<button className="primary-button"><Sparkles size={15} /> Plan first cut</button>
</div>
</div>
- <div className="transport"><span>00:00:00</span><button><Play size={17} fill="currentColor" /></button><span>00:{String(config.brief.targetDurationSeconds).padStart(2, "0")}:00</span></div>
+ <div className="transport"><span>00:00:00</span><button><Play size={17} fill="currentColor" /></button><span>{formatDurationTimecode(config.brief.targetDurationSeconds)}</span></div>
<div className="workspace-prompt">
<Sparkles size={15} />
<input
@@ -103,6 +119,7 @@ export function ProjectWorkspace({ project, onBack, onSave }: {
<div className="timeline-placeholder__top"><div><strong>Timeline</strong><span>Scene-based editing will appear here</span></div><button className="secondary-button"><Plus size={14} /> Add scene</button></div>
<div className="timeline-placeholder__track"><span>V1</span><div><i /><i /><i /><p>Drop media or generate a first cut to begin</p></div></div>
</section>
+ {saveError && <div className="toast" role="alert"><strong>Couldn’t save project</strong><span>{saveError}</span><button onClick={() => setSaveError(null)}>Dismiss</button></div>}
</div>
);
}
diff --git a/src/lib/project.test.ts b/src/lib/project.test.ts
index c0c4595..0ba8aaf 100644
--- a/src/lib/project.test.ts
+++ b/src/lib/project.test.ts
@@ -1,5 +1,11 @@
import { describe, expect, it } from "vitest";
-import { createProjectConfig, parseProjectConfig, projectNameFromPrompt } from "./project";
+import completeFixture from "../../fixtures/project-v1-complete.json";
+import {
+ createProjectConfig,
+ normalizeProjectPath,
+ parseProjectConfig,
+ projectNameFromPrompt,
+} from "./project";
describe("project schema", () => {
it("creates a versioned, validated project", () => {
@@ -13,6 +19,46 @@ describe("project schema", () => {
expect(parseProjectConfig(project)).toEqual(project);
expect(project.schemaVersion).toBe(1);
expect(project.timeline.tracks).toEqual([]);
+ expect(project.references).toEqual([]);
+ expect(project.generationJobs).toEqual([]);
+ expect(project.agentConversation).toEqual({ messages: [] });
+ expect(project.providerSettings).toEqual({});
+ });
+
+ it("parses the complete cross-layer fixture without losing data", () => {
+ expect(parseProjectConfig(completeFixture)).toEqual(completeFixture);
+ });
+
+ it("normalizes portable paths to project-root relative forward slashes", () => {
+ expect(normalizeProjectPath("./media\\imported//clip.mp4")).toBe("media/imported/clip.mp4");
+ const config = structuredClone(completeFixture);
+ config.assets[0].relativePath = "media\\imported\\macro.mp4";
+ expect(parseProjectConfig(config).assets[0].relativePath).toBe("media/imported/macro.mp4");
+ });
+
+ it.each([
+ "/etc/passwd",
+ "\\Windows\\system.ini",
+ "C:\\Users\\creator\\clip.mp4",
+ "https://example.com/clip.mp4",
+ "media/../../outside.mp4",
+ "references/../outside.png",
+ ])("rejects escaping stored path %s", (relativePath) => {
+ const config = structuredClone(completeFixture);
+ config.assets[0].relativePath = relativePath;
+ expect(() => parseProjectConfig(config)).toThrow();
+ });
+
+ it("applies path containment to every stored path field", () => {
+ const thumbnail = structuredClone(completeFixture);
+ thumbnail.thumbnail = "../thumbnail.webp";
+ const reference = structuredClone(completeFixture);
+ reference.references[1].relativePath = "../product.png";
+ const job = structuredClone(completeFixture);
+ job.generationJobs[0].outputRelativePath = "C:\\output.mp4";
+ for (const config of [thumbnail, reference, job]) {
+ expect(() => parseProjectConfig(config)).toThrow();
+ }
});
it("rejects unknown schema versions", () => {
diff --git a/src/lib/project.ts b/src/lib/project.ts
index b9aca93..079cea6 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -6,6 +6,36 @@ export const CURRENT_SCHEMA_VERSION = 1 as const;
const idSchema = z.string().min(1);
const isoDateSchema = z.string().datetime();
+export function normalizeProjectPath(value: string): string {
+ if (!value || value.includes("\0")) {
+ throw new Error("Project paths cannot be empty or contain null bytes.");
+ }
+ if (/^[\\/]/.test(value) || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) {
+ throw new Error("Project paths must be relative to the project root.");
+ }
+ const parts = value.replace(/\\/g, "/").split("/");
+ if (parts.includes("..")) {
+ throw new Error("Project paths cannot traverse outside the project root.");
+ }
+ const normalized = parts.filter((part) => part && part !== ".").join("/");
+ if (!normalized) {
+ throw new Error("Project paths must point to an item below the project root.");
+ }
+ return normalized;
+}
+
+export const projectRelativePathSchema = z.string().transform((value, context) => {
+ try {
+ return normalizeProjectPath(value);
+ } catch (error) {
+ context.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: error instanceof Error ? error.message : "Invalid project path.",
+ });
+ return z.NEVER;
+ }
+});
+
export const aspectRatioSchema = z.enum(["16:9", "9:16", "1:1", "4:5"]);
export const resolutionSchema = z.enum(["720p", "1080p", "4k"]);
@@ -13,7 +43,7 @@ export const projectAssetSchema = z.object({
id: idSchema,
kind: z.enum(["video", "audio", "image", "caption", "generated"]),
name: z.string().min(1),
- relativePath: z.string().min(1),
+ relativePath: projectRelativePathSchema,
mimeType: z.string().min(1),
durationMs: z.number().int().nonnegative().optional(),
width: z.number().int().positive().optional(),
@@ -48,13 +78,62 @@ export const generationBriefSchema = z.object({
resolution: resolutionSchema,
});
+export const reusableReferenceSchema = z.object({
+ id: idSchema,
+ kind: z.enum(["text", "image"]),
+ name: z.string().min(1),
+ content: z.string().min(1).nullable(),
+ relativePath: projectRelativePathSchema.nullable(),
+ createdAt: isoDateSchema,
+}).superRefine((reference, context) => {
+ if (reference.kind === "text" && !reference.content) {
+ context.addIssue({ code: z.ZodIssueCode.custom, path: ["content"], message: "Text references require content." });
+ }
+ if (reference.kind === "image" && !reference.relativePath) {
+ context.addIssue({ code: z.ZodIssueCode.custom, path: ["relativePath"], message: "Image references require a relative path." });
+ }
+});
+
+export const generationJobSchema = z.object({
+ id: idSchema,
+ status: z.enum(["draft", "queued", "generating", "ready", "failed", "cancelled"]),
+ providerId: idSchema.nullable(),
+ creativeBrief: z.string().min(1),
+ compiledPrompt: z.string().min(1),
+ referenceIds: z.array(idSchema).default([]),
+ outputRelativePath: projectRelativePathSchema.nullable(),
+ error: z.string().min(1).nullable(),
+ createdAt: isoDateSchema,
+ updatedAt: isoDateSchema,
+});
+
+export const agentMessageSchema = z.object({
+ id: idSchema,
+ role: z.enum(["user", "assistant", "system"]),
+ content: z.string().min(1),
+ createdAt: isoDateSchema,
+});
+
+export const agentConversationSchema = z.object({
+ messages: z.array(agentMessageSchema).default([]),
+});
+
+const providerOptionSchema = z.union([z.string(), z.number(), z.boolean()]);
+export const providerSettingSchema = z.object({
+ enabled: z.boolean(),
+ model: z.string().min(1).nullable(),
+ options: z.record(providerOptionSchema).default({}),
+});
+
+export const providerSettingsSchema = z.record(idSchema, providerSettingSchema);
+
export const projectConfigSchema = z.object({
schemaVersion: z.literal(CURRENT_SCHEMA_VERSION),
id: idSchema,
name: z.string().min(1).max(120),
createdAt: isoDateSchema,
updatedAt: isoDateSchema,
- thumbnail: z.string().nullable(),
+ thumbnail: projectRelativePathSchema.nullable(),
settings: z.object({
aspectRatio: aspectRatioSchema,
resolution: resolutionSchema,
@@ -64,6 +143,10 @@ export const projectConfigSchema = z.object({
brief: generationBriefSchema,
assets: z.array(projectAssetSchema),
timeline: z.object({ tracks: z.array(timelineTrackSchema) }),
+ references: z.array(reusableReferenceSchema).default([]),
+ generationJobs: z.array(generationJobSchema).default([]),
+ agentConversation: agentConversationSchema.default({ messages: [] }),
+ providerSettings: providerSettingsSchema.default({}),
});
export type AspectRatio = z.infer<typeof aspectRatioSchema>;
@@ -72,6 +155,11 @@ export type ProjectAsset = z.infer<typeof projectAssetSchema>;
export type TimelineClip = z.infer<typeof timelineClipSchema>;
export type TimelineTrack = z.infer<typeof timelineTrackSchema>;
export type GenerationBrief = z.infer<typeof generationBriefSchema>;
+export type ReusableReference = z.infer<typeof reusableReferenceSchema>;
+export type GenerationJob = z.infer<typeof generationJobSchema>;
+export type AgentMessage = z.infer<typeof agentMessageSchema>;
+export type AgentConversation = z.infer<typeof agentConversationSchema>;
+export type ProviderSetting = z.infer<typeof providerSettingSchema>;
export type ProjectConfig = z.infer<typeof projectConfigSchema>;
export interface ProjectRecord {
@@ -112,6 +200,10 @@ export function createProjectConfig(input: CreateProjectInput): ProjectConfig {
},
assets: [],
timeline: { tracks: [] },
+ references: [],
+ generationJobs: [],
+ agentConversation: { messages: [] },
+ providerSettings: {},
});
}
diff --git a/src/styles/app.css b/src/styles/app.css
index 2569e86..41c03ad 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -112,6 +112,11 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-
.section-heading > div:first-child { display: flex; align-items: baseline; gap: 9px; }.section-heading h2 { margin: 0; font-size: 14px; font-weight: 600; }.section-heading span { color: #5f6674; font-size: 9px; }
.view-controls { display: flex; gap: 2px; }
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
+.project-grid--list { grid-template-columns: 1fr; }
+.project-grid--list .project-card { display: grid; grid-template-columns: minmax(180px, 24%) 1fr; }
+.project-grid--list .project-card__art, .project-grid--list .project-card__art-button { height: 100%; }
+.project-grid--list .project-card__art { aspect-ratio: auto; min-height: 112px; }
+.project-grid--list .project-card__body { align-self: center; }
.project-card { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: #0e1117; overflow: hidden; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.project-card:hover, .project-card:focus { transform: translateY(-2px); border-color: rgba(117, 137, 198, .28); box-shadow: 0 15px 35px rgba(0,0,0,.28); outline: none; }
.project-card__art-button { display: block; width: 100%; padding: 0; border: 0; background: none; }
@@ -134,7 +139,10 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-
.project-card__art-copy { position: absolute; z-index: 2; inset: auto 10px 9px; display: flex; gap: 6px; align-items: center; color: rgba(255,255,255,.75); text-shadow: 0 1px 5px #000; font-size: 8px; text-align: left; }
.project-card__art-copy svg { flex: 0 0 auto; }.project-card__art-copy span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card__body { padding: 11px 12px 10px; }
-.project-card__title-row { display: flex; align-items: center; gap: 4px; }.project-card__title-row h3 { min-width: 0; flex: 1; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #d9dce3; font-size: 11px; font-weight: 600; }
+.project-card__title-row { position: relative; display: flex; align-items: center; gap: 4px; }.project-card__title-row h3 { min-width: 0; flex: 1; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #d9dce3; font-size: 11px; font-weight: 600; }
+.project-card__menu { position: absolute; z-index: 5; top: 27px; right: 0; min-width: 120px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 6px; background: #171b24; box-shadow: 0 8px 22px rgba(0,0,0,.35); }
+.project-card__menu button { width: 100%; height: 28px; padding: 0 7px; display: flex; align-items: center; gap: 6px; border: 0; border-radius: 4px; color: #c8cdd7; background: transparent; font-size: 9px; text-align: left; }
+.project-card__menu button:hover { background: rgba(255,255,255,.06); }
.project-card__path { margin: 3px 0 10px; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #555d6b; font: 400 8px "DM Mono", monospace; }
.project-card__path svg { flex: 0 0 auto; }.project-card__meta { border-top: 1px solid var(--line); padding-top: 8px; display: flex; justify-content: space-between; color: #676e7b; font-size: 8px; }.project-card__meta span { display: flex; align-items: center; gap: 4px; }
.project-skeleton { height: 225px; border-radius: 10px; padding: 10px; border: 1px solid var(--line); background: #0e1117; }.project-skeleton i { display: block; height: 145px; border-radius: 6px; background: #151922; }.project-skeleton span, .project-skeleton small { display: block; height: 8px; margin-top: 14px; border-radius: 4px; background: #181c24; }.project-skeleton small { width: 60%; margin-top: 8px; }