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
16 changes: 9 additions & 7 deletions Tools/windows/uia-live-gate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10452,13 +10452,15 @@ try {
$edgeCanvasMenuOrder = @($edgeCanvasMenu.Items | ForEach-Object {
if ($_.Separator) { "<separator>" } else { [string]$_.Text }
})
Require (($edgeCanvasMenuOrder -join "|") -ceq "Edit Edge...|Delete Edge") `
Require ($edgeCanvasMenuOrder.Count -eq 3 -and
$edgeCanvasMenuOrder[0] -cmatch '^(Handoff|Message|Spawn) · (Always|On success|On failure)( · .+)?$' -and
($edgeCanvasMenuOrder[1..2] -join "|") -ceq "Delete Edge|Edit Edge...") `
"canvas edge context menu had unexpected ordered items: $($edgeCanvasMenu.Description)"
Require (@($edgeCanvasMenu.Items | Where-Object {
-not $_.Separator -and (-not $_.Enabled -or $_.Checked)
}).Count -eq 0) `
"canvas edge context menu had an unexpected disabled or checked item: $($edgeCanvasMenu.Description)"
Require ((@($edgeCanvasMenu.Items | ForEach-Object { $_.Id }) -join "|") -ceq "5110|5111") `
Require (-not $edgeCanvasMenu.Items[0].Enabled -and
@($edgeCanvasMenu.Items | Where-Object { $_.Separator -or $_.Checked }).Count -eq 0 -and
@($edgeCanvasMenu.Items | Where-Object { $_.Id -in @(5110, 5111) -and -not $_.Enabled }).Count -eq 0) `
"canvas edge context menu did not retain a disabled summary and enabled actions: $($edgeCanvasMenu.Description)"
Require ((@($edgeCanvasMenu.Items | ForEach-Object { $_.Id }) -join "|") -ceq "0|5111|5110") `
"canvas edge context menu did not expose the edge-specific Edit/Delete commands: $($edgeCanvasMenu.Description)"

# Exercise Edit Edge only after all three menus were dismissed with Escape.
Expand Down Expand Up @@ -11927,7 +11929,7 @@ try {
Start-Sleep -Milliseconds 100
}
$edgeEditMenu = Open-EdgeMenu $true 5110
Require (($edgeEditMenu.menuIds -join "|") -ceq "5110|5111") `
Require (($edgeEditMenu.menuIds -join "|") -ceq "0|5111|5110") `
"republished edge was not hit-tested as a single editable connection"
$edgeWorkflowTitle = "Edit edge"
Wait-EdgeWindow $edgeWorkflowTitle
Expand Down
14 changes: 8 additions & 6 deletions graphcode-windows/src/App.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5741,13 +5741,15 @@ pub const App = struct {
fn showEdgeContextMenu(self: *App, index: usize, x: i32, y: i32) void {
const graph = self.model.graph orelse return;
if (index >= graph.edges.items.len) return;
const project_path = self.allocator.dupe(u8, graph.project.path) catch return;
defer self.allocator.free(project_path);
const edge_id = self.allocator.dupe(u8, graph.edges.items[index].id) catch return;
defer self.allocator.free(edge_id);
var snapshot = GraphContextMenu.EdgeSnapshot.capture(self.allocator, graph.project.path, graph.edges.items[index]) catch |err| {
std.log.warn("Canvas edge menu capture failed: {s}", .{@errorName(err)});
self.setStatus("Unable to open the edge menu");
return;
};
defer snapshot.deinit();
GraphContextMenu.show(
self.window.hwnd,
.{ .edge = .{ .project_path = project_path, .id = edge_id } },
.{ .edge = snapshot.target },
x,
y,
self,
Expand Down Expand Up @@ -10806,7 +10808,7 @@ test "edge action diagnostic records callback and stable target refusals without
\\{"event":{"graphChanged":{"project":{"path":"A","name":"A"},"nodes":[],"edges":[]}}}
);
Probe.count = 0;
onContextAction(&app, .edit_edge, .{ .edge = .{ .project_path = case.project, .id = case.id } });
onContextAction(&app, .edit_edge, .{ .edge = .{ .project_path = case.project, .id = case.id, .summary = "Handoff · Always" } });
try std.testing.expectEqual(@as(usize, 3), Probe.count);
try std.testing.expectEqual(Diagnostics.EdgeActionTrace.Stage.callback_entry, Probe.events[0].stage);
try std.testing.expectEqual(Diagnostics.EdgeActionTrace.Stage.target_entry, Probe.events[1].stage);
Expand Down
49 changes: 2 additions & 47 deletions graphcode-windows/src/GraphCanvas.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const std = @import("std");
const GraphModel = @import("GraphModel.zig");
const GraphContextMenu = @import("GraphContextMenu.zig");
const Tokens = @import("DesignTokens.zig");
const Sidebar = @import("Sidebar.zig");
const WorktreeStatus = @import("WorktreeStatus.zig");
Expand Down Expand Up @@ -2637,59 +2638,13 @@ fn edgeLabel(allocator: std.mem.Allocator, edge: GraphModel.Edge) ![]u8 {
try writer.print(" · {s}", .{edge.condition});
if (edge.cycle_guard) |guard| {
try writer.print(" · loop {d}/", .{edge.fire_count});
try writeCycleGuard(writer, guard);
try GraphContextMenu.writeCycleGuard(writer, guard);
} else if (edge.fire_count > 0) {
try writer.print(" · fired {d}", .{edge.fire_count});
}
return output.toOwnedSlice();
}

fn writeCycleGuard(writer: anytype, guard: GraphModel.CycleGuard) !void {
var has_part = false;
if (guard.max_iterations) |maximum| {
try writer.print("≤{d}×", .{maximum});
has_part = true;
}
if (guard.until) |raw| {
const until = try effectiveEdgeUntil(raw);
if (until.len != 0) {
if (has_part) try writer.writeAll(" or ");
try writer.print("until `{s}`", .{until});
has_part = true;
}
}
if (guard.stop_after_passes_without_improvement) |passes| {
if (passes > 0) {
if (has_part) try writer.writeAll(" or ");
try writer.print("{d} flat passes", .{passes});
has_part = true;
}
}
if (!has_part) try writer.writeAll("unbounded");
}

fn effectiveEdgeUntil(text: []const u8) error{InvalidUtf8}![]const u8 {
const view = std.unicode.Utf8View.init(text) catch return error.InvalidUtf8;
var iterator = view.iterator();
var start = text.len;
var end: usize = 0;
var offset: usize = 0;
while (iterator.nextCodepointSlice()) |bytes| {
const codepoint = std.unicode.utf8Decode(bytes) catch return error.InvalidUtf8;
// Foundation .whitespaces: Unicode space separators plus horizontal tab, not newlines.
const whitespace = switch (codepoint) {
0x09, 0x20, 0xa0, 0x1680, 0x2000...0x200a, 0x202f, 0x205f, 0x3000 => true,
else => false,
};
if (!whitespace) {
start = @min(start, offset);
end = offset + bytes.len;
}
offset += bytes.len;
}
return text[@min(start, end)..end];
}

fn drawBezier(hdc: c.HDC, from: Connector, to: Connector, color: u32, zoom: f32) void {
drawRoute(hdc, CubicRoute.between(from, to, zoom), color, 2 * zoom, null);
}
Expand Down
Loading
Loading