diff --git a/Tools/windows/uia-live-gate.ps1 b/Tools/windows/uia-live-gate.ps1 index 6da333e2..25324294 100644 --- a/Tools/windows/uia-live-gate.ps1 +++ b/Tools/windows/uia-live-gate.ps1 @@ -10452,13 +10452,15 @@ try { $edgeCanvasMenuOrder = @($edgeCanvasMenu.Items | ForEach-Object { if ($_.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. @@ -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 diff --git a/graphcode-windows/src/App.zig b/graphcode-windows/src/App.zig index c5d22af0..e8247275 100644 --- a/graphcode-windows/src/App.zig +++ b/graphcode-windows/src/App.zig @@ -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, @@ -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); diff --git a/graphcode-windows/src/GraphCanvas.zig b/graphcode-windows/src/GraphCanvas.zig index ab7016ff..fe0e99ef 100644 --- a/graphcode-windows/src/GraphCanvas.zig +++ b/graphcode-windows/src/GraphCanvas.zig @@ -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"); @@ -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); } diff --git a/graphcode-windows/src/GraphContextMenu.zig b/graphcode-windows/src/GraphContextMenu.zig index 4f8e29c1..4265ced8 100644 --- a/graphcode-windows/src/GraphContextMenu.zig +++ b/graphcode-windows/src/GraphContextMenu.zig @@ -3,6 +3,7 @@ const Wire = @import("Wire.zig"); const SketchPromotion = @import("SketchPromotion.zig"); const NativeDialogs = @import("WindowsNativeDialogs.zig"); const Diagnostics = @import("Diagnostics.zig"); +const GraphModel = @import("GraphModel.zig"); pub const NodeMenuOrigin = enum { canvas, sidebar }; pub const TransferMenuState = enum { hidden, ready, local_only, busy, context_changed }; @@ -47,8 +48,116 @@ pub const BackgroundTarget = struct { pub const EdgeTarget = struct { project_path: []const u8, id: []const u8, + summary: []const u8, }; +pub const EdgeSnapshot = struct { + allocator: std.mem.Allocator, + target: EdgeTarget, + + pub fn capture(allocator: std.mem.Allocator, project_path: []const u8, edge: GraphModel.Edge) !EdgeSnapshot { + const path = try allocator.dupe(u8, project_path); + errdefer allocator.free(path); + const id = try allocator.dupe(u8, edge.id); + errdefer allocator.free(id); + return .{ + .allocator = allocator, + .target = .{ .project_path = path, .id = id, .summary = try edgeSummary(allocator, edge) }, + }; + } + + pub fn deinit(self: *EdgeSnapshot) void { + self.allocator.free(self.target.summary); + self.allocator.free(self.target.id); + self.allocator.free(self.target.project_path); + } +}; + +fn edgeSummary(allocator: std.mem.Allocator, edge: GraphModel.Edge) ![]u8 { + const kind = if (edge.kind.len == 0 or std.mem.eql(u8, edge.kind, "handoff")) + "Handoff" + else if (std.mem.eql(u8, edge.kind, "message")) + "Message" + else if (std.mem.eql(u8, edge.kind, "spawn")) + "Spawn" + else + return error.InvalidEdgeKind; + const condition = if (std.mem.eql(u8, edge.condition, "always")) + "Always" + else if (std.mem.eql(u8, edge.condition, "onSuccess")) + "On success" + else if (std.mem.eql(u8, edge.condition, "onFailure")) + "On failure" + else + return error.InvalidEdgeCondition; + var output = std.array_list.Managed(u8).init(allocator); + defer output.deinit(); + const writer = output.writer(); + try writer.print("{s} · {s}", .{ kind, condition }); + switch (edge.payload_transform) { + .none => {}, + .template => |text| if (text.len != 0) { + try writer.print(" · {s}", .{text}); + }, + .script => |command| if (command.len != 0) { + try writer.print(" · $ {s}", .{command}); + }, + } + if (edge.cycle_guard) |guard| { + try writer.print(" · loop {d}/", .{edge.fire_count}); + try writeCycleGuard(writer, guard); + } + if (!std.unicode.utf8ValidateSlice(output.items)) return error.InvalidUtf8; + if (std.mem.indexOfScalar(u8, output.items, 0) != null) return error.EmbeddedNull; + return output.toOwnedSlice(); +} + +pub 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]; +} + pub const QuickChatTarget = struct { id: []const u8, }; @@ -363,7 +472,10 @@ pub fn show( .hwnd = @intFromPtr(parent), }); const menu = buildMenu(target) orelse { - if (target == .edge) Diagnostics.traceEdgeAction(.{ .stage = .target_refused, .reason = "MenuCreationFailed" }); + if (target == .edge) { + std.log.warn("Canvas edge menu creation failed", .{}); + Diagnostics.traceEdgeAction(.{ .stage = .target_refused, .reason = "MenuCreationFailed" }); + } return; }; defer _ = c.DestroyMenu(menu); @@ -445,7 +557,7 @@ test "edge action diagnostic observes popup return without changing dispatch" { }; Diagnostics.edge_action_test_observer = Probe.observe; defer Diagnostics.edge_action_test_observer = null; - const target = Target{ .edge = .{ .project_path = "A", .id = "edge-a" } }; + const target = Target{ .edge = .{ .project_path = "A", .id = "edge-a", .summary = "Handoff · Always" } }; for ([_]c.BOOL{ 0, ids.edit_edge, ids.delete_edge, -1 }) |command| { Probe.count = 0; Probe.callbacks = 0; @@ -534,9 +646,18 @@ fn buildMenu(target: Target) c.HMENU { }, }; }, - .edge => { - append(menu, ids.edit_edge, "Edit Edge..."); + .edge => |edge| { + const heading = std.mem.replaceOwned(u8, std.heap.c_allocator, edge.summary, "&", "&&") catch { + _ = c.DestroyMenu(menu); + return null; + }; + defer std.heap.c_allocator.free(heading); + if (heading.len == 0 or !appendDisabledHeading(menu, heading)) { + _ = c.DestroyMenu(menu); + return null; + } append(menu, ids.delete_edge, "Delete Edge"); + append(menu, ids.edit_edge, "Edit Edge..."); }, .quick_chat => { append(menu, ids.open_quick_chat, "Open Chat"); @@ -706,7 +827,8 @@ test "card transfer menu capacity covers every flag combination without losing r var maximum: usize = 0; for (0..512) |bits| { const plan = nodeMenuPlan(.{ - .project_path = "C:\\A", .id = "node", + .project_path = "C:\\A", + .id = "node", .composite = bits & 1 != 0, .can_arm = bits & 2 != 0, .unwired = bits & 4 != 0, @@ -1337,8 +1459,9 @@ test "semantic fallback six E menus expose exact native item info on hidden HWND .{ .id = 5103, .text = std.unicode.utf8ToUtf16LeStringLiteral("Delete Loop...\tDelete") }, }; const edge_expected = [_]ExpectedMenuItem{ - .{ .id = 5110, .text = std.unicode.utf8ToUtf16LeStringLiteral("Edit Edge...") }, + .{ .id = 0, .text = std.unicode.utf8ToUtf16LeStringLiteral("Handoff · Always"), .enabled = false }, .{ .id = 5111, .text = std.unicode.utf8ToUtf16LeStringLiteral("Delete Edge") }, + .{ .id = 5110, .text = std.unicode.utf8ToUtf16LeStringLiteral("Edit Edge...") }, }; var observations: usize = 0; @@ -1378,10 +1501,11 @@ test "semantic fallback six E menus expose exact native item info on hidden HWND try expectBuiltMenuOnHiddenWindow(hwnd, .{ .edge = .{ .project_path = "C:\\fixture", .id = "edge-a", + .summary = "Handoff · Always", } }, &edge_expected, &observations); - try std.testing.expectEqual(@as(usize, 39), observations); + try std.testing.expectEqual(@as(usize, 40), observations); std.debug.print( - "semantic fallback positive targets=6 observations={d} (background=3 resolved=7 sketch-unwired=12 promote-child=4 post-Goal=11 edge=2)\n", + "semantic fallback positive targets=6 observations={d} (background=3 resolved=7 sketch-unwired=12 promote-child=4 post-Goal=11 edge=3)\n", .{observations}, ); @@ -1392,8 +1516,9 @@ test "semantic fallback six E menus expose exact native item info on hidden HWND .{ .id = 5150, .caption = "Unexpected" }, }, &background_expected); try expectDisposableMenuRejected(hwnd, &.{ - .{ .id = 5111, .caption = "Delete Edge" }, + .{ .id = 0, .caption = "Handoff · Always", .enabled = false }, .{ .id = 5110, .caption = "Edit Edge..." }, + .{ .id = 5111, .caption = "Delete Edge" }, }, &edge_expected); try expectDisposableMenuRejected(hwnd, &.{ .{ .id = 0, .caption = "Keep the session, add a shape", .enabled = true }, @@ -1423,7 +1548,7 @@ test "semantic fallback six E menus expose exact native item info on hidden HWND try expectBuiltMenuRejected(hwnd, .{ .node = sketch_node }, 5112, &sketch_expected); { - const edge_popup = buildMenu(.{ .edge = .{ .project_path = "C:\\fixture", .id = "edge-extra-header" } }) orelse return error.MenuCreationFailed; + const edge_popup = buildMenu(.{ .edge = .{ .project_path = "C:\\fixture", .id = "edge-extra-header", .summary = "Handoff · Always" } }) orelse return error.MenuCreationFailed; const edge_attached = try attachTestPopup(hwnd, edge_popup); defer std.debug.assert(detachTestPopup(hwnd, edge_attached)); const edge_header = toWide("Edge") orelse return error.CaptionConversionFailed; @@ -1647,15 +1772,120 @@ test "native node menu variants expose only eligible actions" { try std.testing.expectEqual(std.math.maxInt(c.UINT), c.GetMenuState(unwired, ids.arm_composite, c.MF_BYCOMMAND)); } -test "edge menu preserves edit and delete command ordering" { - const menu = buildMenu(.{ .edge = .{ .project_path = "C:\\fixture", .id = "edge-a" } }) orelse return error.MenuCreationFailed; +test "edge menu parity 765 has a disabled summary before delete and Windows edit" { + const menu = buildMenu(.{ .edge = .{ .project_path = "C:\\fixture", .id = "edge-a", .summary = "Handoff · Always" } }) orelse return error.MenuCreationFailed; defer _ = c.DestroyMenu(menu); try expectNativeMenu(menu, &.{ - .{ .id = ids.edit_edge, .text = std.unicode.utf8ToUtf16LeStringLiteral("Edit Edge...") }, + .{ .id = 0, .text = std.unicode.utf8ToUtf16LeStringLiteral("Handoff · Always"), .enabled = false }, .{ .id = ids.delete_edge, .text = std.unicode.utf8ToUtf16LeStringLiteral("Delete Edge") }, + .{ .id = ids.edit_edge, .text = std.unicode.utf8ToUtf16LeStringLiteral("Edit Edge...") }, }); } +test "edge menu parity 765 summary matches Mac kinds conditions transforms and guards" { + const cases = [_]struct { edge: GraphModel.Edge, expected: []const u8 }{ + .{ .edge = .{ .from = &.{}, .to = &.{} }, .expected = "Handoff · Always" }, + .{ .edge = .{ .from = &.{}, .to = &.{}, .kind = @constCast("message"), .condition = @constCast("onSuccess"), .fire_count = 2 }, .expected = "Message · On success" }, + .{ .edge = .{ .from = &.{}, .to = &.{}, .kind = @constCast("spawn"), .condition = @constCast("onFailure"), .payload_transform = .{ .script = "echo done" } }, .expected = "Spawn · On failure · $ echo done" }, + .{ .edge = .{ .from = &.{}, .to = &.{}, .payload_transform = .{ .template = "Carry \"雪\" & context" } }, .expected = "Handoff · Always · Carry \"雪\" & context" }, + .{ .edge = .{ .from = &.{}, .to = &.{}, .payload_transform = .{ .template = "" }, .cycle_guard = .{} }, .expected = "Handoff · Always · loop 0/unbounded" }, + .{ .edge = .{ .from = &.{}, .to = &.{}, .payload_transform = .{ .script = "" }, .cycle_guard = .{ .max_iterations = 3, .until = @constCast("\u{2003}done\u{a0}"), .stop_after_passes_without_improvement = 2 }, .fire_count = 2 }, .expected = "Handoff · Always · loop 2/≤3× or until `done` or 2 flat passes" }, + .{ .edge = .{ .from = &.{}, .to = &.{}, .cycle_guard = .{ .max_iterations = -3, .until = @constCast(" \t "), .stop_after_passes_without_improvement = -1 }, .fire_count = -2 }, .expected = "Handoff · Always · loop -2/≤-3×" }, + }; + for (cases) |case| { + const summary = try edgeSummary(std.testing.allocator, case.edge); + defer std.testing.allocator.free(summary); + try std.testing.expectEqualStrings(case.expected, summary); + } +} + +test "edge menu parity 765 snapshot owns long Unicode summary and stable target" { + const allocator = std.testing.allocator; + const payload = "雪 & context " ** 80; + var snapshot = capture: { + const project = try allocator.dupe(u8, "C:\\project 雪"); + defer allocator.free(project); + const id = try allocator.dupe(u8, "edge-original"); + defer allocator.free(id); + const text = try allocator.dupe(u8, payload); + defer allocator.free(text); + break :capture try EdgeSnapshot.capture(allocator, project, .{ + .id = id, + .from = &.{}, + .to = &.{}, + .payload_transform = .{ .template = text }, + }); + }; + defer snapshot.deinit(); + try std.testing.expectEqualStrings("C:\\project 雪", snapshot.target.project_path); + try std.testing.expectEqualStrings("edge-original", snapshot.target.id); + try std.testing.expectEqualStrings("Handoff · Always · " ++ payload, snapshot.target.summary); + const menu = buildMenu(.{ .edge = snapshot.target }) orelse return error.MenuCreationFailed; + defer _ = c.DestroyMenu(menu); + const escaped = try std.mem.replaceOwned(u8, allocator, snapshot.target.summary, "&", "&&"); + defer allocator.free(escaped); + const wide = try std.unicode.utf8ToUtf16LeAlloc(allocator, escaped); + defer allocator.free(wide); + try std.testing.expectEqual(wide.len, @as(usize, @intCast(c.GetMenuStringW(menu, 0, null, 0, c.MF_BYPOSITION)))); + const storage = try allocator.alloc(u16, wide.len + 1); + defer allocator.free(storage); + const copied = c.GetMenuStringW(menu, 0, storage.ptr, @intCast(storage.len), c.MF_BYPOSITION); + try std.testing.expectEqual(wide.len, @as(usize, @intCast(copied))); + try std.testing.expectEqualSlices(u16, wide, storage[0..wide.len]); + const state = c.GetMenuState(menu, 0, c.MF_BYPOSITION); + try std.testing.expect(state & c.MF_GRAYED != 0); + try std.testing.expect(state & c.MF_SEPARATOR == 0); +} + +test "edge menu parity 765 snapshot allocation failures unwind without partial targets" { + const Exercise = struct { + fn run(allocator: std.mem.Allocator) !void { + var snapshot = try EdgeSnapshot.capture(allocator, "C:\\original", .{ + .id = @constCast("edge-a"), + .from = &.{}, + .to = &.{}, + .payload_transform = .{ .script = "echo 雪" }, + .cycle_guard = .{ .max_iterations = 4, .until = @constCast(" done "), .stop_after_passes_without_improvement = 2 }, + .fire_count = 1, + }); + defer snapshot.deinit(); + try std.testing.expectEqualStrings("C:\\original", snapshot.target.project_path); + try std.testing.expectEqualStrings("edge-a", snapshot.target.id); + try std.testing.expectEqualStrings("Handoff · Always · $ echo 雪 · loop 1/≤4× or until `done` or 2 flat passes", snapshot.target.summary); + } + }; + try std.testing.checkAllAllocationFailures(std.testing.allocator, Exercise.run, .{}); +} + +test "edge menu parity 765 rejects malformed summary instead of displaying a fallback" { + const allocator = std.testing.allocator; + try std.testing.expectError(error.InvalidEdgeKind, EdgeSnapshot.capture(allocator, "A", .{ + .from = &.{}, + .to = &.{}, + .kind = @constCast("unknown"), + })); + try std.testing.expectError(error.InvalidEdgeCondition, EdgeSnapshot.capture(allocator, "A", .{ + .from = &.{}, + .to = &.{}, + .condition = @constCast("unknown"), + })); + try std.testing.expectError(error.InvalidUtf8, EdgeSnapshot.capture(allocator, "A", .{ + .from = &.{}, + .to = &.{}, + .cycle_guard = .{ .until = @constCast("\xff") }, + })); + try std.testing.expectError(error.InvalidUtf8, EdgeSnapshot.capture(allocator, "A", .{ + .from = &.{}, + .to = &.{}, + .payload_transform = .{ .template = "\xff" }, + })); + try std.testing.expectError(error.EmbeddedNull, EdgeSnapshot.capture(allocator, "A", .{ + .from = &.{}, + .to = &.{}, + .payload_transform = .{ .script = "hidden\x00suffix" }, + })); +} + test "context actions remain stable when graph IDs are reordered" { try std.testing.expectEqual(Action.edit_node, actionForCommand(ids.edit_node)); try std.testing.expectEqual(Action.rename_node, actionForCommand(ids.rename_node)); @@ -1695,7 +1925,7 @@ test "edge editing requires a stable edge identifier" { test "context targets carry stable copied identity rather than collection indices" { const node = NodeTarget{ .project_path = "C:\\work\\graph", .id = "node-a" }; - const edge = EdgeTarget{ .project_path = "C:\\work\\graph", .id = "edge-a" }; + const edge = EdgeTarget{ .project_path = "C:\\work\\graph", .id = "edge-a", .summary = "Handoff · Always" }; try std.testing.expectEqualStrings("node-a", node.id); try std.testing.expectEqualStrings("edge-a", edge.id); try std.testing.expectEqualStrings("C:\\work\\graph", edge.project_path); diff --git a/investigation/ui-parity-matrix.md b/investigation/ui-parity-matrix.md index c2486101..053c591e 100644 --- a/investigation/ui-parity-matrix.md +++ b/investigation/ui-parity-matrix.md @@ -791,7 +791,7 @@ native keyboard/accelerator/window proof; the workspace row remains Partial. | Unwired card recovery | Explanation, Wire it up, Mark as entry | Cards with no inbound or outbound edge now render the macOS-visible inline `Wire it up` button and `Mark as entry` link while retaining the same context-menu actions. Pointer and stable-ID UIA routes share the existing edge-drag and declared-entry plumbing. Focused live UIA evidence observed `wire-node-1839192906933644187` enter `Choose a target loop to wire this entry`, then `mark-entry-1970733617255968265` report `Marked as an entry for this session`, remove both unwired controls, and preserve `canvas-card-1386805833417490675`; owned process cleanup was verified. The matched selected/unselected Goal scene adapter now records both visible controls before capture and exercises both routes afterward. **Remaining limit:** this change did not receive a newly authorized paired macOS/Windows screenshot review, so visual parity remains Partial rather than Validated. **Tracked in [#764](https://github.com/scgopi/GraphCode/issues/764).** | Partial | | Worktree reclaim offer | Reclaim and Keep actions on resolved card | Safe matching landed/clean/pushed worktrees retain separate Reclaim/Keep targets, revalidation and session Keep suppression. **Source-only G11 finish, 2026-10-19:** the common Reclaim button is rounded/bordered and both labels use 11-point semibold text in a shared 21-point row, with narrow-zoom paint/hit/UIA bounds and reclaim-over-metric precedence retained. The V2 Main STOPPED resolution/bytes copy is not an equivalent full card to the Windows Goal DONE fixture; no unavailable model copy was fabricated. Historical live descendants/Invoke/link evidence ([#385](https://github.com/scgopi/GraphCode/pull/385), run 35422364203) predates this finish. [Source-only evidence](#canvas-visual-finish-2026-10-19); current action execution and full-card visual equivalence are not established. | Partial | | Composite card actions | Open Group, Pilot Once, Arm Schedule | Canvas and sidebar composite menus expose all three actions. Open Group is live-validated; nested creates, edits, deletes, edge changes, pilot, and arm commands use the daemon's authoritative `subGraphCommand` envelope; and Arm Schedule is disabled unless the decoded pilot state is exactly `piloted` | Partial | -| Edge presentation | Kind style, fired state, cycle label | Windows retains typed optional cycle guards and derives fired state from authoritative `fireCount`, with missing/null legacy fallback. Raw snapshot JSON reaches the production label formatter for maximum/until/flat-pass and empty-guard summaries; signed/null/malformed inputs, Unicode/long text, owned copies, refresh/composite transitions, and allocation-failure cleanup have executable coverage. Kind styling, selected emphasis, fixed 148-by-20 label bounds, ellipsis, and collision placement are retained. This is exact-string and static-geometry evidence only: full visible wording, the macOS context-menu summary, rendered pixels, and live label evidence remain unverified. Narrowed 2026-10-13 to macOS scope (requirements macOS lacks were dropped; see the issue). **Tracked in [#728](https://github.com/scgopi/GraphCode/issues/728) (implementation gap).** | Partial | +| Edge presentation | Kind style, fired state, cycle label | Ordinary edges and unfired guards have no canvas label; a guarded edge with positive `fireCount` shows only `retry ×N`, below card shadows/faces. Existing kind/fired/guard styling, facing card-middle routes, graph clipping and hit geometry remain unchanged. The edge popup now captures owned project/edge identity and a disabled macOS-style summary (display kind/condition, optional transform and guard/pass details), followed by Delete Edge and Edit Edge. **Decision for [#765](https://github.com/scgopi/GraphCode/issues/765): retain Edit Edge as a Windows-only extra after the parity actions, not as a macOS capability.** Focused native HMENU and formatter tests cover order/disabled state, Unicode/long text, escaped native mnemonics, owned lifetime, malformed summary refusal and allocation cleanup; the existing guard formatter is shared without changing its semantics. This is Tier A local semantic/offscreen evidence, not a shown popup, live routing result or visual comparison. Paired macOS/Windows before-and-after captures, all selected/fired/guard and cycle states, live action outcomes and independent different-vendor visual review remain unqualified; the row stays Partial. **Tracked in [#728](https://github.com/scgopi/GraphCode/issues/728) and [#765](https://github.com/scgopi/GraphCode/issues/765).** | Partial | | Edge creation sheet | Kind/condition/transform/cycle controls with conditional validation | The guided native form provides endpoint selectors, conditional fields, validation, keyboard traversal, scrolling, and recap. Menu and connector creation now share the full draft sender, retaining condition, payload transform, all optional cycle guards, and spawn target. Project/composite identity and endpoint IDs/titles are owned across the modal; stale model/selection/client subgraph addressing and missing or changed endpoint choices are explicitly rejected without retargeting. The update subscription can still observe another cached project or refresh independently: outgoing creation explicitly addresses the captured project. Registered pure production-path tests inspect the real client's outgoing queue, including cached-project selection, Unicode/quotes, callback-induced graph changes, cancellation, and allocation failures. The reduced connector sender fails the same accepted-draft fixture that the full sender passes. Earlier live evidence only opened the form and checked endpoints/recap before cancellation; at that point, daemon acceptance and persistence were also unproven. The added headless harness starts the real `graphcoded.exe` with isolated support state; production `sendCreateEdgeDraft` receives a correlated V2 `graphChanged` response, and daemon save/reload preserves edge identity, endpoints, condition, transform, spawn target, and cycle guard. The hosted `windows-shell integration` job 109978958907 (run 36742113814, merged as #540) then drove the real native sheet end to end against the connected protocol stub: Create Edge from the live canvas popup, the source picker carrying the seeded daemon node ID, native keyboard selection of kind/condition/transform, real `SendInput` text entry into payload and both cycle-guard fields with injected-event counts matching exactly (clear 2/2; text 32/32, 24/24, 2/2) and stable `WM_GETTEXT` readback, a rejected empty-template submission that showed the exact reason `Enter the template or script that should carry context.` while leaving the daemon command-log bytes and graph-command count unchanged, and an accepted submission whose `createEdge` wire matched every native choice and was answered by a correlated reply. The preceding intentional-failure run 36739940627 (job 109971468469) recorded the same full evidence before its deliberate late assertion. This is stub-daemon evidence, not `graphcoded` persistence; the accessibility provider still exposes no edge fragment, so rendering is corroborated only by republished graph state and the live Edit Edge hit test; native macOS parity evidence remains absent. Narrowed 2026-10-13 to macOS scope (requirements macOS lacks were dropped; see the issue). **Tracked in [#729](https://github.com/scgopi/GraphCode/issues/729) (testing gap).** | Partial | | Custody child creation | New Child Node on unresolved parents, inherited editable backend, daemon-owned custody | Project-canvas/sidebar node menus consume the tested unresolved-only item plan (5119). Owned popup target/settings/child-only exact-project worktree snapshots feed the existing guarded node form and template/attachment continuation. Original popup context is checked before normal initial selection; final guards never reselect, reject project/composite/address drift or deleted/resolved/type/backend-changed parents, and allow rename/reorder/unresolved progress. Tests exercise the production initializer/transfer boundary and real data-only client queue, including cached B while observing A, root-versus-composite same IDs, UUID/null wire fields, cancellation and allocation failures. `createdBy` produces one create command: GraphStore owns the fired handoff/report-back memo and normal startup. No new protocol or parent/session mutation. Native display/action results, overview right-click, daemon acceptance/persistence, and inherited downstream-send failure handling remain unverified. The merged ordinary-creation path now retains the owned worktree snapshots whose evidence is recorded in Node creation sheet, while custody retains its pre-popup owned snapshot; template backend settings remain a separate residual. Narrowed 2026-10-13 to macOS scope (requirements macOS lacks were dropped; see the issue). **Tracked in [#730](https://github.com/scgopi/GraphCode/issues/730) (implementation gap).** | Partial | | Node creation sheet | Loop-type teaching tiles, conditional fields, backend/model/branch pickers, recap, validation reason | A guided native form provides loop-type/backend/model choices, type-specific fields, explanatory copy, accessible checkboxes, inline validation, keyboard traversal, scrolling, and a live-updating recap. The native Branch picker offers inspection choices plus “This folder”; existing tests cover its empty state and selected binding, and earlier gate evidence covers the recap, Branch picker, and distinct Attach control. Staging now reserves a uniquely named file exclusively: the production append/removal regression first demonstrated A/B/C → remove B → add D overwriting C's bytes, then passed with C's original path and bytes preserved. Offline in-file coverage also checks template-restored/legacy files, preexisting destination collisions, partial-write rollback, allocation failures without orphan copies, invalid inputs, exactly eight files and the ninth rejection, and the exact 10 MiB/+1-byte boundary. Existing attachment DTO/wire tests remain passing; these are no-window helper/filesystem results, not OS input or daemon persistence evidence. Creation choices now own an exact-project snapshot of inspected path/branch strings across cache/model replacement; baseline aliasing and foreign-cache regressions fail before the fix and pass afterward. Noninteractive production-projection tests cover snapshot lifetime, projection without a loaded graph, and allocation-failure cleanup. Separate pure initializer/builder-to-Wire tests verify exact non-default repository/id/path/branch fields, initial/current/template-restored selection, and “This folder” clearing with available choices; legacy empty-choice hidden binding remains unchanged. This does not establish actual native non-default selection or a Git-inspection-to-creation flow. **Still partial:** actual inspected nondefault binding and project-scoped ownership across pumped modals remain unproved; New branch and remote/global branch visibility differ from macOS; authentic OS picker acceptance/cancellation and clipboard paste/drop remain outstanding; native-input evidence remains outstanding. Per-file removed-file reclamation and legacy unguarded cleanup remain separate residuals. Creation now retains the original project/composite context and validates after modal teardown, before attachment transfer, across normal, template-load-error, empty-library, and template-loop submissions without switching selection or client scope. Bounded offline production-boundary RED/GREEN and owned temporary-file tests cover stale-scope refusal, loaded-project closure, same-path refresh/promotion, path-only starts, valid empty composites, template continuation, allocation unwinding, and checked cleanup failures. Guarded staging reserves its attachment-directory leaf exclusively; cancellation/refusal and zero-reference acceptance abandon only that owned leaf, while nonzero accepted attachment bytes survive. Zero-reference drafts preserve existing empty-ID/wire behavior. These are helper/model/unstarted-client-queue proofs, not live modal, OS picker, or daemon-persistence evidence; path-only external disappearance and downstream send failure remain limitations.. A headless real-daemon round-trip sends production `sendCreateNodeDraft`, receives a correlated V2 `graphChanged` response, and confirms node identity/configuration in persisted graph state and after a fresh daemon restart. The hosted `windows-shell integration` job 109912042628 (run 36722807278, merged as #538) then exercised the real native sheet with OS input: four loop-type teaching tiles were selected by verified native mouse points, two invalid submissions each kept the modal open, showed the exact validation reason and dispatched no create command with the daemon command count unchanged, the reason cleared on type change, and an accepted submission dispatched `timeBased`/`copilotCLI`/`capable` with the exact trigger prompt, was answered by the daemon stub, and rendered as exactly one sidebar row and one canvas card. Two accessibility defects were recorded rather than papered over: the pre-submit recap is not refreshed when a tile is clicked, and on both invalid submissions the modal stayed natively visible with the correct title while the desktop UIA child census never recovered after ten retries. Native OS picker acceptance, clipboard paste/drop, physical keyboard entry and macOS parity remain unproven, so this row stays `Partial`. Separately, #539 (merged `d0cce79e`) clamps the form's content controls to the scrollable viewport and sizes the dialog to the monitor work area, so a tall sheet no longer paints outside its frame on a small display; the hosted UIA gate caught a regression in that work where fully offscreen controls were hidden outright and therefore vanished from the automation tree, and the landed fix keeps such controls shown with an empty clip region. That is unit plus hosted-gate evidence over 254 `NativeForms.zig` tests, not a live small-display walkthrough. A blank title is accepted for every type except composite and the daemon names the loop `NewNode`, matching macOS `NodeDraft.isValid`/`untitledFallback` (macOS then asks the loop's backend for a title via `TitleSuggestionClient`, which Windows does not yet do). Client-chosen node ids are now random RFC 4122 version-4 UUIDs in Swift's uppercase form; before the beta17 Dev Box finding they were a 48-bit timestamp behind a constant `00000000-0000-4000-8000-` prefix. Narrowed 2026-10-13 to macOS scope (requirements macOS lacks were dropped; see the issue). **Tracked in [#732](https://github.com/scgopi/GraphCode/issues/732) (implementation gap).** | Partial |