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
7 changes: 6 additions & 1 deletion macos/Tests/LitheTests/DiagnosticsWorkflowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ private struct WorkflowLogDirectory: LogDirectoryProviding {
let defaultLogDirectory: URL
}

/// AppKit shrinks titled windows to the visible screen, and CI displays are smaller than the mockup.
private final class ScreenUnconstrainedWindow: NSWindow {
override func constrainFrameRect(_ frameRect: NSRect, to screen: NSScreen?) -> NSRect { frameRect }
}

/// Real filesystem adapter with task-owned staging, never the user's cache.
private struct WorkflowDiskStorage: FileStorage {
let root: URL
Expand Down Expand Up @@ -245,7 +250,7 @@ struct DiagnosticsWorkflowTests {
.environmentObject(settings).environment(\.colorScheme, scheme)
.environment(\.locale, Locale(identifier: language))
.task { mounted.open() })
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1340, height: 786), styleMask: [.titled, .resizable], backing: .buffered, defer: false)
let window = ScreenUnconstrainedWindow(contentRect: NSRect(x: 0, y: 0, width: 1340, height: 786), styleMask: [.titled, .resizable], backing: .buffered, defer: false)
window.isReleasedWhenClosed = false
window.appearance = NSAppearance(named: scheme == .dark ? .darkAqua : .aqua)
window.contentView = host; window.makeKeyAndOrderFront(nil)
Expand Down
8 changes: 7 additions & 1 deletion rust/lithe-core/src/diagnostics/request_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,18 @@ mod tests {

#[test]
fn fields_keep_valid_tokens_and_omit_invalid_ones() {
// Windows paths are only absolute with a drive prefix.
let root = if cfg!(windows) {
r"C:\project"
} else {
"/tmp/project"
};
let ((), events) = capture::run(false, || {
let trace = Request::begin(&request(json!({
"id": "request-1",
"command": "git.write",
"origin": {"source": "user", "trigger": "vcs.fetch", "operation": "action-7"},
"payload": {"operation": "fetch", "root": "/tmp/project", "path": "/ignored"}
"payload": {"operation": "fetch", "root": root, "path": "/ignored"}
})));
assert_eq!(current().op.as_deref(), Some("action-7"));
assert_eq!(current().source, Source::User);
Expand Down
2 changes: 1 addition & 1 deletion rust/lithe-core/src/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub(crate) mod configuration;
pub(crate) mod console;
pub(crate) mod execution_events;
pub(crate) mod execution_policy;
pub(crate) mod file_context;
mod fetch;
mod fetch_execution;
pub(crate) mod file_context;
#[allow(dead_code)]
pub(crate) mod graph;
mod history;
Expand Down
26 changes: 22 additions & 4 deletions rust/lithe-core/src/runtime/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2693,19 +2693,37 @@ fn execute_parsed(parsed: CoreRequest) -> CoreResponse {
}
CoreCommand::GitWorkspaceStatusMerge => {
match serde_json::from_value::<git::workspace_status::Request>(parsed.payload)
.map_err(|error| CoreError::new(ErrorCode::InvalidRequest, "Invalid workspace Git status request").with_details(error.to_string()))
.map_err(|error| {
CoreError::new(
ErrorCode::InvalidRequest,
"Invalid workspace Git status request",
)
.with_details(error.to_string())
})
.and_then(git::workspace_status::plan)
{
Ok(data) => CoreResponse::success(id, serde_json::to_value(data).expect("Git workspace status plan should encode")),
Ok(data) => CoreResponse::success(
id,
serde_json::to_value(data).expect("Git workspace status plan should encode"),
),
Err(error) => CoreResponse::failure(id, error),
}
}
CoreCommand::GitResolveFileContext => {
match serde_json::from_value::<git::file_context::Request>(parsed.payload)
.map_err(|error| CoreError::new(ErrorCode::InvalidRequest, "Invalid Git file context request").with_details(error.to_string()))
.map_err(|error| {
CoreError::new(
ErrorCode::InvalidRequest,
"Invalid Git file context request",
)
.with_details(error.to_string())
})
.and_then(git::file_context::resolve)
{
Ok(data) => CoreResponse::success(id, serde_json::to_value(data).expect("Git file context should encode")),
Ok(data) => CoreResponse::success(
id,
serde_json::to_value(data).expect("Git file context should encode"),
),
Err(error) => CoreResponse::failure(id, error),
}
}
Expand Down
4 changes: 3 additions & 1 deletion rust/lithe-core/src/tests/core_request_traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ fn user_git_command_records_redacted_argv_under_the_action_operation() {
assert_eq!(request.op.as_deref(), Some("action-1"));
assert_eq!(request.fields["method"], "git.command");
assert_eq!(request.fields["trigger"], "vcs.commit");
assert_eq!(request.fields["path"], "<PATH>");
// A temporary directory under the home directory scrubs to `<HOME>\...` on Windows runners.
let path = request.fields["path"].as_str().unwrap();
assert!(path == "<PATH>" || path.starts_with("<HOME>"), "{path}");

let serialized = serde_json::to_string(&events).unwrap();
assert!(!serialized.contains("secret"), "{serialized}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mock.module("@/platform/tauri-core", () => ({ ...core, invoke: async (command: s
mutate?.();
return diff;
}
if (command === "git.resolveFileContext") return { root: current.root, path: "file.txt", ownership: "git" };
throw new Error(`Unexpected command: ${command}`);
} }));
const { getWorkingTreePathDiff, isWorktreeWritePatchCurrent } = await import("@/features/git/api/git-diff-api");
Expand Down
Loading