v0.2.0
clean architecture refactor, performance, resilience, DX/UX architecture: - 13 crates with proper domain/application/infrastructure layers - domain crate: newtypes, ports (Plugin, AppLauncher), constants - kernel: pure orchestrator - shared UI state machine (k-launcher-ui-core) - merged plugin-api into domain as ports module - granular file structure (no monolithic lib.rs) - all tests extracted to tests/ directories features: - frecency boost in search results - empty query shows top frecent apps - append-only frecency log with configurable compaction - config-driven styling (all colors, sizes, debounce) - configurable terminal emulator, external plugin timeout - log rotation with max_log_files - loading indicator, descriptive placeholder text - graceful shutdown via iced::exit() + Plugin::shutdown() - --version flag, panic hook, signal handling (SIGINT/SIGTERM) - SpawnInTerminal in external plugin protocol performance: - ~1500 -> ~50 heap allocs per keystroke - reused Matcher, Pattern, char buffer across entries - Arc<str> for shared result fields - pre-filter before fuzzy matching - partial sort for top frecent IDs - cached lowercase names in entries resilience: - parking_lot (no mutex poisoning) - thiserror hierarchy (PluginError, ConfigError, AppError) - all silent error swallowing replaced with tracing::warn - config parse errors logged quality: - named constants (no magic strings/numbers) - named types (no anonymous tuples) - Rgba newtype with validation - domain newtype validation (debug_assert non-empty) - man page, LICENSE (MIT), PKGBUILD, example config - plugin development guide updated - make check (fmt + clippy + test), make dev (RUST_LOG=debug) style: format code for better readability in tests and function signatures fix: update build_entries function signature to ignore frecency parameter fix(review): bugs, arch violations, design smells P1 bugs: - unix_launcher: shell_split respects quoted args (was split_whitespace) - plugin-host: 5s timeout on external plugin search - ui: handle engine init panic, wire error state - ui-egui: read window config instead of always using defaults - plugin-url: use OpenPath action instead of SpawnProcess+xdg-open Architecture: - remove WindowConfig (mirror of WindowCfg); use WindowCfg directly - remove on_select closure from SearchResult (domain leakage) - remove LaunchAction::Custom; add Plugin::on_selected + SearchEngine::on_selected - apps: record frecency via on_selected instead of embedded closure Design smells: - frecency: extract decay_factor helper, write outside mutex - apps: remove cfg(test) cache_path hack; add new_for_test ctor - apps: stable ResultId using name+exec to prevent collision - files: stable ResultId using full path instead of index - plugin-host: remove k-launcher-os-bridge dep (WindowConfig gone) Update iced dependency in Cargo.toml to disable default features and add additional ones feat(app): enhance engine initialization with EngineHandle and update run function signature feat: production hardening (panic isolation, file logging, apps cache) - Kernel::search wraps each plugin in catch_unwind; panics are logged and return [] - init_logging() adds daily rolling file at ~/.local/share/k-launcher/logs/ - AppsPlugin caches entries to ~/.cache/k-launcher/apps.bin via bincode; stale-while-revalidate on subsequent launches - 57 tests pass refactor: remove client module and associated show command logic fix(app): format code for clarity in update function chore: update .gitignore and enhance README with compositor setup instructions chore(docs): remove unused screenshot file feature/prod-ready (#1) Reviewed-on: #1 fix(calc): remove ambiguous log alias, use ln/log2/log10 explicitly fix(calc): fix log/ln naming, cache math context, strengthen sin(pi) test feat(calc): add math functions (sqrt, sin, cos, etc.) and pi/e constants refactor(calc): rename preprocess, extend underscore test assertions feat(calc): strip underscore digit separators feat: update dependencies for improved compatibility and performance feat: add plugin-url for URL handling and open in browser functionality feat: add support for external plugins and enhance plugin management feat: add Makefile for build, run, and installation commands feat: add required features for k-launcher-egui and update dependencies feat: update README and add documentation for installation, configuration, usage, and plugin development feat: enhance configuration management and UI styling, remove unused theme module feat: add k-launcher-config crate for configuration management and integrate with existing components feat: add k-launcher-ui-egui crate for enhanced UI - Introduced a new crate `k-launcher-ui-egui` to provide a graphical user interface using eframe and egui. - Updated the workspace configuration in `Cargo.toml` to include the new crate. - Implemented the main application logic in `src/app.rs`, handling search functionality and user interactions. - Created a library entry point in `src/lib.rs` to expose the `run` function for launching the UI. - Modified the `k-launcher` crate to include a new binary target for the egui-based launcher. - Added a new main file `src/main_egui.rs` to initialize and run the egui UI with the existing kernel and launcher components. feat: implement OS bridge and enhance app launcher functionality feat: add FilesPlugin for file searching and integrate into KLauncher feat: implement frecency tracking for app usage and enhance search functionality feat: add CmdPlugin for executing terminal commands and update workspace configuration refactor: update dependencies and improve keyboard event handling in KLauncherApp refactor: simplify theme usage and enhance AppsPlugin structure feat: restructure k-launcher workspace and add core functionality - Updated Cargo.toml to include a new k-launcher crate and reorganized workspace members. - Introduced a README.md file detailing the project philosophy, architecture, and technical specifications. - Implemented a new Kernel struct in k-launcher-kernel for managing plugins and search functionality. - Created a Plugin trait for plugins to implement, allowing for asynchronous search operations. - Developed k-launcher-ui with an Iced-based UI for user interaction, including search input and result display. - Added AppsPlugin and CalcPlugin to handle application launching and basic calculations, respectively. - Established a theme module for UI styling, focusing on an Aero aesthetic. - Removed unnecessary main.rs files from plugin crates, streamlining the project structure. Initialize k-launcher project structure with multiple crates and basic configurations
This commit is contained in:
8
crates/k-launcher-domain/Cargo.toml
Normal file
8
crates/k-launcher-domain/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "k-launcher-domain"
|
||||
version = "0.2.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
7
crates/k-launcher-domain/src/action.rs
Normal file
7
crates/k-launcher-domain/src/action.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
#[derive(Clone)]
|
||||
pub enum LaunchAction {
|
||||
SpawnProcess(String),
|
||||
SpawnInTerminal(String),
|
||||
OpenPath(String),
|
||||
CopyToClipboard(String),
|
||||
}
|
||||
6
crates/k-launcher-domain/src/constants.rs
Normal file
6
crates/k-launcher-domain/src/constants.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
pub const APP_NAME: &str = "k-launcher";
|
||||
pub const APP_TITLE: &str = "K-Launcher";
|
||||
pub const CONFIG_FILENAME: &str = "config.toml";
|
||||
pub const FRECENCY_SNAPSHOT_FILENAME: &str = "frecency.json";
|
||||
pub const LOG_DIR_NAME: &str = "logs";
|
||||
pub const LOG_FILE_PREFIX: &str = "k-launcher.log";
|
||||
10
crates/k-launcher-domain/src/lib.rs
Normal file
10
crates/k-launcher-domain/src/lib.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
mod action;
|
||||
pub mod constants;
|
||||
mod newtypes;
|
||||
pub mod ports;
|
||||
mod search_result;
|
||||
|
||||
pub use action::*;
|
||||
pub use newtypes::*;
|
||||
pub use ports::*;
|
||||
pub use search_result::*;
|
||||
46
crates/k-launcher-domain/src/newtypes.rs
Normal file
46
crates/k-launcher-domain/src/newtypes.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ResultId(String);
|
||||
|
||||
impl ResultId {
|
||||
pub fn new(id: impl Into<String>) -> Self {
|
||||
let id = id.into();
|
||||
debug_assert!(!id.is_empty(), "ResultId must not be empty");
|
||||
Self(id)
|
||||
}
|
||||
pub fn as_str(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ResultTitle(String);
|
||||
|
||||
impl ResultTitle {
|
||||
pub fn new(title: impl Into<String>) -> Self {
|
||||
let title = title.into();
|
||||
debug_assert!(!title.is_empty(), "ResultTitle must not be empty");
|
||||
Self(title)
|
||||
}
|
||||
pub fn as_str(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize,
|
||||
)]
|
||||
pub struct Score(u32);
|
||||
|
||||
impl Score {
|
||||
pub const MAX: Self = Self(u32::MAX);
|
||||
|
||||
pub fn new(value: u32) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
pub fn value(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
pub fn saturating_add(self, other: u32) -> Self {
|
||||
Self(self.0.saturating_add(other))
|
||||
}
|
||||
}
|
||||
15
crates/k-launcher-domain/src/ports.rs
Normal file
15
crates/k-launcher-domain/src/ports.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{LaunchAction, ResultId, SearchResult};
|
||||
|
||||
pub trait AppLauncher: Send + Sync {
|
||||
fn execute(&self, action: &LaunchAction);
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait Plugin: Send + Sync {
|
||||
fn name(&self) -> &str;
|
||||
async fn search(&self, query: &str) -> Vec<SearchResult>;
|
||||
fn on_selected(&self, _id: &ResultId) {}
|
||||
fn shutdown(&self) {}
|
||||
}
|
||||
25
crates/k-launcher-domain/src/search_result.rs
Normal file
25
crates/k-launcher-domain/src/search_result.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::action::LaunchAction;
|
||||
use crate::newtypes::{ResultId, ResultTitle, Score};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SearchResult {
|
||||
pub id: ResultId,
|
||||
pub title: ResultTitle,
|
||||
pub description: Option<Arc<str>>,
|
||||
pub icon: Option<Arc<str>>,
|
||||
pub score: Score,
|
||||
pub action: LaunchAction,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for SearchResult {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("SearchResult")
|
||||
.field("id", &self.id)
|
||||
.field("title", &self.title)
|
||||
.field("icon", &self.icon)
|
||||
.field("score", &self.score)
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
16
crates/k-launcher-domain/tests/newtypes.rs
Normal file
16
crates/k-launcher-domain/tests/newtypes.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use k_launcher_domain::{ResultId, ResultTitle, Score};
|
||||
|
||||
#[test]
|
||||
fn newtype_result_id() {
|
||||
assert_eq!(ResultId::new("x").as_str(), "x");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newtype_score() {
|
||||
assert_eq!(Score::new(42).value(), 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newtype_title() {
|
||||
assert_eq!(ResultTitle::new("hello").as_str(), "hello");
|
||||
}
|
||||
Reference in New Issue
Block a user