Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "bash -c '\"$(git rev-parse --show-toplevel)/.claude/hooks/post-edit-format.sh\"'"
}
]
}
]
}
}
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ jobs:
name: Desktop E2E (Linux)
runs-on: ubuntu-latest
needs: [changes, desktop-rust, desktop-svelte]
if: needs.changes.outputs.desktop == 'true'
if: |
always() &&
needs.changes.outputs.desktop == 'true' &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

steps:
- name: Checkout code
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/coverage-allowlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"file-explorer/SelectionInfo.svelte": { "reason": "Logic tested in selection-info-utils.ts, DOM-dependent" },
"file-explorer/ShareBrowser.svelte": { "reason": "Network component, needs integration tests" },
"file-explorer/SortableHeader.svelte": { "reason": "Simple UI component, display only" },
"file-viewer/open-viewer.ts": { "reason": "Depends on Tauri WebviewWindow API" },
"font-metrics/measure.ts": { "reason": "Depends on DOM APIs" },
"icon-cache.ts": { "reason": "Depends on Tauri APIs" },
"licensing-store.svelte.ts": { "reason": "Depends on Tauri store APIs" },
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ futures-util = "0.3"
tower-http = { version = "0.6", features = ["cors"] }
tauri-plugin-updater = "2"
tauri-plugin-process = "2"
memchr = "2"

[target.'cfg(unix)'.dependencies]
libc = "0.2"
Expand Down
15 changes: 15 additions & 0 deletions apps/desktop/src-tauri/capabilities/viewer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "viewer",
"description": "Capability for file viewer windows",
"windows": [
"viewer-*"
],
"permissions": [
"core:window:allow-close",
"core:window:allow-set-title",
"core:window:allow-set-focus",
"core:window:allow-get-all-windows",
"core:event:default"
]
}
89 changes: 89 additions & 0 deletions apps/desktop/src-tauri/src/commands/file_viewer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//! Tauri commands for the file viewer.

use crate::file_viewer::{self, LineChunk, SearchPollResult, SeekTarget, ViewerOpenResult, ViewerSessionStatus};
use log::debug;

/// Opens a viewer session for the given file.
/// Returns session metadata + initial lines from the start of the file.
#[tauri::command]
pub fn viewer_open(path: String) -> Result<ViewerOpenResult, String> {
file_viewer::open_session(&path).map_err(|e| e.to_string())
}

/// Fetches a range of lines from a viewer session.
///
/// # Arguments
/// * `session_id` - The session ID from `viewer_open`.
/// * `target_type` - One of "line", "byte", or "fraction".
/// * `target_value` - The seek value (line number, byte offset, or fraction 0.0-1.0).
/// * `count` - Number of lines to fetch.
#[tauri::command]
pub fn viewer_get_lines(
session_id: String,
target_type: String,
target_value: f64,
count: usize,
) -> Result<LineChunk, String> {
let target = match target_type.as_str() {
"line" => SeekTarget::Line(target_value as usize),
"byte" => SeekTarget::ByteOffset(target_value as u64),
"fraction" => SeekTarget::Fraction(target_value),
other => {
return Err(format!(
"Unknown target type: {}. Use 'line', 'byte', or 'fraction'.",
other
));
}
};

debug!(
"viewer_get_lines: session={}, target_type={}, target_value={}, count={}",
session_id, target_type, target_value, count
);

let result = file_viewer::get_lines(&session_id, target, count).map_err(|e| e.to_string())?;

debug!(
"viewer_get_lines: returned {} lines, first_line_number={}, byte_offset={}, first_line_preview={:?}",
result.lines.len(),
result.first_line_number,
result.byte_offset,
result.lines.first().map(|s| s.chars().take(50).collect::<String>())
);

Ok(result)
}

/// Starts a background search in the viewer session.
/// Poll with `viewer_search_poll` to get results.
#[tauri::command]
pub fn viewer_search_start(session_id: String, query: String) -> Result<(), String> {
if query.is_empty() {
return Err("Search query cannot be empty".to_string());
}
file_viewer::search_start(&session_id, query).map_err(|e| e.to_string())
}

/// Polls search progress and current matches.
#[tauri::command]
pub fn viewer_search_poll(session_id: String) -> Result<SearchPollResult, String> {
file_viewer::search_poll(&session_id).map_err(|e| e.to_string())
}

/// Cancels an ongoing search.
#[tauri::command]
pub fn viewer_search_cancel(session_id: String) -> Result<(), String> {
file_viewer::search_cancel(&session_id).map_err(|e| e.to_string())
}

/// Gets the current status of a viewer session (backend type, indexing state).
#[tauri::command]
pub fn viewer_get_status(session_id: String) -> Result<ViewerSessionStatus, String> {
file_viewer::get_session_status(&session_id).map_err(|e| e.to_string())
}

/// Closes a viewer session and frees resources.
#[tauri::command]
pub fn viewer_close(session_id: String) -> Result<(), String> {
file_viewer::close_session(&session_id).map_err(|e| e.to_string())
}
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Tauri commands module.

pub mod file_system;
pub mod file_viewer;
pub mod font_metrics;
pub mod icons;
pub mod licensing;
Expand Down
Loading
Loading