Compare commits

...

16 Commits

Author SHA1 Message Date
Test
8f8954a6f7 fix: inbox sidebar ordering, filter chip wrapping, and editor banner architecture
- Move Inbox to first position in sidebar (before All Notes)
- Add whitespace-nowrap to filter pills + flex-wrap on container so chips
  wrap as whole units instead of breaking text internally
- Editor now reads trashed/archived state from fresh vault entries instead
  of potentially stale tab entry, ensuring banners appear regardless of
  navigation context
- Update tests to pass correct entries prop alongside tabs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 22:36:59 +01:00
Test
99f5716508 feat: show emoji icon in sidebar note items
Pass the icon field from VaultEntry to SectionChildItem and render
it before the title when present, matching the pattern used in
NoteItem and other contexts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 21:58:34 +01:00
Test
b8f29c9530 fix: align type selector chip left using grid layout matching property rows
The type selector was using flex justify-between, pushing the chip to the
right side of the Properties panel. Switch to grid-cols-2 layout (matching
PropertyRow and InfoRow) so the chip sits left-aligned in the value column.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 21:27:51 +01:00
Test
33ae00a558 style: apply rustfmt to vault_config.rs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 21:04:05 +01:00
Test
ac02de88e6 fix: store ui.config.md at vault root instead of config/ directory
Repair Vault was creating config/ui.config.md inside a config/ subdirectory.
All vault config files should live at vault root (flat structure). Changed
config_path() to point to vault root, added migrate_ui_config_to_root() for
legacy migration, and wired it into both startup and repair_vault flows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 21:00:19 +01:00
Test
fb8208cfa0 fix: use CSS grid for 50/50 label/value layout in properties panel
Flex layout with gap-2 allowed content to override the 50% width split,
causing short labels like "URL" to be truncated to "U…" when values were
long. Switching to grid-cols-2 enforces exact 50/50 columns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 20:27:36 +01:00
Test
66e29b70b8 fix: match TitleField font-size/weight to BlockNote H1 and fix left alignment
TitleField now uses var(--headings-h1-font-size/weight/line-height/letter-spacing)
instead of hardcoded 28px, matching the editor H1 exactly. Added margin-left: 8px
to align with BlockNote's bn-block-content offset. Fixed bn-editor max-width to
use the same CSS var as the title-section for consistent horizontal alignment.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 20:03:26 +01:00
Test
d1b358f76a fix: remove incorrect wikilink assertion from snippet smoke test
Wikilinks ([[note name]]) are valid content in note snippets — they are
plain-text references, not raw markdown formatting. The test was failing
against demo-vault data containing wikilinks in renamed-title-xyz.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 19:38:51 +01:00
Test
c2ce67c300 test: add smoke test for focus-event UI freeze regression
Verifies that window focus events don't block the main thread for >500ms,
covering both single focus and rapid 5x focus (Cmd+Tab spam) scenarios.
Completes the regression test requirement for the git-commands-off-main-thread fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 19:28:53 +01:00
Test
07522e984c fix: eliminate UI freeze on app focus by moving git commands off main thread
Sync Tauri commands (git_pull, git_push, git_remote_status, reload_vault)
blocked the runtime thread during network I/O, freezing the UI for 2-3s
on every Cmd+Tab. Converted them to async with tokio::spawn_blocking.
Added 30s cooldown to focus-triggered git pull and theme settings reload
to prevent redundant work on rapid app switching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 19:05:23 +01:00
Test
36f43c1ae0 fix: note list resolves relationships by title/alias matching unified resolveEntry
resolveRefs() and refsMatch() in noteListHelpers used a simple 2-pass
matching (path stem + filename stem), while the Inspector used the unified
resolveEntry() with 4-pass resolution (filename, alias, title, humanized
title). Notes matched only by title or alias were silently dropped from the
note list, causing incomplete relationship groups.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 16:03:50 +01:00
Test
1b478d0fc1 fix: remove vertical padding from PropertyRow to match InfoRow density
PropertyRow had py-0.5 (4px total) while InfoRow had no vertical padding,
making Properties rows taller than Info rows even with equal gap values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 12:26:25 +01:00
Test
8646be6b8d fix: force WKWebView pseudo-element style recalc on theme CSS var changes
WKWebView doesn't invalidate ::before/::after pseudo-element styles when
CSS custom properties change via inline styles alone — offsetHeight reflow
only triggers layout, not style recalculation. This caused bullet size and
bullet color (rendered via ::before on bulletListItem) to not update live
when editing a theme note and saving with Cmd+S.

Fix: after setting CSS vars as inline styles, also inject them into a
<style> element. Replacing <style> content forces a full style tree
invalidation in WebKit, covering pseudo-elements that reference var().

Also extract shouldDeactivate/deactivateTheme helpers from useThemeManager
to reduce cyclomatic complexity (CodeScene: 8.77 → 9.6).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 08:41:30 +01:00
Test
fd9b4fe5e7 refactor: NoteList.test.tsx -- deduplicate makeEntry helpers and bulk action tests (CodeScene: 7.78 to 10.0)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 07:18:34 +01:00
Test
d52365882c style: rustfmt formatting for mod_tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 03:28:36 +01:00
Test
135fe62d21 fix: note list shows incomplete relationships when opening from sidebar
Two root causes:
1. noteListHooks used a stale selection.entry to build relationship groups —
   now looks up the fresh entry from the entries array so relationship updates
   propagate immediately.
2. frontmatterToEntryPatch didn't update entry.relationships — added
   RelationshipPatch support so frontmatter changes also update the
   relationships map in state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 03:26:52 +01:00
33 changed files with 935 additions and 396 deletions

View File

@@ -539,7 +539,7 @@ Managed by `useIndexing` hook:
### Vault Config
Per-vault settings stored in `config/ui.config.md`:
Per-vault settings stored in `ui.config.md` at vault root:
- Editable as a normal note (YAML frontmatter)
- Managed by `useVaultConfig` hook and `vaultConfigStore`
- Settings: zoom, view mode, tag colors, status colors, property display modes

View File

@@ -466,7 +466,7 @@ Managed by `useVaultSwitcher` hook. Switching vaults closes all tabs and resets
### Vault Config
Per-vault UI settings stored in `config/ui.config.md` (YAML frontmatter in a markdown note):
Per-vault UI settings stored in `ui.config.md` at vault root (YAML frontmatter in a markdown note):
- `zoom`: Float zoom level (0.81.5)
- `view_mode`: "all" | "editor-list" | "editor-only"
- `editor_mode`: "raw" | "preview" (persists across tab switches and sessions)

View File

