Repository navigation
chore: update to zig 0.16 and zigzag v0.1.5 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7d8bf2f
deb8056
ab9af4c
6cf019e
018e79e
e1da21d
3f625e2
316e53b
efb6ac7
b9ba2b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| .zig-cache/ | ||
| zig-out/ | ||
| zig-pkg/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,12 @@ | |
| .name = .sshz, | ||
| .version = "0.1.0", | ||
| .fingerprint = 0x138d7fea3306d410, | ||
| .minimum_zig_version = "0.16.0", | ||
| .paths = .{ "build.zig", "build.zig.zon", "src" }, | ||
| .dependencies = .{ | ||
| .zigzag = .{ | ||
| .url = "https://github.com/meszmate/zigzag/archive/refs/tags/v0.1.2.tar.gz", | ||
| .hash = "zigzag-0.1.0-YXwYS20gCwATYmA0IOAYQVHykNP--Dl7bKfp2UDE0K2I", | ||
| .url = "https://github.com/meszmate/zigzag/archive/refs/tags/v0.1.5.tar.gz", | ||
| .hash = "zigzag-0.1.2-YXwYS17aEQBlpxPETTrhY5leFh7vV0DpnXJbHogs4Lsv", | ||
|
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Architect Review — CRITICAL The zigzag dependency URL was bumped to v0.1.5 while the hash still targets the v0.1.2 artifact, so Zig's package manager will reject the dependency and Suggestion: Regenerate and commit the correct hash for zigzag v0.1.5 using a Zig 0.16 toolchain (for example, Fix in Cursor | Fix in VSCode Claude (Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.
**Path:** build.zig.zon
**Line:** 9:10
**Comment:**
*CRITICAL: The zigzag dependency URL was bumped to v0.1.5 while the hash still targets the v0.1.2 artifact, so Zig's package manager will reject the dependency and `zig build` will fail in normal workflows.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 検証しました。この指摘は false positive です (4スレッド共通の返信)。 手元の Zig 0.16.0 で ハッシュの prefix
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Customized review instruction saved! Instruction:
Applied to:
💡 To manage or update this instruction, visit: CodeAnt AI Settings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 検証しました。この指摘は false positive です (4スレッド共通の返信)。 手元の Zig 0.16.0 で ハッシュの prefix
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# zigzag v0.1.5 アーカイブ内の build.zig.zon の .version フィールドを確認する
# 期待値: "0.1.5" (正しく更新されていれば) / "0.1.2" (内部バージョンが古いまま)
curl -sL "https://github.com/meszmate/zigzag/archive/refs/tags/v0.1.5.tar.gz" \
| tar -xzO --wildcards '*/build.zig.zon' 2>/dev/null | grep -E '\.version'Repository: midasdf/sshz Length of output: 1943 🏁 Script executed: #!/bin/bash
# Download and check the build.zig.zon version in zigzag v0.1.5
curl -sL "https://github.com/meszmate/zigzag/archive/refs/tags/v0.1.5.tar.gz" \
| tar -xzO --wildcards '*/build.zig.zon' 2>/dev/null | grep -E '\.version|\.name'Repository: midasdf/sshz Length of output: 101 URL の 上流パッケージの v0.1.5 タグの 以下を実行してハッシュを再生成してください: または上流プロジェクト(meszmate/zigzag)に対して、v0.1.5 タグの 🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 検証しました。この指摘は false positive です (4スレッド共通の返信)。 手元の Zig 0.16.0 で ハッシュの prefix
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Zig パッケージマネージャのハッシュプレフィックスは git タグ ではなく、依存パッケージ自身の 現状の ✏️ Learnings added
|
||
| }, | ||
| }, | ||
| } | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,27 +20,28 @@ pub const CheckRequest = struct { | |
| }; | ||
|
|
||
| pub const ResultQueue = struct { | ||
| mutex: std.Thread.Mutex = .{}, | ||
| results: std.ArrayList(CheckResult) = .{}, | ||
| mutex: std.Io.Mutex = std.Io.Mutex.init, | ||
| results: std.ArrayList(CheckResult) = .empty, | ||
| allocator: std.mem.Allocator, | ||
| io: std.Io, | ||
|
|
||
| pub fn init(allocator: std.mem.Allocator) ResultQueue { | ||
| return .{ .allocator = allocator }; | ||
| pub fn init(allocator: std.mem.Allocator, io: std.Io) ResultQueue { | ||
| return .{ .allocator = allocator, .io = io }; | ||
| } | ||
|
|
||
| pub fn deinit(self: *ResultQueue) void { | ||
| self.results.deinit(self.allocator); | ||
| } | ||
|
|
||
| pub fn push(self: *ResultQueue, result: CheckResult) void { | ||
| self.mutex.lock(); | ||
| defer self.mutex.unlock(); | ||
| self.mutex.lockUncancelable(self.io); | ||
| defer self.mutex.unlock(self.io); | ||
| self.results.append(self.allocator, result) catch {}; | ||
| } | ||
|
|
||
| pub fn drain(self: *ResultQueue, allocator: std.mem.Allocator) []CheckResult { | ||
| self.mutex.lock(); | ||
| defer self.mutex.unlock(); | ||
| self.mutex.lockUncancelable(self.io); | ||
| defer self.mutex.unlock(self.io); | ||
| if (self.results.items.len == 0) return &.{}; | ||
| return self.results.toOwnedSlice(allocator) catch return &.{}; | ||
| } | ||
|
|
@@ -51,19 +52,21 @@ pub const StatusChecker = struct { | |
| active_count: std.atomic.Value(u32), | ||
| max_concurrent: u32 = 3, | ||
| shutdown: std.atomic.Value(bool), | ||
| threads: std.ArrayList(std.Thread) = .{}, | ||
| threads_mutex: std.Thread.Mutex = .{}, | ||
| threads: std.ArrayList(std.Thread) = .empty, | ||
| threads_mutex: std.Io.Mutex = std.Io.Mutex.init, | ||
| dispatcher_thread: ?std.Thread = null, | ||
| generation: std.atomic.Value(u32), | ||
| allocator: std.mem.Allocator, | ||
| io: std.Io, | ||
|
|
||
| pub fn init(queue: *ResultQueue, allocator: std.mem.Allocator) StatusChecker { | ||
| pub fn init(queue: *ResultQueue, allocator: std.mem.Allocator, io: std.Io) StatusChecker { | ||
| return .{ | ||
| .queue = queue, | ||
| .active_count = std.atomic.Value(u32).init(0), | ||
| .shutdown = std.atomic.Value(bool).init(false), | ||
| .generation = std.atomic.Value(u32).init(0), | ||
| .allocator = allocator, | ||
| .io = io, | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -78,9 +81,12 @@ pub const StatusChecker = struct { | |
| } | ||
|
|
||
| fn joinAllThreads(self: *StatusChecker) void { | ||
| self.threads_mutex.lock(); | ||
| const threads = self.threads.toOwnedSlice(self.allocator) catch return; | ||
| self.threads_mutex.unlock(); | ||
| self.threads_mutex.lockUncancelable(self.io); | ||
| const threads = self.threads.toOwnedSlice(self.allocator) catch { | ||
| self.threads_mutex.unlock(self.io); | ||
| return; | ||
| }; | ||
| self.threads_mutex.unlock(self.io); | ||
|
Comment on lines
+84
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Severity Level: Critical 🚨- ❌ TUI status refresh can deadlock on low-memory allocation failure.
- ❌ `StatusChecker.deinit` may hang, blocking clean TUI shutdown.
- ⚠️ Background status-check worker threads may remain unjoined on error.Steps of Reproduction ✅1. Start the TUI via `main` at `src/main.zig:8-36` (which calls `launchTui` at
`src/main.zig:56-77` and constructs `app.Model` through `zz.Program(app.Model).init`).
2. In `Model.init` at `src/app.zig:61-89`, SSH host configuration is loaded and
`startStatusChecks()` is called at `src/app.zig:86`, which builds `CheckRequest` values
and calls `self.status_checker.checkAll(requests.items)` at `src/app.zig:130-131`.
3. Inside `StatusChecker.checkAll` at `src/checker.zig:92-111`, the first operation is
`self.joinAllThreads();` at `src/checker.zig:98`, which calls `joinAllThreads` at
`src/checker.zig:83-89`. There, `threads_mutex` is locked at line 84, and
`self.threads.toOwnedSlice(self.allocator)` at line 85 may fail under memory pressure (it
allocates a copy of the internal `threads` array using the same allocator used throughout
the TUI).
4. When `toOwnedSlice` fails, the `catch return` at `src/checker.zig:85` exits
`joinAllThreads` without executing the unlock at line 86, leaving `threads_mutex`
permanently locked. On the next status refresh (e.g., user presses 'r' in the TUI, which
calls `startStatusChecks` at `src/app.zig:115-133`, leading again to
`status_checker.checkAll` and `joinAllThreads`), or during shutdown via
`self.status_checker.deinit()` at `src/app.zig:92-100`,
`threads_mutex.lockUncancelable(self.io)` at `src/checker.zig:84` blocks forever,
deadlocking the status-checking logic and freezing that part of the TUI.Fix in Cursor | Fix in VSCode Claude (Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/checker.zig
**Line:** 84:86
**Comment:**
*Possible Bug: `joinAllThreads` acquires `threads_mutex` and then returns immediately on allocation failure from `toOwnedSlice` without releasing the mutex. This leaves the mutex permanently locked, so later calls that need the same mutex can block forever. Ensure the mutex is always released on every exit path (including error paths).
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 3f625e2。 const threads = self.threads.toOwnedSlice(self.allocator) catch {
self.threads_mutex.unlock(self.io);
return;
}; |
||
| for (threads) |t| t.join(); | ||
| self.allocator.free(threads); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
@@ -131,27 +137,36 @@ pub const StatusChecker = struct { | |
| _ = self.active_count.fetchSub(1, .release); | ||
| continue; | ||
| }; | ||
| self.threads_mutex.lock(); | ||
| self.threads_mutex.lockUncancelable(self.io); | ||
| self.threads.append(self.allocator, thread) catch { | ||
| self.threads_mutex.unlock(); | ||
| self.threads_mutex.unlock(self.io); | ||
| thread.join(); | ||
| continue; | ||
| }; | ||
| self.threads_mutex.unlock(); | ||
| self.threads_mutex.unlock(self.io); | ||
| } | ||
| } | ||
|
|
||
| fn checkWorker(self: *StatusChecker, host_index: usize, hostname: []const u8, port: u16, gen: u32) void { | ||
| defer _ = self.active_count.fetchSub(1, .release); | ||
| if (self.shutdown.load(.acquire)) return; | ||
|
|
||
| const status = tcpCheck(hostname, port); | ||
| const status = tcpCheck(self.io, hostname, port); | ||
| self.queue.push(.{ .host_index = host_index, .status = status, .generation = gen }); | ||
| } | ||
| }; | ||
|
|
||
| fn tcpCheck(hostname: []const u8, port: u16) HostStatus { | ||
| const stream = std.net.tcpConnectToHost(std.heap.page_allocator, hostname, port) catch return .offline; | ||
| stream.close(); | ||
| fn tcpCheck(io: std.Io, hostname: []const u8, port: u16) HostStatus { | ||
| // Try IPv4/IPv6 literals first; HostName.init rejects ':' so a bare IPv6 | ||
| // address would otherwise always report offline. | ||
| if (std.Io.net.IpAddress.parse(hostname, port)) |addr| { | ||
| const stream = addr.connect(io, .{ .mode = .stream }) catch return .offline; | ||
| stream.close(io); | ||
| return .online; | ||
| } else |_| {} | ||
|
|
||
| const host = std.Io.net.HostName.init(hostname) catch return .offline; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For SSH configs whose effective Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 3f625e2。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For SSH configs whose effective host name is a resolver/hosts-file name that is valid for Useful? React with 👍 / 👎. |
||
| const stream = host.connect(io, port, .{ .mode = .stream }) catch return .offline; | ||
| stream.close(io); | ||
| return .online; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The dependency hash does not match the updated
v0.1.5tarball URL (it is still the oldv0.1.2hash), so Zig will reject this dependency during fetch/resolve and the project will fail to build. Regenerate and commit the correct hash for thev0.1.5archive. [possible bug]Severity Level: Critical 🚨
Steps of Reproduction ✅
Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
検証しました。この指摘は false positive です (4スレッド共通の返信)。
手元の Zig 0.16.0 で
zig fetch --save=zigzag https://github.com/meszmate/zigzag/archive/refs/tags/v0.1.5.tar.gzを実行した結果、得られたハッシュは現状のbuild.zig.zonの値と完全一致しました:ハッシュの prefix
zigzag-0.1.2-は 上流 zigzag の v0.1.5 タグ内build.zig.zonの.versionfield がまだ"0.1.2"のまま であることに由来しており、Zig パッケージマネージャはこの内部 version を prefix に採用する仕様です (CodeRabbit のスクリプト調査結果と一致)。URL のv0.1.5と内部 version0.1.2の不一致は上流側のメンテナンス問題であって、ハッシュ自体は正しい値です。zig buildおよびzig build testは Zig 0.16.0 で問題なく成功します。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Customized review instruction saved!
Instruction:
Applied to:
**/*.zon💡 To manage or update this instruction, visit: CodeAnt AI Settings