@@ -155,10 +155,14 @@ pub fn get_default_vault_path() -> Result<String, String> {
}
#[tauri::command]
pub fn reload_vault(path: String) -> Result<Vec<VaultEntry>, String> {
let path = expand_tilde(&path);
vault::invalidate_cache(std::path::Path::new(path.as_ref()));
vault::scan_vault_cached(std::path::Path::new(path.as_ref()))
pub async fn reload_vault(path: String) -> Result<Vec<VaultEntry>, String> {
let path = expand_tilde(&path).into_owned();
tokio::task::spawn_blocking(move || {
vault::invalidate_cache(std::path::Path::new(&path));
vault::scan_vault_cached(std::path::Path::new(&path))
})
.await
.map_err(|e| format!("Task panicked: {e}"))?
}
#[tauri::command]
@@ -293,9 +297,11 @@ pub fn get_last_commit_info(vault_path: String) -> Result<Option<LastCommitInfo>
}
#[tauri::command]
pub fn git_pull(vault_path: String) -> Result<GitPullResult, String> {
let vault_path = expand_tilde(&vault_path);
git::git_pull(&vault_path)
pub async fn git_pull(vault_path: String) -> Result<GitPullResult, String> {
let vault_path = expand_tilde(&vault_path).into_owned();
tokio::task::spawn_blocking(move || git::git_pull(&vault_path))
.await
.map_err(|e| format!("Task panicked: {e}"))?
}
#[tauri::command]
@@ -327,15 +333,19 @@ pub fn git_commit_conflict_resolution(vault_path: String) -> Result<String, Stri
}
#[tauri::command]
pub fn git_push(vault_path: String) -> Result<GitPushResult, String> {
let vault_path = expand_tilde(&vault_path);
git::git_push(&vault_path)
pub async fn git_push(vault_path: String) -> Result<GitPushResult, String> {
let vault_path = expand_tilde(&vault_path).into_owned();
tokio::task::spawn_blocking(move || git::git_push(&vault_path))
.await
.map_err(|e| format!("Task panicked: {e}"))?
}
#[tauri::command]
pub fn git_remote_status(vault_path: String) -> Result<GitRemoteStatus, String> {
let vault_path = expand_tilde(&vault_path);
git::git_remote_status(&vault_path)
pub async fn git_remote_status(vault_path: String) -> Result<GitRemoteStatus, String> {
let vault_path = expand_tilde(&vault_path).into_owned();
tokio::task::spawn_blocking(move || git::git_remote_status(&vault_path))
.await
.map_err(|e| format!("Task panicked: {e}"))?
}
// ── GitHub commands ─────────────────────────────────────────────────────────
@@ -578,6 +588,8 @@ pub fn repair_vault(vault_path: String) -> Result<String, String> {
// Migrate legacy theme/ directory to root, then repair themes
theme::migrate_theme_dir_to_root(&vault_path);
theme::restore_default_themes(&vault_path)?;
// Migrate legacy config/ui.config.md → root ui.config.md
vault_config::migrate_ui_config_to_root(&vault_path);
// Repair config files (AGENTS.md at root, config.md type def)
vault::repair_config_files(&vault_path)?;
// Ensure .gitignore with sensible defaults exists
@@ -794,7 +806,9 @@ mod tests {
std::fs::write(vault.join("note.md"), "---\nTrashed: true\n---\n# Note\n").unwrap();
// reload_vault must return the updated trashed state
let fresh = reload_vault(vault.to_str().unwrap().to_string()).unwrap();
let vault_str = vault.to_str().unwrap();
vault::invalidate_cache(std::path::Path::new(vault_str));
let fresh = vault::scan_vault_cached(std::path::Path::new(vault_str)).unwrap();
assert!(
fresh[0].trashed,
"reload_vault must reflect disk state after trashing"

View File

@@ -44,6 +44,8 @@ fn run_startup_tasks() {
"Migrated is_a to type on startup",
vault::migrate_is_a_to_type(vp_str),
);
// Migrate legacy config/ui.config.md → root ui.config.md
vault_config::migrate_ui_config_to_root(vp_str);
log_startup_result(
"Migrated hidden_sections to visible property",
vault_config::migrate_hidden_sections_to_visible(vp_str),

View File

@@ -486,6 +486,79 @@ References:
);
}
// --- large relationship array (regression: No Code note with 32 Notes) ---
#[test]
fn test_parse_large_notes_relationship_array() {
let dir = TempDir::new().unwrap();
let content = r#"---
type: Topic
Referred by Data:
- "[[michele-sampieri|Michele Sampieri]]"
- "[[varun-anand|Varun Anand]]"
Belongs to:
- "[[engineering|Engineering]]"
aliases:
- No Code
Notes:
- "[[8020-we-help-companies-move-faster-without-code|8020 | We help companies move faster without code.]]"
- "[[airdev-build-hub|Airdev Build Hub]]"
- "[[airdev-leader-in-bubble-and-no-code-development|AirDev | Leader in Bubble and No-Code Development]]"
- "[[budibase-internal-tools-made-easy|Budibase - Internal tools made easy]]"
- "[[bullet-launch-bubble-boilerplate|Bullet Launch Bubble Boilerplate]]"
- "[[canvas-base-template-for-bubble|Canvas • Base Template for Bubble]]"
- "[[chameleon-microsurveys|Chameleon | Microsurveys]]"
- "[[felt-the-best-way-to-make-maps-on-the-internet|Felt The best way to make maps on the internet]]"
- "[[flutterflow-build-native-apps-visually|FlutterFlow | Build Native Apps Visually]]"
- "[[framer-ai-generate-and-publish-your-site-with-ai-in-seconds|Framer AI — Generate and publish your site with AI in seconds.]]"
- "[[jumpstart-pro-the-best-ruby-on-rails-saas-template|Jumpstart Pro | The best Ruby on Rails SaaS Template]]"
- "[[mailparser-email-parser-software-workflow-automation|MailParser • Email Parser Software & Workflow Automation]]"
- "[[make-work-the-way-you-imagine|Make | Work the way you imagine]]"
- "[[michele-sampieri|Michele Sampieri]]"
- "[[n8nio-a-powerful-workflow-automation-tool|n8n.io - a powerful workflow automation tool]]"
- "[[n8nio-ai-workflow-automation-tool|n8n.io - AI workflow automation tool]]"
- "[[nocodey-find-best-nocoder|Nocodey • Find Best Nocoder]]"
- "[[outseta-software-for-subscription-start-ups|Outseta | Software for subscription start-ups]]"
- "[[payments-tax-subscriptions-for-software-companies-lemon-squeezy|Payments, tax & subscriptions for software companies • Lemon Squeezy]]"
- "[[retool-portals-custom-client-portal-software|Retool Portals • Custom Client Portal Software]]"
- "[[rise-of-the-no-code-economy-report-formstack|Rise of the No-Code Economy Report | Formstack]]"
- "[[scene-the-smart-way-to-build-websites|Scene • The smart way to build websites]]"
- "[[scrapingbee-the-best-web-scraping-api|ScrapingBee • the best web scraping API]]"
- "[[softr-build-a-website-web-app-or-portal-on-airtable-without-code|Softr | Build a website, web app or portal on Airtable without code]]"
- "[[superblocks-build-modern-internal-apps-in-days-not-months|Superblocks • Build modern internal apps in days, not months]]"
- "[[superwall-quickly-deploy-paywalls|Superwall • Quickly deploy paywalls]]"
- "[[tails-tailwind-css-page-creator|Tails | Tailwind CSS Page Creator]]"
- "[[the-open-source-firebase-alternative-supabase|The Open Source Firebase Alternative | Supabase]]"
- "[[varun-anand|Varun Anand]]"
- "[[xano-the-fastest-no-code-backend-development-platform|Xano - The Fastest No Code Backend Development Platform]]"
- "[[directus-open-data-platform-for-headless-content-management|{'Directus': 'Open Data Platform for Headless Content Management'}]]"
- "[[framer-design-beautiful-websites-in-minutes|{'Framer': 'Design beautiful websites in minutes'}]]"
title: No Code
---
# No Code
"#;
create_test_file(dir.path(), "no-code.md", content);
let entry = parse_md_file(&dir.path().join("no-code.md")).unwrap();
let notes = entry
.relationships
.get("Notes")
.expect("Notes relationship should exist");
assert_eq!(notes.len(), 32, "All 32 Notes entries should be parsed");
let referred = entry
.relationships
.get("Referred by Data")
.expect("Referred by Data should exist");
assert_eq!(referred.len(), 2);
let belongs = entry
.relationships
.get("Belongs to")
.expect("Belongs to should exist");
assert_eq!(belongs.len(), 1);
}
// --- type from frontmatter only (no folder inference) ---
#[test]

View File

@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::Path;
/// Vault-wide UI configuration stored in `config/ui.config.md`.
/// Vault-wide UI configuration stored in `ui.config.md` at vault root.
///
/// This file is a regular vault note with YAML frontmatter, visible in the
/// sidebar under the "Config" section and editable like any note.
@@ -21,14 +21,13 @@ pub struct VaultConfig {
pub property_display_modes: Option<HashMap<String, String>>,
}
const CONFIG_DIR: &str = "config";
const CONFIG_FILENAME: &str = "ui.config.md";
fn config_path(vault_path: &str) -> std::path::PathBuf {
Path::new(vault_path).join(CONFIG_DIR).join(CONFIG_FILENAME)
Path::new(vault_path).join(CONFIG_FILENAME)
}
/// Read the vault-wide UI config from `config/ui.config.md`.
/// Read the vault-wide UI config from `ui.config.md` at vault root.
/// Returns default values if the file doesn't exist.
pub fn get_vault_config(vault_path: &str) -> Result<VaultConfig, String> {
let path = config_path(vault_path);
@@ -69,19 +68,42 @@ fn parse_vault_config(content: &str) -> Result<VaultConfig, String> {
.map_err(|e| format!("Failed to parse config: {e}"))
}
/// Save the vault-wide UI config to `config/ui.config.md`.
/// Creates the directory and file if they don't exist.
/// Save the vault-wide UI config to `ui.config.md` at vault root.
/// Creates the file if it doesn't exist.
pub fn save_vault_config(vault_path: &str, config: VaultConfig) -> Result<(), String> {
let path = config_path(vault_path);
let dir = Path::new(vault_path).join(CONFIG_DIR);
if !dir.exists() {
std::fs::create_dir_all(&dir).map_err(|e| format!("Failed to create config dir: {e}"))?;
}
let content = serialize_config(&config);
std::fs::write(&path, content).map_err(|e| format!("Failed to write config: {e}"))
}
/// Migrate legacy `config/ui.config.md` → root `ui.config.md`.
/// If the root file already exists, the legacy file is simply removed.
/// Cleans up empty `config/` directory after migration.
pub fn migrate_ui_config_to_root(vault_path: &str) {
let vault = Path::new(vault_path);
let legacy = vault.join("config").join(CONFIG_FILENAME);
let root = vault.join(CONFIG_FILENAME);
if legacy.exists() {
if !root.exists() {
// Move legacy content to root
if let Ok(content) = std::fs::read_to_string(&legacy) {
let _ = std::fs::write(&root, content);
}
}
let _ = std::fs::remove_file(&legacy);
}
// Clean up empty config/ directory
let config_dir = vault.join("config");
if config_dir.is_dir() {
let is_empty = std::fs::read_dir(&config_dir).map_or(true, |mut d| d.next().is_none());
if is_empty {
let _ = std::fs::remove_dir(&config_dir);
}
}
}
/// Serialize VaultConfig to a markdown file with YAML frontmatter.
fn serialize_config(config: &VaultConfig) -> String {
let mut lines = vec!["---".to_string(), "type: config".to_string()];
@@ -142,7 +164,7 @@ fn yaml_safe_value(value: &str) -> String {
}
}
/// Migrate `hidden_sections` from `config/ui.config.md` to `visible: false`
/// Migrate `hidden_sections` from `ui.config.md` to `visible: false`
/// on Type notes. Returns the number of Type notes updated.
///
/// For each type name in `hidden_sections`:
@@ -354,11 +376,9 @@ property_display_modes:
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
// Create config with hidden_sections
let config_dir = dir.path().join("config");
std::fs::create_dir_all(&config_dir).unwrap();
// Create config with hidden_sections at vault root
std::fs::write(
config_dir.join("ui.config.md"),
dir.path().join("ui.config.md"),
"---\ntype: config\nhidden_sections:\n - Bookmark\n - Recipe\n---\n",
)
.unwrap();
@@ -375,7 +395,7 @@ property_display_modes:
assert!(recipe.contains("visible: false"));
// Config should no longer have hidden_sections
let config_content = std::fs::read_to_string(config_dir.join("ui.config.md")).unwrap();
let config_content = std::fs::read_to_string(dir.path().join("ui.config.md")).unwrap();
assert!(!config_content.contains("hidden_sections"));
}
@@ -384,11 +404,9 @@ property_display_modes:
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
// Create config with hidden_sections
let config_dir = dir.path().join("config");
std::fs::create_dir_all(&config_dir).unwrap();
// Create config with hidden_sections at vault root
std::fs::write(
config_dir.join("ui.config.md"),
dir.path().join("ui.config.md"),
"---\ntype: config\nhidden_sections:\n - Project\n---\n",
)
.unwrap();
@@ -416,10 +434,8 @@ property_display_modes:
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
let config_dir = dir.path().join("config");
std::fs::create_dir_all(&config_dir).unwrap();
std::fs::write(
config_dir.join("ui.config.md"),
dir.path().join("ui.config.md"),
"---\ntype: config\nzoom: 1.0\n---\n",
)
.unwrap();
@@ -440,19 +456,15 @@ property_display_modes:
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
let config_dir = dir.path().join("config");
std::fs::create_dir_all(&config_dir).unwrap();
std::fs::write(
config_dir.join("ui.config.md"),
dir.path().join("ui.config.md"),
"---\ntype: config\nhidden_sections:\n - Note\n---\n",
)
.unwrap();
// Type note already has visible: false
let type_dir = dir.path().join("type");
std::fs::create_dir_all(&type_dir).unwrap();
// Type note already has visible: false at vault root
std::fs::write(
type_dir.join("note.md"),
dir.path().join("note.md"),
"---\ntype: Type\ntitle: Note\nvisible: false\n---\n",
)
.unwrap();
@@ -460,7 +472,7 @@ property_display_modes:
let count = migrate_hidden_sections_to_visible(vault_path).unwrap();
assert_eq!(count, 1);
let content = std::fs::read_to_string(type_dir.join("note.md")).unwrap();
let content = std::fs::read_to_string(dir.path().join("note.md")).unwrap();
// Should have exactly one visible: false, not two
assert_eq!(content.matches("visible:").count(), 1);
}
@@ -478,4 +490,90 @@ property_display_modes:
assert_eq!(yaml_safe_key("has space"), "\"has space\"");
assert_eq!(yaml_safe_key("has:colon"), "\"has:colon\"");
}
#[test]
fn migrate_ui_config_moves_legacy_to_root() {
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
let config_dir = dir.path().join("config");
std::fs::create_dir_all(&config_dir).unwrap();
std::fs::write(
config_dir.join("ui.config.md"),
"---\ntype: config\nzoom: 1.5\n---\n",
)
.unwrap();
migrate_ui_config_to_root(vault_path);
// Root file should exist with migrated content
let content = std::fs::read_to_string(dir.path().join("ui.config.md")).unwrap();
assert!(content.contains("zoom: 1.5"));
// Legacy file and empty config dir should be gone
assert!(!config_dir.join("ui.config.md").exists());
assert!(!config_dir.exists());
}
#[test]
fn migrate_ui_config_preserves_existing_root() {
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
// Root already has content
std::fs::write(
dir.path().join("ui.config.md"),
"---\ntype: config\nzoom: 2.0\n---\n",
)
.unwrap();
// Legacy also exists
let config_dir = dir.path().join("config");
std::fs::create_dir_all(&config_dir).unwrap();
std::fs::write(
config_dir.join("ui.config.md"),
"---\ntype: config\nzoom: 1.0\n---\n",
)
.unwrap();
migrate_ui_config_to_root(vault_path);
// Root should keep its original content
let content = std::fs::read_to_string(dir.path().join("ui.config.md")).unwrap();
assert!(content.contains("zoom: 2.0"));
// Legacy file should be removed
assert!(!config_dir.join("ui.config.md").exists());
}
#[test]
fn migrate_ui_config_keeps_nonempty_config_dir() {
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
let config_dir = dir.path().join("config");
std::fs::create_dir_all(&config_dir).unwrap();
std::fs::write(config_dir.join("ui.config.md"), "---\ntype: config\n---\n").unwrap();
std::fs::write(config_dir.join("other.md"), "Other file").unwrap();
migrate_ui_config_to_root(vault_path);
// config/ should still exist because it has other files
assert!(config_dir.exists());
assert!(config_dir.join("other.md").exists());
assert!(!config_dir.join("ui.config.md").exists());
}
#[test]
fn save_config_writes_to_vault_root() {
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_str().unwrap();
let config = VaultConfig {
zoom: Some(1.0),
..Default::default()
};
save_vault_config(vault_path, config).unwrap();
// File should be at vault root, not in config/
assert!(dir.path().join("ui.config.md").exists());
assert!(!dir.path().join("config").exists());
}
}

View File

@@ -664,6 +664,39 @@ describe('DynamicPropertiesPanel', () => {
})
})
describe('property row 50/50 layout', () => {
it('uses CSS grid with two equal columns on editable rows', () => {
render(
<DynamicPropertiesPanel
entry={makeEntry()}
content=""
frontmatter={{ url: 'https://example.com/very/long/path/that/should/be/truncated' }}
onUpdateProperty={onUpdateProperty}
/>
)
const editableRows = screen.getAllByTestId('editable-property')
editableRows.forEach(row => {
expect(row.className).toContain('grid')
expect(row.className).toContain('grid-cols-2')
})
})
it('uses CSS grid with two equal columns on read-only rows', () => {
render(
<DynamicPropertiesPanel
entry={makeEntry()}
content=""
frontmatter={{}}
/>
)
const readOnlyRows = screen.getAllByTestId('readonly-property')
readOnlyRows.forEach(row => {
expect(row.className).toContain('grid')
expect(row.className).toContain('grid-cols-2')
})
})
})
describe('URL property rendering', () => {
it('renders URL values with link styling instead of plain EditableValue', () => {
render(

View File

@@ -47,15 +47,15 @@ function PropertyRow({ propKey, value, editingKey, displayMode, autoMode, vaultS
}
return (
<div className="group/prop flex min-w-0 items-center gap-2 rounded px-1.5 py-0.5 outline-none transition-colors hover:bg-muted focus:bg-muted focus:ring-1 focus:ring-primary" tabIndex={0} onKeyDown={handleKeyDown} data-testid="editable-property">
<span className="font-mono-overline flex w-1/2 shrink-0 min-w-0 items-center gap-1 text-muted-foreground">
<div className="group/prop grid min-w-0 grid-cols-2 items-center gap-2 rounded px-1.5 outline-none transition-colors hover:bg-muted focus:bg-muted focus:ring-1 focus:ring-primary" tabIndex={0} onKeyDown={handleKeyDown} data-testid="editable-property">
<span className="font-mono-overline flex min-w-0 items-center gap-1 text-muted-foreground">
<span className="truncate">{propKey}</span>
{onDelete && (
<button className="border-none bg-transparent p-0 text-sm leading-none text-muted-foreground opacity-0 transition-all hover:text-destructive group-hover/prop:opacity-100" onClick={() => onDelete(propKey)} title="Delete property">&times;</button>
)}
<DisplayModeSelector propKey={propKey} currentMode={displayMode} autoMode={autoMode} onSelect={onDisplayModeChange} />
</span>
<div className="w-1/2 min-w-0">
<div className="min-w-0">
<SmartPropertyValueCell propKey={propKey} value={value} displayMode={displayMode} isEditing={editingKey === propKey} vaultStatuses={vaultStatuses} vaultTags={vaultTags} onStartEdit={onStartEdit} onSave={onSave} onSaveList={onSaveList} onUpdate={onUpdate} />
</div>
</div>
@@ -64,9 +64,9 @@ function PropertyRow({ propKey, value, editingKey, displayMode, autoMode, vaultS
function InfoRow({ label, value }: { label: string; value: string }) {
return (
<div className="flex min-w-0 items-center gap-2 px-1.5" data-testid="readonly-property">
<span className="font-mono-overline w-1/2 shrink-0 truncate" style={{ color: 'var(--text-muted)' }}>{label}</span>
<span className="w-1/2 min-w-0 truncate text-right text-[12px]" style={{ color: 'var(--text-muted)' }}>{value}</span>
<div className="grid min-w-0 grid-cols-2 items-center gap-2 px-1.5" data-testid="readonly-property">
<span className="font-mono-overline min-w-0 truncate" style={{ color: 'var(--text-muted)' }}>{label}</span>
<span className="min-w-0 truncate text-right text-[12px]" style={{ color: 'var(--text-muted)' }}>{value}</span>
</div>
)
}

View File

@@ -96,7 +96,7 @@
.editor__blocknote-container .bn-editor {
width: 100%;
padding: 20px 40px;
max-width: 760px;
max-width: var(--editor-max-width, 760px);
margin: 0 auto;
}
@@ -282,11 +282,13 @@
border: none;
outline: none;
background: transparent;
font-size: var(--editor-title-size, 28px);
font-weight: 700;
line-height: 1.2;
font-size: var(--headings-h1-font-size);
font-weight: var(--headings-h1-font-weight);
line-height: var(--headings-h1-line-height);
letter-spacing: var(--headings-h1-letter-spacing);
color: var(--foreground);
padding: 0;
margin-left: 8px;
}
.title-field__input::placeholder {

View File

@@ -300,7 +300,7 @@ describe('Editor', () => {
const trashedTab = { entry: trashedEntry, content: mockContent }
function renderTrashed(overrides: Partial<Parameters<typeof Editor>[0]> = {}) {
return render(<Editor {...defaultProps} tabs={[trashedTab]} activeTabPath={trashedEntry.path} {...overrides} />)
return render(<Editor {...defaultProps} entries={[trashedEntry]} tabs={[trashedTab]} activeTabPath={trashedEntry.path} {...overrides} />)
}
it('shows banner and read-only editor when note is trashed', () => {
@@ -336,9 +336,10 @@ describe('Editor', () => {
)
expect(screen.queryByTestId('trashed-note-banner')).not.toBeInTheDocument()
const updatedTab = { entry: { ...mockEntry, trashed: true, trashedAt: Date.now() / 1000 }, content: mockContent }
const trashedEntryUpdated = { ...mockEntry, trashed: true, trashedAt: Date.now() / 1000 }
const updatedTab = { entry: trashedEntryUpdated, content: mockContent }
rerender(
<Editor {...defaultProps} tabs={[updatedTab]} activeTabPath={mockEntry.path} onRestoreNote={vi.fn()} onDeleteNote={vi.fn()} />
<Editor {...defaultProps} entries={[trashedEntryUpdated]} tabs={[updatedTab]} activeTabPath={mockEntry.path} onRestoreNote={vi.fn()} onDeleteNote={vi.fn()} />
)
expect(screen.getByTestId('trashed-note-banner')).toBeInTheDocument()
expect(screen.getByTestId('blocknote-view')).toHaveAttribute('data-editable', 'false')
@@ -346,13 +347,14 @@ describe('Editor', () => {
it('removes trash banner immediately when entry is restored (reactive)', () => {
const { rerender } = render(
<Editor {...defaultProps} tabs={[trashedTab]} activeTabPath={trashedEntry.path} onRestoreNote={vi.fn()} onDeleteNote={vi.fn()} />
<Editor {...defaultProps} entries={[trashedEntry]} tabs={[trashedTab]} activeTabPath={trashedEntry.path} onRestoreNote={vi.fn()} onDeleteNote={vi.fn()} />
)
expect(screen.getByTestId('trashed-note-banner')).toBeInTheDocument()
const restoredTab = { entry: { ...trashedEntry, trashed: false, trashedAt: null }, content: mockContent }
const restoredEntry = { ...trashedEntry, trashed: false, trashedAt: null }
const restoredTab = { entry: restoredEntry, content: mockContent }
rerender(
<Editor {...defaultProps} tabs={[restoredTab]} activeTabPath={trashedEntry.path} onRestoreNote={vi.fn()} onDeleteNote={vi.fn()} />
<Editor {...defaultProps} entries={[restoredEntry]} tabs={[restoredTab]} activeTabPath={trashedEntry.path} onRestoreNote={vi.fn()} onDeleteNote={vi.fn()} />
)
expect(screen.queryByTestId('trashed-note-banner')).not.toBeInTheDocument()
expect(screen.getByTestId('blocknote-view')).toHaveAttribute('data-editable', 'true')
@@ -408,6 +410,7 @@ describe('click empty editor space', () => {
render(
<Editor
{...defaultProps}
entries={[trashedEntry]}
tabs={[{ entry: trashedEntry, content: mockContent }]}
activeTabPath={trashedEntry.path}
/>
@@ -429,9 +432,10 @@ describe('archived note behavior', () => {
)
expect(screen.queryByTestId('archived-note-banner')).not.toBeInTheDocument()
const archivedTab = { entry: { ...mockEntry, archived: true }, content: mockContent }
const archivedEntry = { ...mockEntry, archived: true }
const archivedTab = { entry: archivedEntry, content: mockContent }
rerender(
<Editor {...defaultProps} tabs={[archivedTab]} activeTabPath={mockEntry.path} onUnarchiveNote={vi.fn()} />
<Editor {...defaultProps} entries={[archivedEntry]} tabs={[archivedTab]} activeTabPath={mockEntry.path} onUnarchiveNote={vi.fn()} />
)
expect(screen.getByTestId('archived-note-banner')).toBeInTheDocument()
})
@@ -440,13 +444,14 @@ describe('archived note behavior', () => {
const archivedEntry: VaultEntry = { ...mockEntry, archived: true }
const archivedTab = { entry: archivedEntry, content: mockContent }
const { rerender } = render(
<Editor {...defaultProps} tabs={[archivedTab]} activeTabPath={archivedEntry.path} onUnarchiveNote={vi.fn()} />
<Editor {...defaultProps} entries={[archivedEntry]} tabs={[archivedTab]} activeTabPath={archivedEntry.path} onUnarchiveNote={vi.fn()} />
)
expect(screen.getByTestId('archived-note-banner')).toBeInTheDocument()
const unarchivedTab = { entry: { ...archivedEntry, archived: false }, content: mockContent }
const unarchivedEntry = { ...archivedEntry, archived: false }
const unarchivedTab = { entry: unarchivedEntry, content: mockContent }
rerender(
<Editor {...defaultProps} tabs={[unarchivedTab]} activeTabPath={archivedEntry.path} onUnarchiveNote={vi.fn()} />
<Editor {...defaultProps} entries={[unarchivedEntry]} tabs={[unarchivedTab]} activeTabPath={archivedEntry.path} onUnarchiveNote={vi.fn()} />
)
expect(screen.queryByTestId('archived-note-banner')).not.toBeInTheDocument()
})

View File

@@ -161,7 +161,11 @@ export function EditorContent({
isConflicted, onKeepMine, onKeepTheirs,
...breadcrumbProps
}: EditorContentProps) {
const isTrashed = activeTab?.entry.trashed ?? false
// Look up trashed/archived from the latest vault entries, not the tab snapshot,
// so the banner appears regardless of navigation context.
const freshEntry = activeTab ? entries.find(e => e.path === activeTab.entry.path) : undefined
const isTrashed = freshEntry?.trashed ?? activeTab?.entry.trashed ?? false
const isArchived = freshEntry?.archived ?? activeTab?.entry.archived ?? false
const showEditor = !diffMode && !rawMode
const entryIcon = activeTab?.entry.icon ?? null
const emojiIcon = entryIcon && isEmoji(entryIcon) ? entryIcon : null
@@ -188,7 +192,7 @@ export function EditorContent({
onDeletePermanently={() => onDeleteNote?.(activeTab.entry.path)}
/>
)}
{activeTab?.entry.archived && breadcrumbProps.onUnarchiveNote && (
{activeTab && isArchived && breadcrumbProps.onUnarchiveNote && (
<ArchivedNoteBanner onUnarchive={() => breadcrumbProps.onUnarchiveNote!(activeTab.entry.path)} />
)}
{activeTab && isConflicted && (

View File

@@ -154,6 +154,29 @@ const mockEntries: VaultEntry[] = [
},
]
const makeEntry = (overrides: Partial<VaultEntry> = {}): VaultEntry => ({
path: '/test.md', filename: 'test.md', title: 'Test', isA: null,
aliases: [], belongsTo: [], relatedTo: [], status: null,
archived: false, trashed: false, trashedAt: null,
modifiedAt: null, createdAt: null, fileSize: 100, snippet: '', wordCount: 0,
relationships: {}, icon: null, color: null, order: null, sidebarLabel: null,
template: null, sort: null, view: null, visible: null,
outgoingLinks: [], properties: {},
...overrides,
})
const makeIndexedEntry = (i: number, overrides?: Partial<VaultEntry>): VaultEntry =>
makeEntry({
path: `/vault/note/note-${i}.md`,
filename: `note-${i}.md`,
title: `Note ${i}`,
isA: 'Note',
modifiedAt: 1700000000 - i * 60,
fileSize: 500,
snippet: `Content of note ${i}`,
...overrides,
})
describe('NoteList', () => {
it('shows empty state when no entries', () => {
render(<NoteList {...defaultFilterProps} entries={[]} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />)
@@ -348,35 +371,6 @@ describe('NoteList click behavior', () => {
})
describe('getSortComparator', () => {
const makeEntry = (overrides: Partial<VaultEntry>): VaultEntry => ({
path: '/test.md',
filename: 'test.md',
title: 'Test',
isA: null,
aliases: [],
belongsTo: [],
relatedTo: [],
status: null,
owner: null,
cadence: null,
archived: false,
trashed: false,
trashedAt: null,
modifiedAt: null,
createdAt: null,
fileSize: 100,
snippet: '',
wordCount: 0,
relationships: {},
icon: null,
color: null,
order: null,
template: null, sort: null,
outgoingLinks: [],
properties: {},
...overrides,
})
it('sorts by modified date descending', () => {
const a = makeEntry({ title: 'A', modifiedAt: 1000 })
const b = makeEntry({ title: 'B', modifiedAt: 3000 })
@@ -462,35 +456,6 @@ describe('NoteList sort controls', () => {
try { localStorage.removeItem('laputa-sort-preferences') } catch { /* noop */ }
})
const makeEntry = (overrides: Partial<VaultEntry>): VaultEntry => ({
path: '/test.md',
filename: 'test.md',
title: 'Test',
isA: null,
aliases: [],
belongsTo: [],
relatedTo: [],
status: null,
owner: null,
cadence: null,
archived: false,
trashed: false,
trashedAt: null,
modifiedAt: null,
createdAt: null,
fileSize: 100,
snippet: '',
wordCount: 0,
relationships: {},
icon: null,
color: null,
order: null,
template: null, sort: null,
outgoingLinks: [],
properties: {},
...overrides,
})
it('shows sort button in note list header for flat view', () => {
render(
<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
@@ -505,11 +470,21 @@ describe('NoteList sort controls', () => {
expect(screen.getByTestId('sort-button-Children')).toBeInTheDocument()
})
it('opens sort menu on click and shows all options', () => {
const renderListAndOpenSort = (entries: VaultEntry[] = mockEntries) => {
render(
<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
<NoteList {...defaultFilterProps} entries={entries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
fireEvent.click(screen.getByTestId('sort-button-__list__'))
}
const zamEntries = [
makeEntry({ path: '/a.md', title: 'Zebra', modifiedAt: 3000 }),
makeEntry({ path: '/b.md', title: 'Alpha', modifiedAt: 1000 }),
makeEntry({ path: '/c.md', title: 'Middle', modifiedAt: 2000 }),
]
it('opens sort menu on click and shows all options', () => {
renderListAndOpenSort()
expect(screen.getByTestId('sort-menu-__list__')).toBeInTheDocument()
expect(screen.getByTestId('sort-option-modified')).toBeInTheDocument()
expect(screen.getByTestId('sort-option-created')).toBeInTheDocument()
@@ -518,20 +493,12 @@ describe('NoteList sort controls', () => {
})
it('changes sort order when an option is selected', () => {
const entries = [
makeEntry({ path: '/a.md', title: 'Zebra', modifiedAt: 3000 }),
makeEntry({ path: '/b.md', title: 'Alpha', modifiedAt: 1000 }),
makeEntry({ path: '/c.md', title: 'Middle', modifiedAt: 2000 }),
]
render(
<NoteList {...defaultFilterProps} entries={entries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
// Default sort: by modified (Zebra first)
renderListAndOpenSort(zamEntries)
// Default sort: by modified (Zebra first) — menu is already open
let titles = screen.getAllByText(/Zebra|Alpha|Middle/).map((el) => el.textContent)
expect(titles).toEqual(['Zebra', 'Middle', 'Alpha'])
// Switch to title sort
fireEvent.click(screen.getByTestId('sort-button-__list__'))
fireEvent.click(screen.getByTestId('sort-option-title'))
// Now should be alphabetical
@@ -540,21 +507,14 @@ describe('NoteList sort controls', () => {
})
it('closes sort menu after selecting an option', () => {
render(
<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
fireEvent.click(screen.getByTestId('sort-button-__list__'))
renderListAndOpenSort()
expect(screen.getByTestId('sort-menu-__list__')).toBeInTheDocument()
fireEvent.click(screen.getByTestId('sort-option-title'))
expect(screen.queryByTestId('sort-menu-__list__')).not.toBeInTheDocument()
})
it('shows direction arrows in sort dropdown menu', () => {
render(
<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
fireEvent.click(screen.getByTestId('sort-button-__list__'))
// Each option should have asc and desc direction buttons
renderListAndOpenSort()
expect(screen.getByTestId('sort-dir-asc-modified')).toBeInTheDocument()
expect(screen.getByTestId('sort-dir-desc-modified')).toBeInTheDocument()
expect(screen.getByTestId('sort-dir-asc-title')).toBeInTheDocument()
@@ -562,20 +522,12 @@ describe('NoteList sort controls', () => {
})
it('reverses sort order when clicking direction arrow', () => {
const entries = [
makeEntry({ path: '/a.md', title: 'Zebra', modifiedAt: 3000 }),
makeEntry({ path: '/b.md', title: 'Alpha', modifiedAt: 1000 }),
makeEntry({ path: '/c.md', title: 'Middle', modifiedAt: 2000 }),
]
render(
<NoteList {...defaultFilterProps} entries={entries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
renderListAndOpenSort(zamEntries)
// Default sort: modified descending (Zebra first at 3000)
let titles = screen.getAllByText(/Zebra|Alpha|Middle/).map((el) => el.textContent)
expect(titles).toEqual(['Zebra', 'Middle', 'Alpha'])
// Click the asc arrow for modified to reverse
fireEvent.click(screen.getByTestId('sort-button-__list__'))
fireEvent.click(screen.getByTestId('sort-dir-asc-modified'))
// Now ascending: Alpha (1000) first
@@ -897,37 +849,8 @@ describe('NoteList — trash view', () => {
// --- Virtual list performance tests ---
describe('NoteList — virtual list with large datasets', () => {
const makeEntry = (i: number, overrides?: Partial<VaultEntry>): VaultEntry => ({
path: `/vault/note/note-${i}.md`,
filename: `note-${i}.md`,
title: `Note ${i}`,
isA: 'Note',
aliases: [],
belongsTo: [],
relatedTo: [],
status: null,
owner: null,
cadence: null,
archived: false,
trashed: false,
trashedAt: null,
modifiedAt: 1700000000 - i * 60,
createdAt: null,
fileSize: 500,
snippet: `Content of note ${i}`,
wordCount: 0,
relationships: {},
icon: null,
color: null,
order: null,
template: null, sort: null,
outgoingLinks: [],
properties: {},
...overrides,
})
it('renders 9000 entries without crashing', { timeout: 30000 }, () => {
const largeDataset = Array.from({ length: 9000 }, (_, i) => makeEntry(i))
const largeDataset = Array.from({ length: 9000 }, (_, i) => makeIndexedEntry(i))
const { container } = render(
<NoteList {...defaultFilterProps} entries={largeDataset} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
@@ -936,7 +859,7 @@ describe('NoteList — virtual list with large datasets', () => {
})
it('renders items from a large dataset via Virtuoso', () => {
const largeDataset = Array.from({ length: 500 }, (_, i) => makeEntry(i))
const largeDataset = Array.from({ length: 500 }, (_, i) => makeIndexedEntry(i))
render(
<NoteList {...defaultFilterProps} entries={largeDataset} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
@@ -946,9 +869,9 @@ describe('NoteList — virtual list with large datasets', () => {
it('search filters large dataset correctly', () => {
const entries = [
makeEntry(0, { title: 'Alpha Strategy' }),
...Array.from({ length: 998 }, (_, i) => makeEntry(i + 1, { title: `Filler Note ${i + 1}` })),
makeEntry(999, { title: 'Beta Strategy' }),
makeIndexedEntry(0, { title: 'Alpha Strategy' }),
...Array.from({ length: 998 }, (_, i) => makeIndexedEntry(i + 1, { title: `Filler Note ${i + 1}` })),
makeIndexedEntry(999, { title: 'Beta Strategy' }),
]
render(
<NoteList {...defaultFilterProps} entries={entries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
@@ -962,9 +885,9 @@ describe('NoteList — virtual list with large datasets', () => {
it('sorting works with large dataset', () => {
const entries = [
makeEntry(0, { title: 'Zebra', modifiedAt: 1000 }),
makeEntry(1, { title: 'Alpha', modifiedAt: 3000 }),
...Array.from({ length: 100 }, (_, i) => makeEntry(i + 2, { title: `Mid ${i}`, modifiedAt: 2000 - i })),
makeIndexedEntry(0, { title: 'Zebra', modifiedAt: 1000 }),
makeIndexedEntry(1, { title: 'Alpha', modifiedAt: 3000 }),
...Array.from({ length: 100 }, (_, i) => makeIndexedEntry(i + 2, { title: `Mid ${i}`, modifiedAt: 2000 - i })),
]
render(
<NoteList {...defaultFilterProps} entries={entries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
@@ -976,8 +899,8 @@ describe('NoteList — virtual list with large datasets', () => {
it('section group filter works with large mixed-type dataset', () => {
const entries = [
...Array.from({ length: 100 }, (_, i) => makeEntry(i, { isA: 'Project', title: `Project ${i}` })),
...Array.from({ length: 200 }, (_, i) => makeEntry(100 + i, { isA: 'Note', title: `Note ${i}` })),
...Array.from({ length: 100 }, (_, i) => makeIndexedEntry(i, { isA: 'Project', title: `Project ${i}` })),
...Array.from({ length: 200 }, (_, i) => makeIndexedEntry(100 + i, { isA: 'Note', title: `Note ${i}` })),
]
render(
<NoteList {...defaultFilterProps} entries={entries} selection={{ kind: 'sectionGroup', type: 'Project' }} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
@@ -987,7 +910,7 @@ describe('NoteList — virtual list with large datasets', () => {
})
it('selection highlighting works in virtualized list', () => {
const entries = Array.from({ length: 100 }, (_, i) => makeEntry(i))
const entries = Array.from({ length: 100 }, (_, i) => makeIndexedEntry(i))
const selected = entries[5]
render(
<NoteList {...defaultFilterProps} entries={entries} selection={allSelection} selectedNote={selected} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
@@ -997,7 +920,7 @@ describe('NoteList — virtual list with large datasets', () => {
it('click handler works on virtualized items', () => {
noopReplace.mockClear()
const entries = Array.from({ length: 100 }, (_, i) => makeEntry(i))
const entries = Array.from({ length: 100 }, (_, i) => makeIndexedEntry(i))
render(
<NoteList {...defaultFilterProps} entries={entries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />
)
@@ -1197,68 +1120,34 @@ describe('NoteList — multi-select', () => {
expect(screen.getByText('2 selected')).toBeInTheDocument()
})
it('bulk archive calls onBulkArchive and clears selection', () => {
const onBulkArchive = vi.fn()
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} onBulkArchive={onBulkArchive} />)
const selectTwoNotes = (extraProps: Record<string, unknown> = {}) => {
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} {...extraProps} />)
fireEvent.click(screen.getByText('Build Laputa App'))
fireEvent.click(screen.getByText('Facebook Ads Strategy'), { shiftKey: true })
fireEvent.click(screen.getByTestId('bulk-archive-btn'))
expect(onBulkArchive).toHaveBeenCalledWith([mockEntries[0].path, mockEntries[1].path])
expect(screen.queryByTestId('bulk-action-bar')).not.toBeInTheDocument()
})
}
it('bulk trash calls onBulkTrash and clears selection', () => {
const onBulkTrash = vi.fn()
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} onBulkTrash={onBulkTrash} />)
fireEvent.click(screen.getByText('Build Laputa App'))
fireEvent.click(screen.getByText('Facebook Ads Strategy'), { shiftKey: true })
fireEvent.click(screen.getByTestId('bulk-trash-btn'))
expect(onBulkTrash).toHaveBeenCalledWith([mockEntries[0].path, mockEntries[1].path])
it.each([
{ label: 'bulk archive via button', prop: 'onBulkArchive', trigger: () => fireEvent.click(screen.getByTestId('bulk-archive-btn')) },
{ label: 'bulk trash via button', prop: 'onBulkTrash', trigger: () => fireEvent.click(screen.getByTestId('bulk-trash-btn')) },
{ label: 'Cmd+E archives', prop: 'onBulkArchive', trigger: () => fireEvent.keyDown(window, { key: 'e', metaKey: true }) },
{ label: 'Cmd+Backspace trashes', prop: 'onBulkTrash', trigger: () => fireEvent.keyDown(window, { key: 'Backspace', metaKey: true }) },
{ label: 'Cmd+Delete trashes', prop: 'onBulkTrash', trigger: () => fireEvent.keyDown(window, { key: 'Delete', metaKey: true }) },
])('$label selected notes and clears selection', ({ prop, trigger }) => {
const handler = vi.fn()
selectTwoNotes({ [prop]: handler })
trigger()
expect(handler).toHaveBeenCalledWith([mockEntries[0].path, mockEntries[1].path])
expect(screen.queryByTestId('bulk-action-bar')).not.toBeInTheDocument()
})
it('clear button on bulk action bar clears selection', () => {
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />)
fireEvent.click(screen.getByText('Build Laputa App'))
fireEvent.click(screen.getByText('Facebook Ads Strategy'), { shiftKey: true })
selectTwoNotes()
expect(screen.getByTestId('bulk-action-bar')).toBeInTheDocument()
fireEvent.click(screen.getByTestId('bulk-clear-btn'))
expect(screen.queryByTestId('bulk-action-bar')).not.toBeInTheDocument()
expect(screen.queryByTestId('multi-selected-item')).not.toBeInTheDocument()
})
it('Cmd+E archives selected notes when multiselect is active', () => {
const onBulkArchive = vi.fn()
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} onBulkArchive={onBulkArchive} />)
fireEvent.click(screen.getByText('Build Laputa App'))
fireEvent.click(screen.getByText('Facebook Ads Strategy'), { shiftKey: true })
expect(screen.getByTestId('bulk-action-bar')).toBeInTheDocument()
fireEvent.keyDown(window, { key: 'e', metaKey: true })
expect(onBulkArchive).toHaveBeenCalledWith([mockEntries[0].path, mockEntries[1].path])
expect(screen.queryByTestId('bulk-action-bar')).not.toBeInTheDocument()
})
it('Cmd+Backspace trashes selected notes when multiselect is active', () => {
const onBulkTrash = vi.fn()
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} onBulkTrash={onBulkTrash} />)
fireEvent.click(screen.getByText('Build Laputa App'))
fireEvent.click(screen.getByText('Facebook Ads Strategy'), { shiftKey: true })
expect(screen.getByTestId('bulk-action-bar')).toBeInTheDocument()
fireEvent.keyDown(window, { key: 'Backspace', metaKey: true })
expect(onBulkTrash).toHaveBeenCalledWith([mockEntries[0].path, mockEntries[1].path])
expect(screen.queryByTestId('bulk-action-bar')).not.toBeInTheDocument()
})
it('Cmd+Delete trashes selected notes when multiselect is active', () => {
const onBulkTrash = vi.fn()
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} onBulkTrash={onBulkTrash} />)
fireEvent.click(screen.getByText('Build Laputa App'))
fireEvent.click(screen.getByText('Facebook Ads Strategy'), { shiftKey: true })
fireEvent.keyDown(window, { key: 'Delete', metaKey: true })
expect(onBulkTrash).toHaveBeenCalledWith([mockEntries[0].path, mockEntries[1].path])
expect(screen.queryByTestId('bulk-action-bar')).not.toBeInTheDocument()
})
it('no bulk action bar when nothing is selected', () => {
render(<NoteList {...defaultFilterProps} entries={mockEntries} selection={allSelection} selectedNote={null} onSelectNote={noopSelect} onReplaceActiveTab={noopReplace} onCreateNote={vi.fn()} />)
expect(screen.queryByTestId('bulk-action-bar')).not.toBeInTheDocument()
@@ -1360,17 +1249,6 @@ describe('NoteList — traffic light padding when sidebar collapsed', () => {
})
describe('countByFilter', () => {
const makeEntry = (overrides: Partial<VaultEntry>): VaultEntry => ({
path: '/test.md', filename: 'test.md', title: 'Test', isA: null,
aliases: [], belongsTo: [], relatedTo: [], status: null,
archived: false, trashed: false, trashedAt: null,
modifiedAt: null, createdAt: null, fileSize: 100, snippet: '', wordCount: 0,
relationships: {}, icon: null, color: null, order: null, sidebarLabel: null,
template: null, sort: null, view: null, visible: null,
outgoingLinks: [], properties: {},
...overrides,
})
it('counts open, archived, and trashed notes per type', () => {
const entries = [
makeEntry({ path: '/1.md', isA: 'Project' }),
@@ -1397,17 +1275,6 @@ describe('countByFilter', () => {
})
describe('NoteList — filter pills', () => {
const makeEntry = (overrides: Partial<VaultEntry>): VaultEntry => ({
path: '/test.md', filename: 'test.md', title: 'Test', isA: null,
aliases: [], belongsTo: [], relatedTo: [], status: null,
archived: false, trashed: false, trashedAt: null,
modifiedAt: 1700000000, createdAt: null, fileSize: 100, snippet: '', wordCount: 0,
relationships: {}, icon: null, color: null, order: null, sidebarLabel: null,
template: null, sort: null, view: null, visible: null,
outgoingLinks: [], properties: {},
...overrides,
})
const projectEntries = [
makeEntry({ path: '/p1.md', title: 'Open Project 1', isA: 'Project' }),
makeEntry({ path: '/p2.md', title: 'Open Project 2', isA: 'Project' }),
@@ -1484,17 +1351,6 @@ describe('NoteList — filter pills', () => {
})
describe('NoteList — filterEntries with subFilter', () => {
const makeEntry = (overrides: Partial<VaultEntry>): VaultEntry => ({
path: '/test.md', filename: 'test.md', title: 'Test', isA: null,
aliases: [], belongsTo: [], relatedTo: [], status: null,
archived: false, trashed: false, trashedAt: null,
modifiedAt: null, createdAt: null, fileSize: 100, snippet: '', wordCount: 0,
relationships: {}, icon: null, color: null, order: null, sidebarLabel: null,
template: null, sort: null, view: null, visible: null,
outgoingLinks: [], properties: {},
...overrides,
})
const entries = [
makeEntry({ path: '/1.md', title: 'Active', isA: 'Project' }),
makeEntry({ path: '/2.md', title: 'Archived', isA: 'Project', archived: true }),

View File

@@ -1038,4 +1038,24 @@ describe('Sidebar', () => {
const mondaySections = screen.getAllByText(/Monday Ideas/i)
expect(mondaySections).toHaveLength(1)
})
it('renders Inbox as the first item in the top nav', () => {
render(<Sidebar entries={[]} selection={defaultSelection} onSelect={() => {}} inboxCount={5} />)
const topNav = screen.getByTestId('sidebar-top-nav')
const items = topNav.children
expect(items[0].textContent).toContain('Inbox')
expect(items[1].textContent).toContain('All Notes')
})
it('displays inbox count badge', () => {
render(<Sidebar entries={[]} selection={defaultSelection} onSelect={() => {}} inboxCount={12} />)
expect(screen.getByText('12')).toBeInTheDocument()
})
it('calls onSelect with inbox filter when clicking Inbox', () => {
const onSelect = vi.fn()
render(<Sidebar entries={[]} selection={defaultSelection} onSelect={onSelect} inboxCount={3} />)
fireEvent.click(screen.getByText('Inbox'))
expect(onSelect).toHaveBeenCalledWith({ kind: 'filter', filter: 'inbox' })
})
})

View File

@@ -306,10 +306,10 @@ export const Sidebar = memo(function Sidebar({
<nav className="flex-1 overflow-y-auto">
{/* Top nav */}
<div className="border-b border-border" data-testid="sidebar-top-nav" style={{ padding: '4px 6px' }}>
<NavItem icon={Tray} label="Inbox" count={inboxCount} isActive={isSelectionActive(selection, { kind: 'filter', filter: 'inbox' })} badgeClassName="text-muted-foreground" badgeStyle={{ background: 'var(--muted)' }} onClick={() => onSelect({ kind: 'filter', filter: 'inbox' })} />
<NavItem icon={FileText} label="All Notes" count={activeCount} isActive={isSelectionActive(selection, { kind: 'filter', filter: 'all' })} badgeClassName="bg-primary text-primary-foreground" onClick={() => onSelect({ kind: 'filter', filter: 'all' })} />
<NavItem icon={Archive} label="Archive" count={archivedCount} isActive={isSelectionActive(selection, { kind: 'filter', filter: 'archived' })} badgeClassName="text-muted-foreground" badgeStyle={{ background: 'var(--muted)' }} onClick={() => onSelect({ kind: 'filter', filter: 'archived' })} />
<NavItem icon={Trash} label="Trash" count={trashedCount} isActive={isSelectionActive(selection, { kind: 'filter', filter: 'trash' })} activeClassName="bg-destructive/10 text-destructive" badgeClassName="text-muted-foreground" badgeStyle={{ background: 'var(--muted)' }} onClick={() => onSelect({ kind: 'filter', filter: 'trash' })} />
<NavItem icon={Tray} label="Inbox" count={inboxCount} isActive={isSelectionActive(selection, { kind: 'filter', filter: 'inbox' })} badgeClassName="text-muted-foreground" badgeStyle={{ background: 'var(--muted)' }} onClick={() => onSelect({ kind: 'filter', filter: 'inbox' })} />
</div>
{/* Sections header + visibility popover */}

View File

@@ -1,6 +1,7 @@
import { type ComponentType, useState, useEffect, useRef } from 'react'
import type { VaultEntry, SidebarSelection } from '../types'
import { cn } from '@/lib/utils'
import { isEmoji } from '../utils/emoji'
import { ChevronRight, ChevronDown, Plus } from 'lucide-react'
import { getTypeColor, getTypeLightColor } from '../utils/typeColors'
import { type IconProps } from '@phosphor-icons/react'
@@ -148,7 +149,7 @@ function SectionChildList({ items, selection, sectionColor, sectionLightColor, o
const active = isSelectionActive(selection, sel)
return (
<SectionChildItem
key={entry.path} title={entry.title} isActive={active}
key={entry.path} title={entry.title} icon={entry.icon} isActive={active}
sectionColor={active ? sectionColor : undefined}
sectionLightColor={active ? sectionLightColor : undefined}
onClick={() => { onSelect(sel); onSelectNote?.(entry) }}
@@ -237,8 +238,8 @@ function SectionHeader({ label, type, Icon, sectionColor, isCollapsed, isActive,
)
}
function SectionChildItem({ title, isActive, sectionColor, sectionLightColor, onClick }: {
title: string; isActive: boolean
function SectionChildItem({ title, icon, isActive, sectionColor, sectionLightColor, onClick }: {
title: string; icon?: string | null; isActive: boolean
sectionColor?: string; sectionLightColor?: string
onClick: () => void
}) {
@@ -248,7 +249,7 @@ function SectionChildItem({ title, isActive, sectionColor, sectionLightColor, on
style={{ padding: '4px 16px 4px 28px', ...(isActive && { backgroundColor: sectionLightColor, color: sectionColor }) }}
onClick={onClick}
>
{title}
{icon && isEmoji(icon) && <span className="mr-1">{icon}</span>}{title}
</div>
)
}

View File

@@ -22,17 +22,19 @@ function TypeSelectorItem({ type, typeColorKeys, typeIconKeys }: {
function ReadOnlyType({ isA, customColorKey, onNavigate }: { isA?: string | null; customColorKey?: string | null; onNavigate?: (target: string) => void }) {
if (!isA) return null
return (
<div className="flex min-w-0 items-center justify-between gap-2 px-1.5">
<div className="grid min-w-0 grid-cols-2 items-center gap-2 px-1.5">
<span className="font-mono-overline shrink-0 text-muted-foreground">Type</span>
{onNavigate ? (
<button
className="min-w-0 truncate border-none text-right cursor-pointer hover:opacity-80"
style={{ background: getTypeLightColor(isA, customColorKey), color: getTypeColor(isA, customColorKey), borderRadius: 6, padding: '2px 8px', fontSize: 12, fontWeight: 500 }}
onClick={() => onNavigate(isA.toLowerCase())} title={isA}
>{isA}</button>
) : (
<span className="text-right text-[12px] text-secondary-foreground">{isA}</span>
)}
<div className="min-w-0">
{onNavigate ? (
<button
className="min-w-0 max-w-full truncate border-none cursor-pointer ring-inset hover:ring-1 hover:ring-current"
style={{ background: getTypeLightColor(isA, customColorKey), color: getTypeColor(isA, customColorKey), borderRadius: 6, padding: '2px 8px', fontSize: 12, fontWeight: 500 }}
onClick={() => onNavigate(isA.toLowerCase())} title={isA}
>{isA}</button>
) : (
<span className="text-[12px] text-secondary-foreground">{isA}</span>
)}
</div>
</div>
)
}
@@ -55,23 +57,24 @@ export function TypeSelector({ isA, customColorKey, availableTypes, typeColorKey
const typeLightColor = isA ? getTypeLightColor(isA, typeColorKeys[isA] ?? customColorKey) : undefined
return (
<div className="flex min-w-0 items-center justify-between gap-2 px-1.5" data-testid="type-selector">
<div className="grid min-w-0 grid-cols-2 items-center gap-2 px-1.5" data-testid="type-selector">
<span className="font-mono-overline shrink-0 text-muted-foreground">Type</span>
<Select value={currentValue} onValueChange={v => onUpdateProperty('type', v === TYPE_NONE ? null : v)}>
<SelectTrigger
size="sm"
className={`h-auto shrink-0 gap-1 border-none shadow-none [&_svg]:text-current ring-inset${isA ? ' hover:ring-1 hover:ring-current' : ' bg-muted hover:opacity-80'}`}
style={{
background: typeLightColor ?? undefined,
color: typeColor ?? undefined,
borderRadius: 6,
padding: '4px 8px',
fontSize: 12,
fontWeight: 500,
}}
>
<SelectValue placeholder="None" />
</SelectTrigger>
<div className="min-w-0">
<Select value={currentValue} onValueChange={v => onUpdateProperty('type', v === TYPE_NONE ? null : v)}>
<SelectTrigger
size="sm"
className={`h-auto max-w-full gap-1 border-none shadow-none [&_svg]:text-current ring-inset${isA ? ' hover:ring-1 hover:ring-current' : ' bg-muted hover:opacity-80'}`}
style={{
background: typeLightColor ?? undefined,
color: typeColor ?? undefined,
borderRadius: 6,
padding: '4px 8px',
fontSize: 12,
fontWeight: 500,
}}
>
<SelectValue placeholder="None" />
</SelectTrigger>
<SelectContent position="popper" side="left">
<SelectItem value={TYPE_NONE}>None</SelectItem>
<SelectSeparator />
@@ -81,7 +84,8 @@ export function TypeSelector({ isA, customColorKey, availableTypes, typeColorKey
</SelectItem>
))}
</SelectContent>
</Select>
</Select>
</div>
</div>
)
}

View File

@@ -15,14 +15,14 @@ const PILLS: { value: NoteListFilter; label: string }[] = [
function FilterPillsInner({ active, counts, onChange }: FilterPillsProps) {
return (
<div className="flex h-[45px] shrink-0 items-center gap-1 border-b border-border px-4" data-testid="filter-pills">
<div className="flex h-auto min-h-[45px] shrink-0 flex-wrap items-center gap-1 border-b border-border px-4 py-1.5" data-testid="filter-pills">
{PILLS.map(({ value, label }) => (
<button
key={value}
type="button"
role="tab"
aria-selected={active === value}
className={`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${
className={`inline-flex whitespace-nowrap items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${
active === value
? 'border-foreground/20 bg-foreground/10 text-foreground'
: 'border-transparent text-muted-foreground hover:bg-muted hover:text-foreground'

View File

@@ -16,14 +16,14 @@ const PILLS: { value: InboxPeriod; label: string }[] = [
function InboxFilterPillsInner({ active, counts, onChange }: InboxFilterPillsProps) {
return (
<div className="flex h-[45px] shrink-0 items-center gap-1 border-b border-border px-4" data-testid="inbox-filter-pills">
<div className="flex h-auto min-h-[45px] shrink-0 flex-wrap items-center gap-1 border-b border-border px-4 py-1.5" data-testid="inbox-filter-pills">
{PILLS.map(({ value, label }) => (
<button
key={value}
type="button"
role="tab"
aria-selected={active === value}
className={`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${
className={`inline-flex whitespace-nowrap items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[12px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${
active === value
? 'border-foreground/20 bg-foreground/10 text-foreground'
: 'border-transparent text-muted-foreground hover:bg-muted hover:text-foreground'

View File

@@ -56,7 +56,10 @@ export function useNoteListData({ entries, selection, query, listSort, listDirec
const searchedGroups = useMemo(() => {
if (!isEntityView) return []
const groups = buildRelationshipGroups(selection.entry, entries)
// Look up the fresh entry from the entries array to pick up relationship
// updates that happened after the selection was captured.
const freshEntry = entries.find((e) => e.path === selection.entry.path) ?? selection.entry
const groups = buildRelationshipGroups(freshEntry, entries)
return filterGroupsByQuery(groups, query)
}, [isEntityView, selection, entries, query])

View File

@@ -13,12 +13,38 @@ const ENTRY_DELETE_MAP: Record<string, Partial<VaultEntry>> = {
template: { template: null }, sort: { sort: null }, visible: { visible: null },
}
/** Check if a string contains a wikilink pattern `[[...]]`. */
function isWikilink(s: string): boolean {
return s.startsWith('[[') && s.includes(']]')
}
/** Extract wikilink strings from a FrontmatterValue. Returns empty array if none. */
function extractWikilinks(value: FrontmatterValue): string[] {
if (typeof value === 'string') return isWikilink(value) ? [value] : []
if (Array.isArray(value)) return value.filter((v): v is string => typeof v === 'string' && isWikilink(v))
return []
}
/**
* Relationship patch: a partial update to merge into `entry.relationships`.
* Keys map to their new ref arrays. A `null` value means "remove this key".
*/
export type RelationshipPatch = Record<string, string[] | null>
export interface EntryPatchResult {
patch: Partial<VaultEntry>
relationshipPatch: RelationshipPatch | null
}
/** Map a frontmatter key+value to the corresponding VaultEntry field(s). */
export function frontmatterToEntryPatch(
op: 'update' | 'delete', key: string, value?: FrontmatterValue,
): Partial<VaultEntry> {
): EntryPatchResult {
const k = key.toLowerCase().replace(/\s+/g, '_')
if (op === 'delete') return ENTRY_DELETE_MAP[k] ?? {}
if (op === 'delete') {
const relPatch: RelationshipPatch = { [key]: null }
return { patch: ENTRY_DELETE_MAP[k] ?? {}, relationshipPatch: relPatch }
}
const str = value != null ? String(value) : null
const arr = Array.isArray(value) ? value.map(String) : []
const updates: Record<string, Partial<VaultEntry>> = {
@@ -32,7 +58,11 @@ export function frontmatterToEntryPatch(
view: { view: str },
visible: { visible: value === false ? false : null },
}
return updates[k] ?? {}
// Also update the relationships map for wikilink-containing values
const wikilinks = value != null ? extractWikilinks(value) : []
const relationshipPatch: RelationshipPatch | null =
wikilinks.length > 0 ? { [key]: wikilinks } : null
return { patch: updates[k] ?? {}, relationshipPatch }
}
async function invokeFrontmatter(command: string, args: Record<string, unknown>): Promise<string> {
@@ -65,18 +95,42 @@ export interface FrontmatterOpOptions {
silent?: boolean
}
/** Apply a relationship patch by merging into the existing relationships map. */
export function applyRelationshipPatch(
existing: Record<string, string[]>, relPatch: RelationshipPatch,
): Record<string, string[]> {
const merged = { ...existing }
for (const [k, v] of Object.entries(relPatch)) {
if (v === null) delete merged[k]
else merged[k] = v
}
return merged
}
/** Run a frontmatter update/delete and apply the result to state.
* Returns the new file content on success, or undefined on failure. */
export async function runFrontmatterAndApply(
op: 'update' | 'delete', path: string, key: string, value: FrontmatterValue | undefined,
callbacks: { updateTab: (p: string, c: string) => void; updateEntry: (p: string, patch: Partial<VaultEntry>) => void; toast: (m: string | null) => void },
callbacks: {
updateTab: (p: string, c: string) => void
updateEntry: (p: string, patch: Partial<VaultEntry>) => void
toast: (m: string | null) => void
getEntry?: (p: string) => VaultEntry | undefined
},
options?: FrontmatterOpOptions,
): Promise<string | undefined> {
try {
const newContent = await executeFrontmatterOp(op, path, key, value)
callbacks.updateTab(path, newContent)
const patch = frontmatterToEntryPatch(op, key, value)
if (Object.keys(patch).length > 0) callbacks.updateEntry(path, patch)
const { patch, relationshipPatch } = frontmatterToEntryPatch(op, key, value)
const fullPatch = { ...patch }
if (relationshipPatch && callbacks.getEntry) {
const current = callbacks.getEntry(path)
if (current) {
fullPatch.relationships = applyRelationshipPatch(current.relationships, relationshipPatch)
}
}
if (Object.keys(fullPatch).length > 0) callbacks.updateEntry(path, fullPatch)
if (!options?.silent) callbacks.toast(op === 'update' ? 'Property updated' : 'Property deleted')
return newContent
} catch (err) {

View File

@@ -107,20 +107,32 @@ describe('useAutoSync', () => {
})
})
it('pulls on window focus', async () => {
it('pulls on window focus after cooldown expires', async () => {
const now = vi.spyOn(Date, 'now')
let clock = 1000
now.mockImplementation(() => clock)
renderSync()
await waitFor(() => {
expect(mockInvokeFn).toHaveBeenCalledWith('git_pull', { vaultPath: '/Users/luca/Laputa' })
})
// Focus within cooldown — should NOT trigger pull
mockInvokeFn.mockClear()
await act(async () => {
window.dispatchEvent(new Event('focus'))
})
clock += 5_000 // only 5s later
await act(async () => { window.dispatchEvent(new Event('focus')) })
const pullCalls = mockInvokeFn.mock.calls.filter((c: unknown[]) => c[0] === 'git_pull')
expect(pullCalls).toHaveLength(0)
// Focus after cooldown — should trigger pull
clock += 30_000 // 30s later
await act(async () => { window.dispatchEvent(new Event('focus')) })
await waitFor(() => {
expect(mockInvokeFn).toHaveBeenCalledWith('git_pull', { vaultPath: '/Users/luca/Laputa' })
})
now.mockRestore()
})
it('triggerSync allows manual pull', async () => {

View File

@@ -195,9 +195,16 @@ export function useAutoSync({
refreshRemoteStatus()
}, [checkExistingConflicts, performPull, refreshRemoteStatus])
// Pull on window focus (app foreground)
// Pull on window focus (app foreground) — with cooldown to avoid repeated pulls
const lastPullTimeRef = useRef(0)
useEffect(() => {
const handleFocus = () => { performPull() }
const FOCUS_COOLDOWN_MS = 30_000
const handleFocus = () => {
const now = Date.now()
if (now - lastPullTimeRef.current < FOCUS_COOLDOWN_MS) return
lastPullTimeRef.current = now
performPull()
}
window.addEventListener('focus', handleFocus)
return () => window.removeEventListener('focus', handleFocus)
}, [performPull])

View File

@@ -19,7 +19,7 @@ import {
resolveTemplate,
} from './useNoteCreation'
import { needsRenameOnSave } from './useNoteRename'
import { frontmatterToEntryPatch } from './frontmatterOps'
import { frontmatterToEntryPatch, applyRelationshipPatch } from './frontmatterOps'
import { useNoteActions } from './useNoteActions'
import type { NoteActionsConfig } from './useNoteActions'
@@ -345,25 +345,45 @@ describe('frontmatterToEntryPatch', () => {
] as [string, unknown, Partial<VaultEntry>][])(
'maps %s update to correct entry field',
(key, value, expected) => {
expect(frontmatterToEntryPatch('update', key, value as never)).toEqual(expected)
expect(frontmatterToEntryPatch('update', key, value as never).patch).toEqual(expected)
},
)
it('maps aliases update with array value', () => {
expect(frontmatterToEntryPatch('update', 'aliases', ['A', 'B'])).toEqual({ aliases: ['A', 'B'] })
expect(frontmatterToEntryPatch('update', 'aliases', ['A', 'B']).patch).toEqual({ aliases: ['A', 'B'] })
})
it('maps belongs_to update with array value', () => {
expect(frontmatterToEntryPatch('update', 'belongs_to', ['[[parent]]'])).toEqual({ belongsTo: ['[[parent]]'] })
const result = frontmatterToEntryPatch('update', 'belongs_to', ['[[parent]]'])
expect(result.patch).toEqual({ belongsTo: ['[[parent]]'] })
// Also produces a relationship patch for the wikilink
expect(result.relationshipPatch).toEqual({ 'belongs_to': ['[[parent]]'] })
})
it('handles case-insensitive keys with spaces (e.g. "Is A", "Belongs to")', () => {
expect(frontmatterToEntryPatch('update', 'Is A', 'Experiment')).toEqual({ isA: 'Experiment' })
expect(frontmatterToEntryPatch('update', 'Belongs to', ['[[x]]'])).toEqual({ belongsTo: ['[[x]]'] })
expect(frontmatterToEntryPatch('update', 'Is A', 'Experiment').patch).toEqual({ isA: 'Experiment' })
const result = frontmatterToEntryPatch('update', 'Belongs to', ['[[x]]'])
expect(result.patch).toEqual({ belongsTo: ['[[x]]'] })
expect(result.relationshipPatch).toEqual({ 'Belongs to': ['[[x]]'] })
})
it('returns empty object for unknown keys', () => {
expect(frontmatterToEntryPatch('update', 'custom_field', 'value')).toEqual({})
it('returns empty patch for unknown non-wikilink keys', () => {
const result = frontmatterToEntryPatch('update', 'custom_field', 'value')
expect(result.patch).toEqual({})
// Non-wikilink value → no relationship change
expect(result.relationshipPatch).toBeNull()
})
it('produces relationship patch for wikilink values on unknown keys', () => {
const result = frontmatterToEntryPatch('update', 'Notes', ['[[note-a]]', '[[note-b|Note B]]'])
expect(result.patch).toEqual({})
expect(result.relationshipPatch).toEqual({ Notes: ['[[note-a]]', '[[note-b|Note B]]'] })
})
it('produces relationship patch for single wikilink string', () => {
const result = frontmatterToEntryPatch('update', 'Owner', '[[person/alice]]')
expect(result.patch).toEqual({})
expect(result.relationshipPatch).toEqual({ Owner: ['[[person/alice]]'] })
})
it.each([
@@ -377,12 +397,46 @@ describe('frontmatterToEntryPatch', () => {
] as [string, Partial<VaultEntry>][])(
'maps delete of %s to null/default',
(key, expected) => {
expect(frontmatterToEntryPatch('delete', key)).toEqual(expected)
expect(frontmatterToEntryPatch('delete', key).patch).toEqual(expected)
},
)
it('returns empty object for unknown key on delete', () => {
expect(frontmatterToEntryPatch('delete', 'unknown_key')).toEqual({})
it('returns empty patch for unknown key on delete, with relationship removal', () => {
const result = frontmatterToEntryPatch('delete', 'unknown_key')
expect(result.patch).toEqual({})
expect(result.relationshipPatch).toEqual({ unknown_key: null })
})
it('delete of known key also produces relationship removal', () => {
const result = frontmatterToEntryPatch('delete', 'status')
expect(result.patch).toEqual({ status: null })
expect(result.relationshipPatch).toEqual({ status: null })
})
})
describe('applyRelationshipPatch', () => {
it('adds new relationship key', () => {
const existing = { 'Belongs to': ['[[eng]]'] }
const result = applyRelationshipPatch(existing, { Notes: ['[[note-a]]', '[[note-b]]'] })
expect(result).toEqual({ 'Belongs to': ['[[eng]]'], Notes: ['[[note-a]]', '[[note-b]]'] })
})
it('overwrites existing relationship key', () => {
const existing = { Notes: ['[[old]]'] }
const result = applyRelationshipPatch(existing, { Notes: ['[[new-a]]', '[[new-b]]'] })
expect(result).toEqual({ Notes: ['[[new-a]]', '[[new-b]]'] })
})
it('removes relationship key when value is null', () => {
const existing = { Notes: ['[[a]]'], Owner: ['[[alice]]'] }
const result = applyRelationshipPatch(existing, { Notes: null })
expect(result).toEqual({ Owner: ['[[alice]]'] })
})
it('does not mutate the original map', () => {
const existing = { Notes: ['[[a]]'] }
applyRelationshipPatch(existing, { Notes: ['[[b]]'] })
expect(existing).toEqual({ Notes: ['[[a]]'] })
})
})

View File

@@ -117,8 +117,8 @@ export function useNoteActions(config: NoteActionsConfig) {
const runFrontmatterOp = useCallback(
(op: 'update' | 'delete', path: string, key: string, value?: FrontmatterValue, options?: FrontmatterOpOptions) =>
runFrontmatterAndApply(op, path, key, value, { updateTab: updateTabContent, updateEntry, toast: setToastMessage }, options),
[updateTabContent, updateEntry, setToastMessage],
runFrontmatterAndApply(op, path, key, value, { updateTab: updateTabContent, updateEntry, toast: setToastMessage, getEntry: (p) => entries.find((e) => e.path === p) }, options),
[updateTabContent, updateEntry, setToastMessage, entries],
)
return {

View File

@@ -579,4 +579,32 @@ background: "#FF0000"
await new Promise(r => setTimeout(r, 50))
expect(mockInvokeFn).not.toHaveBeenCalledWith('ensure_vault_themes', expect.anything())
})
it('skips theme reload on focus within 30s cooldown', async () => {
const now = vi.spyOn(Date, 'now')
let clock = 1000
now.mockImplementation(() => clock)
renderHook(() => useThemeManager('/vault', entries, allContent))
await waitFor(() => {
expect(mockInvokeFn).toHaveBeenCalledWith('get_vault_settings', { vaultPath: '/vault' })
})
mockInvokeFn.mockClear()
// Focus within cooldown — should NOT reload settings
clock += 5_000
await act(async () => { window.dispatchEvent(new Event('focus')) })
const settingsCalls = mockInvokeFn.mock.calls.filter((c: unknown[]) => c[0] === 'get_vault_settings')
expect(settingsCalls).toHaveLength(0)
// Focus after cooldown — should reload
clock += 30_000
await act(async () => { window.dispatchEvent(new Event('focus')) })
await waitFor(() => {
expect(mockInvokeFn).toHaveBeenCalledWith('get_vault_settings', { vaultPath: '/vault' })
})
now.mockRestore()
})
})

View File

@@ -79,15 +79,31 @@ function clearColorScheme(): void {
delete root.dataset.themeMode
}
const THEME_STYLE_ID = 'laputa-theme-vars'
function getOrCreateThemeStyle(): HTMLStyleElement {
let el = document.getElementById(THEME_STYLE_ID) as HTMLStyleElement | null
if (!el) {
el = document.createElement('style')
el.id = THEME_STYLE_ID
document.head.appendChild(el)
}
return el
}
function applyVarsToDom(vars: Record<string, string>): void {
const root = document.documentElement
for (const [key, value] of Object.entries(vars)) {
root.style.setProperty(key, value)
}
updateColorScheme(vars)
// Force WebKit to recalculate ::before/::after pseudo-element styles
// when CSS custom properties change (WKWebView doesn't auto-invalidate).
void root.offsetHeight
// WKWebView doesn't invalidate ::before/::after pseudo-element styles when
// CSS custom properties change via inline styles alone — `void offsetHeight`
// triggers layout reflow but not style recalculation on pseudo-elements.
// Replacing a <style> element's content forces a full style tree invalidation
// that covers pseudo-elements using var() references (e.g. bullet size/color).
const css = Object.entries(vars).map(([k, v]) => `${k}:${v}`).join(';')
getOrCreateThemeStyle().textContent = `:root{${css}}`
}
function clearVarsFromDom(vars: Record<string, string>): void {
@@ -95,6 +111,7 @@ function clearVarsFromDom(vars: Record<string, string>): void {
for (const key of Object.keys(vars)) {
root.style.removeProperty(key)
}
getOrCreateThemeStyle().textContent = ''
clearColorScheme()
}
@@ -146,9 +163,17 @@ function useThemeSetting(vaultPath: string | null) {
// eslint-disable-next-line react-hooks/set-state-in-effect -- async fn; setState runs after await
useEffect(() => { load() }, [load])
const lastLoadRef = useRef(0)
useEffect(() => {
window.addEventListener('focus', load)
return () => window.removeEventListener('focus', load)
const FOCUS_COOLDOWN_MS = 30_000
const handleFocus = () => {
const now = Date.now()
if (now - lastLoadRef.current < FOCUS_COOLDOWN_MS) return
lastLoadRef.current = now
load()
}
window.addEventListener('focus', handleFocus)
return () => window.removeEventListener('focus', handleFocus)
}, [load])
return { activeThemeId, setActiveThemeId, reload: load }
@@ -205,11 +230,36 @@ function useThemeApplier(
return { clearDom, isDark }
}
/** Deactivate the theme and persist `null` to vault settings. */
function deactivateTheme(
vaultPath: string | null,
clearTheme: () => void,
setActiveThemeId: (id: string | null) => void,
) {
clearTheme()
setActiveThemeId(null)
if (vaultPath) tauriCall('set_active_theme', { vaultPath, themeId: null }).catch(() => {})
}
/** True when the active theme should be cleared (stale, trashed, or archived). */
function shouldDeactivate(
activeThemeId: string | null,
themes: ThemeFile[],
entries: VaultEntry[],
userSetId: string | null,
): boolean {
if (!activeThemeId) return false
// Stale ID from old theme system — skip IDs just set by user action
if (themes.length > 0 && activeThemeId !== userSetId && !themes.some(t => t.id === activeThemeId)) return true
// Trashed or archived
const entry = entries.find(e => e.path === activeThemeId)
return !!entry && isEntryRemoved(entry)
}
export function useThemeManager(
vaultPath: string | null,
entries: VaultEntry[],
): ThemeManager {
// Ensure default theme files exist on vault open (creates theme/ dir + defaults if missing)
useEffect(() => {
if (vaultPath) tauriCall('ensure_vault_themes', { vaultPath }).catch(() => {})
}, [vaultPath])
@@ -217,14 +267,10 @@ export function useThemeManager(
const { activeThemeId, setActiveThemeId, reload } = useThemeSetting(vaultPath)
const [cachedThemeContent, setCachedThemeContent] = useState<string | undefined>(undefined)
// Clear cached content when theme changes — useThemeApplier will fetch from disk
// eslint-disable-next-line react-hooks/set-state-in-effect
useEffect(() => { setCachedThemeContent(undefined) }, [activeThemeId])
const { clearDom: clearTheme, isDark } = useThemeApplier(activeThemeId, cachedThemeContent)
// Track IDs set by user actions (switchTheme/createTheme) so the stale-ID
// cleanup doesn't clear a newly-created theme that isn't in entries yet.
const userSetIdRef = useRef<string | null>(null)
const themes = useMemo(
@@ -239,30 +285,12 @@ export function useThemeManager(
[themes, activeThemeId],
)
// If active theme ID doesn't match any known theme (e.g. stale ID from old
// JSON-based theme system), clear it so the app doesn't try to load a
// non-existent path. Skip IDs just set by switchTheme/createTheme — the
// entry may not have appeared in `entries` yet.
// Deactivate stale, trashed, or archived theme
useEffect(() => {
if (!activeThemeId || themes.length === 0) return
if (activeThemeId === userSetIdRef.current) return
const isKnown = themes.some(t => t.id === activeThemeId)
if (!isKnown) {
clearTheme()
setActiveThemeId(null)
if (vaultPath) tauriCall('set_active_theme', { vaultPath, themeId: null }).catch(() => {})
if (shouldDeactivate(activeThemeId, themes, entries, userSetIdRef.current)) {
deactivateTheme(vaultPath, clearTheme, setActiveThemeId)
}
}, [activeThemeId, themes, clearTheme, vaultPath, setActiveThemeId])
// If active theme is trashed or archived: clear CSS vars and fall back to no theme
useEffect(() => {
if (!activeThemeId) return
const entry = entries.find(e => e.path === activeThemeId)
if (!entry || !isEntryRemoved(entry)) return
clearTheme()
setActiveThemeId(null)
if (vaultPath) tauriCall('set_active_theme', { vaultPath, themeId: null }).catch(() => {})
}, [entries, activeThemeId, clearTheme, vaultPath, setActiveThemeId])
}, [activeThemeId, themes, entries, clearTheme, vaultPath, setActiveThemeId])
const switchTheme = useCallback(async (themeId: string) => {
if (!vaultPath) return
@@ -294,9 +322,7 @@ export function useThemeManager(
if (!activeThemeId) return
try {
const newContent = await tauriCall<string>('update_frontmatter', {
path: activeThemeId,
key,
value,
path: activeThemeId, key, value,
})
setCachedThemeContent(newContent)
} catch (err) { console.error('Failed to update theme property:', err) }

View File

@@ -155,7 +155,7 @@ export interface VaultSettings {
theme: string | null
}
/** Vault-wide UI configuration stored in config/ui.config.md. */
/** Vault-wide UI configuration stored in ui.config.md at vault root. */
export interface VaultConfig {
zoom: number | null
view_mode: string | null

View File

@@ -324,6 +324,84 @@ describe('buildRelationshipGroups', () => {
const groups = buildRelationshipGroups(entity, [entity, linker])
expect(groups.find((g) => g.label === 'Backlinks')!.entries[0].title).toBe('Linker')
})
it('resolves all entries in a large Notes relationship (regression: No Code)', () => {
// Simulates the No Code topic note with 32 Notes, 2 Referred by Data, 1 Belongs to
const noteRefs = [
'8020', 'airdev-build-hub', 'airdev-leader', 'budibase', 'bullet-launch',
'canvas', 'chameleon', 'felt', 'flutterflow', 'framer-ai',
'jumpstart', 'mailparser', 'make', 'michele-sampieri', 'n8n-a',
'n8n-ai', 'nocodey', 'outseta', 'lemon-squeezy', 'retool',
'rise-no-code', 'scene', 'scrapingbee', 'softr', 'superblocks',
'superwall', 'tails', 'supabase', 'varun-anand', 'xano',
'directus', 'framer-design',
]
const noteEntries = noteRefs.map((slug, i) => makeEntry({
path: `/Laputa/${slug}.md`, filename: `${slug}.md`, title: `Title ${slug}`,
modifiedAt: 1700000000 - i * 100,
}))
const engineering = makeEntry({
path: '/Laputa/engineering.md', filename: 'engineering.md', title: 'Engineering',
modifiedAt: 1700000000,
})
const entity = makeEntry({
path: '/Laputa/no-code.md', filename: 'no-code.md', title: 'No Code',
isA: 'Topic',
relationships: {
'Belongs to': ['[[engineering|Engineering]]'],
Notes: noteRefs.map((slug) => `[[${slug}|Title ${slug}]]`),
'Referred by Data': ['[[michele-sampieri|Michele Sampieri]]', '[[varun-anand|Varun Anand]]'],
},
})
const allEntries = [entity, engineering, ...noteEntries]
const groups = buildRelationshipGroups(entity, allEntries)
const belongsGroup = groups.find((g) => g.label === 'Belongs to')
expect(belongsGroup).toBeDefined()
expect(belongsGroup!.entries).toHaveLength(1)
const notesGroup = groups.find((g) => g.label === 'Notes')
expect(notesGroup).toBeDefined()
expect(notesGroup!.entries).toHaveLength(32)
// michele-sampieri and varun-anand already consumed by Notes → Referred by Data has 0 new
const referredGroup = groups.find((g) => g.label === 'Referred by Data')
expect(referredGroup).toBeUndefined()
})
it('resolves refs by title when filename differs from wikilink target', () => {
// Wikilink [[Airdev]] but filename is airdev-tool.md, title is "Airdev"
const airdev = makeEntry({
path: '/vault/airdev-tool.md', filename: 'airdev-tool.md', title: 'Airdev',
})
const budibase = makeEntry({
path: '/vault/budibase-app.md', filename: 'budibase-app.md', title: 'Budibase',
aliases: ['Budi'],
})
const entity = makeEntry({
path: '/vault/no-code.md', filename: 'no-code.md', title: 'No Code',
relationships: { Notes: ['[[Airdev]]', '[[Budi]]'] },
})
const groups = buildRelationshipGroups(entity, [entity, airdev, budibase])
const notesGroup = groups.find((g) => g.label === 'Notes')
expect(notesGroup).toBeDefined()
expect(notesGroup!.entries).toHaveLength(2)
expect(notesGroup!.entries.map(e => e.title).sort()).toEqual(['Airdev', 'Budibase'])
})
it('resolves Children via title match when belongsTo target differs from filename', () => {
// Child's belongsTo uses [[No Code]] but entity filename is no-code-topic.md
const child = makeEntry({
path: '/vault/tool.md', filename: 'tool.md', title: 'Tool',
belongsTo: ['[[No Code]]'], modifiedAt: 1700000000,
})
const entity = makeEntry({
path: '/vault/no-code-topic.md', filename: 'no-code-topic.md', title: 'No Code',
relationships: {},
})
const groups = buildRelationshipGroups(entity, [entity, child])
expect(groups.find((g) => g.label === 'Children')!.entries).toHaveLength(1)
})
})
describe('getSortComparator — custom properties', () => {

View File

@@ -1,4 +1,5 @@
import type { VaultEntry, SidebarSelection, InboxPeriod } from '../types'
import { wikilinkTarget, resolveEntry } from './wikilink'
export type NoteListFilter = 'open' | 'archived' | 'trashed'
@@ -61,25 +62,12 @@ export function formatSearchSubtitle(entry: VaultEntry): string {
}
function refsMatch(refs: string[], entry: VaultEntry): boolean {
const stem = entry.path.replace(/^.*\/Laputa\//, '').replace(/\.md$/, '')
const fileStem = entry.filename.replace(/\.md$/, '')
return refs.some((ref) => {
const inner = ref.replace(/^\[\[/, '').replace(/\]\]$/, '').split('|')[0]
return inner === stem || inner.split('/').pop() === fileStem
})
return refs.some((ref) => resolveEntry([entry], wikilinkTarget(ref)) !== undefined)
}
function resolveRefs(refs: string[], entries: VaultEntry[]): VaultEntry[] {
return refs
.map((ref) => {
const inner = ref.replace(/^\[\[/, '').replace(/\]\]$/, '').split('|')[0]
return entries.find((e) => {
const stem = e.path.replace(/^.*\/Laputa\//, '').replace(/\.md$/, '')
if (stem === inner) return true
const fileStem = e.filename.replace(/\.md$/, '')
return fileStem === inner.split('/').pop()
})
})
.map((ref) => resolveEntry(entries, wikilinkTarget(ref)))
.filter((e): e is VaultEntry => e !== undefined)
}

View File

@@ -0,0 +1,50 @@
import { test, expect } from '@playwright/test'
test.describe('Focus event does not freeze the UI', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/')
await page.waitForLoadState('networkidle')
})
test('window focus event completes without blocking UI for >500ms', async ({ page }) => {
// Verify the app loaded
await expect(page.locator('[data-testid="sidebar"]').or(page.locator('nav')).first()).toBeVisible()
// Measure how long the UI is blocked after a focus event.
// We dispatch focus, then immediately schedule a rAF callback.
// If the main thread is blocked (sync IPC), the rAF callback is delayed.
const blockMs = await page.evaluate(() => {
return new Promise<number>((resolve) => {
const t0 = performance.now()
window.dispatchEvent(new Event('focus'))
requestAnimationFrame(() => {
resolve(performance.now() - t0)
})
})
})
// The focus handler must not block the main thread for more than 500ms.
// Before the fix, git_pull ran synchronously and blocked for 2-3 seconds.
expect(blockMs).toBeLessThan(500)
})
test('rapid focus events (5x) do not accumulate freezes', async ({ page }) => {
await expect(page.locator('[data-testid="sidebar"]').or(page.locator('nav')).first()).toBeVisible()
const totalMs = await page.evaluate(() => {
return new Promise<number>((resolve) => {
const t0 = performance.now()
for (let i = 0; i < 5; i++) {
window.dispatchEvent(new Event('focus'))
}
requestAnimationFrame(() => {
resolve(performance.now() - t0)
})
})
})
// 5 rapid focus events should still complete in under 500ms total
// thanks to the cooldown preventing redundant work.
expect(totalMs).toBeLessThan(500)
})
})

View File

@@ -0,0 +1,103 @@
import { test, expect } from '@playwright/test'
import { sendShortcut } from './helpers'
test.describe('Note list shows complete relationships when opening from sidebar', () => {
test.beforeEach(async ({ page }) => {
await page.setViewportSize({ width: 1600, height: 900 })
await page.goto('/')
await page.waitForLoadState('networkidle')
})
test('entity view shows relationship groups with correct counts after sidebar click', async ({ page }) => {
// Navigate to Responsibilities type to find entity notes in the sidebar
// First, click on a sidebar type that contains entity notes
// We'll use the sidebar search to filter to "Sponsorships"
const searchToggle = page.locator('[data-testid="search-toggle"]')
if (await searchToggle.isVisible()) {
await searchToggle.click()
}
// Type in sidebar search to find Sponsorships
const sidebarSearch = page.locator('[data-testid="note-list-search"]')
if (await sidebarSearch.isVisible()) {
await sidebarSearch.fill('Sponsorships')
await page.waitForTimeout(500)
}
// Click the Sponsorships note in the note list to trigger entity view
const sponsorshipsItem = page.locator('[data-entry-path*="sponsorships"]').first()
if (await sponsorshipsItem.isVisible({ timeout: 3000 }).catch(() => false)) {
await sponsorshipsItem.click()
await page.waitForTimeout(1000)
} else {
// Fallback: open via quick open — then click in sidebar
await page.locator('body').click()
await sendShortcut(page, 'p', ['Control'])
const searchInput = page.locator('input[placeholder="Search notes..."]')
await expect(searchInput).toBeVisible()
await searchInput.fill('Sponsorships')
await page.waitForTimeout(500)
await page.keyboard.press('Enter')
await page.waitForTimeout(1000)
}
// The inspector panel (right side) should show relationship labels with font-mono-overline
// This verifies the note loaded and relationships were parsed correctly
const measuresLabel = page.locator('span.font-mono-overline').filter({ hasText: 'Has Measures' })
await expect(measuresLabel).toBeVisible({ timeout: 5000 })
const proceduresLabel = page.locator('span.font-mono-overline').filter({ hasText: 'Has Procedures' })
await expect(proceduresLabel).toBeVisible({ timeout: 5000 })
// Verify the relationships panel shows the correct number of items
// Has Measures should have 2 entries (measure-sponsorship-mrr, measure-close-rate)
const measuresSection = measuresLabel.locator('xpath=ancestor::div[1]')
const measureItems = measuresSection.locator('a, button').filter({ hasText: /measure|Measure/ })
// At least 1 resolved relationship entry
const hasItems = await measureItems.count()
expect(hasItems).toBeGreaterThanOrEqual(1)
})
test('relationship labels persist after navigating away and back', async ({ page }) => {
// Open Sponsorships via quick open
await page.locator('body').click()
await sendShortcut(page, 'p', ['Control'])
const searchInput = page.locator('input[placeholder="Search notes..."]')
await expect(searchInput).toBeVisible()
await searchInput.fill('Sponsorships')
await page.waitForTimeout(500)
await page.keyboard.press('Enter')
await page.waitForTimeout(1000)
// Verify Has Measures relationship appears in inspector
const measuresLabel = page.locator('span.font-mono-overline').filter({ hasText: 'Has Measures' })
await expect(measuresLabel).toBeVisible({ timeout: 5000 })
// Navigate to different note
await page.locator('body').click()
await sendShortcut(page, 'p', ['Control'])
const searchInput2 = page.locator('input[placeholder="Search notes..."]')
await expect(searchInput2).toBeVisible()
await searchInput2.fill('Start Laputa App')
await page.waitForTimeout(500)
await page.keyboard.press('Enter')
await page.waitForTimeout(1000)
// Navigate back to Sponsorships
await page.locator('body').click()
await sendShortcut(page, 'p', ['Control'])
const searchInput3 = page.locator('input[placeholder="Search notes..."]')
await expect(searchInput3).toBeVisible()
await searchInput3.fill('Sponsorships')
await page.waitForTimeout(500)
await page.keyboard.press('Enter')
await page.waitForTimeout(1000)
// Relationships should still be visible — not stale or incomplete
const measuresLabelAgain = page.locator('span.font-mono-overline').filter({ hasText: 'Has Measures' })
await expect(measuresLabelAgain).toBeVisible({ timeout: 5000 })
const proceduresLabelAgain = page.locator('span.font-mono-overline').filter({ hasText: 'Has Procedures' })
await expect(proceduresLabelAgain).toBeVisible({ timeout: 5000 })
})
})

View File

@@ -18,7 +18,6 @@ test.describe('Note list preview snippet', () => {
if (text && text.length > 10) {
expect(text).not.toMatch(/\*\*[^*]+\*\*/)
expect(text).not.toContain('```')
expect(text).not.toMatch(/\[\[.*\]\]/)
}
}
})

View File

@@ -54,4 +54,29 @@ test.describe('TitleField alignment and separator', () => {
// Both should have the same left edge (within 2px tolerance)
expect(Math.abs(titleBox!.x - editorBox!.x)).toBeLessThanOrEqual(2)
})
test('title field uses H1 CSS variables for font styling', async ({ page }) => {
// Verify the title-field__input element references the H1 heading CSS vars
const usesH1Vars = await page.evaluate(() => {
const sheets = Array.from(document.styleSheets)
for (const sheet of sheets) {
try {
for (const rule of Array.from(sheet.cssRules)) {
if (rule instanceof CSSStyleRule && rule.selectorText === '.title-field__input') {
const fontSize = rule.style.getPropertyValue('font-size')
const fontWeight = rule.style.getPropertyValue('font-weight')
return {
fontSize: fontSize.includes('--headings-h1-font-size'),
fontWeight: fontWeight.includes('--headings-h1-font-weight'),
}
}
}
} catch { /* cross-origin sheet */ }
}
return { fontSize: false, fontWeight: false }
})
expect(usesH1Vars.fontSize).toBe(true)
expect(usesH1Vars.fontWeight).toBe(true)
})
})