Skip to content

feat(windows): platform-aware title bar + WSL hooks - #3

Closed
guan4tou2 wants to merge 1 commit into
mainfrom
windows-support-v2
Closed

feat(windows): platform-aware title bar + WSL hooks#3
guan4tou2 wants to merge 1 commit into
mainfrom
windows-support-v2

Conversation

@guan4tou2

@guan4tou2 guan4tou2 commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Slimmed and rebased onto current main (v0.3.2). Keeps only what main still lacks — main has since fixed the api-server scan type and grown a fuller electron-builder.yml + release workflow, so those parts were dropped.

Changes (9 files)

  • Title barwindows.ts uses platform-conditional titleBarStyle (keep hiddenInset on macOS; hidden + native titleBarOverlay on Windows/Linux so min/max/close stay usable). main still ships hiddenInset, so on Windows the controls are otherwise unreachable from the window.
  • Platform plumbing — expose process.platform via preload (+ env.d.ts); App.tsx drops mac-only traffic-light padding on Windows, clears the window-controls overlay, and shows Ctrl instead of .
  • WSL hookshooks/redlog-send.sh (WSL-aware event sender) + hooks/wsl-redlog-test.sh (diagnostic): resolve the token path from the Windows profile and reach the API over WSL2 mirrored networking.
  • .gitattributes — pin shell/python hooks to LF (CRLF shebang breaks under WSL).
  • Docsdocs/windows-wsl-setup.md + README pointer: setup, packaging, WSL networking, and operational privacy / isolating private activity.

Verification

Changed files pass TypeScript syntax validation; the same title-bar/platform edits previously bundled cleanly (57 modules). Full electron-vite build couldn't run on the dev machine because Smart App Control blocks rollup's native binary (OS policy, unrelated to this change).

Summary by CodeRabbit

  • New Features

    • Added Windows and WSL setup guidance, including build, packaging, networking, and troubleshooting instructions.
    • Added WSL utilities for testing RedLog connectivity and sending event data safely when available.
    • Added platform-specific window controls and keyboard shortcut labels for macOS and Windows/Linux.
  • Documentation

    • Documented engagement isolation, target scoping, hook behavior, and Windows/WSL operational considerations.
  • Chores

    • Standardized Unix line endings for shell, scripting, and Python files.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds Windows and WSL build guidance, WSL-to-RedLog hook scripts, connectivity testing, Unix line-ending rules, and platform-aware Electron title-bar and shortcut behavior.

Changes

Cross-platform support

Layer / File(s) Summary
Windows and WSL setup guidance
.gitattributes, README.md, docs/windows-wsl-setup.md
Documents Windows prerequisites, packaging, WSL networking and logging, privacy isolation, scope controls, and Unix line endings for scripts.
WSL event sender
hooks/redlog-send.sh
Discovers native or Windows-mapped RedLog credentials, probes reachable API hosts, builds event payloads, and sends authenticated events.
WSL connectivity validation
hooks/wsl-redlog-test.sh
Validates WSL prerequisites and credentials, checks API reachability, and verifies that an authenticated test event increases the event count.
Platform-aware desktop UI
src/main/windows.ts, src/preload/index.ts, src/renderer/src/App.tsx, src/renderer/src/env.d.ts
Exposes the host platform, applies platform-specific title-bar settings, and displays macOS or non-macOS shortcut labels.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant WSLHook as redlog-send.sh
  participant Config as .redlog files
  participant RedLogAPI
  Operator->>WSLHook: Invoke event hook
  WSLHook->>Config: Read api-port and api-token
  WSLHook->>RedLogAPI: Probe /api/health
  WSLHook->>RedLogAPI: POST authenticated event
Loading

Possibly related PRs

  • guan4tou2/REDLOG#1: Contains overlapping platform-aware Electron title-bar, preload platform exposure, and renderer shortcut changes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main Windows-focused changes: platform-aware title bar behavior and WSL hook support.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch windows-support-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (1)
src/renderer/src/App.tsx (1)

86-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Avoid a fixed right-side title-bar reserve.

pr-36 assumes native controls are always on the right and exactly 144px wide. Electron’s current WCO guidance recommends env(titlebar-area-x)/env(titlebar-area-width) because Linux controls may appear on the left, right, or both; verify this against Electron 33.2.1 and target desktop environments, then size the title bar from the safe area instead. (electronjs.org)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/renderer/src/App.tsx` around lines 86 - 93, Replace the fixed non-Mac
pr-36 padding in the title-bar container around the project name and controls
with Window Controls Overlay safe-area sizing using env(titlebar-area-x) and
env(titlebar-area-width). Account for controls positioned on either side across
Electron 33.2.1 target desktop environments, while preserving the existing Mac
behavior and no-drag controls.

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/windows-wsl-setup.md`:
- Around line 109-112: Update the redlog-send.sh invocations in the event
example to use the configured absolute repository path established by the
preceding diagnostic example, rather than the relative hooks/redlog-send.sh
path. Preserve the existing arguments and fire-and-forget workflow.
- Line 160: Update the “Per-engagement isolation” heading to use the hyphenated
form “built-in.”
- Around line 13-17: Align the Node.js requirements in docs/windows-wsl-setup.md
(lines 13-17) and README.md (lines 40-43) with the versions tested by Electron’s
native rebuild toolchain. Update both documents consistently, include Node 24
only if supported by the repository tooling, and remove the blanket “no prebuilt
better-sqlite3 binary” claim unless source rebuilds are actually required.

In `@hooks/redlog-send.sh`:
- Around line 90-94: Replace the hand-rolled _esc JSON construction in the
Python-unavailable fallback of hooks/redlog-send.sh with a real JSON encoder
such as jq -n, passing AGENT_TYPE, SUBTYPE, and CMD as encoded values so
multiline text, tabs, quotes, backslashes, and other control characters remain
valid JSON; alternatively, require Python instead of emitting an unsafe payload.
- Around line 49-53: Update the cache setup in redlog-send.sh to use a per-user
cache directory with 0700 permissions instead of the predictable shared /tmp
path, and resolve _gw before reading the cache. In the cached-host validation
near _cache and HOST, accept only 127.0.0.1 or the resolved _gw value before
performing the health check; discard all other cached hosts.

In `@hooks/wsl-redlog-test.sh`:
- Around line 120-125: Make the POST payload in the WSL round-trip test unique
on each run by generating a nonce and incorporating it into data.command. Keep
the existing event structure and HTTP 201 assertion unchanged, while ensuring
the command still exercises the intended redlog-wsl-test path.

In `@README.md`:
- Line 37: Update the README build instructions around the dist:win, dist:mac,
and dist:linux targets to document the required build host or CI environment for
each production package, including AppImage and macOS DMG signing constraints.
Replace the current direct-alternatives wording with per-target guidance while
preserving the existing command references.

In `@src/renderer/src/App.tsx`:
- Line 98: Define a single markerShortcut constant for the platform-specific
marker shortcut label, then reuse it in the button tooltip and dashboard display
instead of maintaining separate inline strings. Ensure both locations render the
same label for macOS and non-macOS platforms.

---

Nitpick comments:
In `@src/renderer/src/App.tsx`:
- Around line 86-93: Replace the fixed non-Mac pr-36 padding in the title-bar
container around the project name and controls with Window Controls Overlay
safe-area sizing using env(titlebar-area-x) and env(titlebar-area-width).
Account for controls positioned on either side across Electron 33.2.1 target
desktop environments, while preserving the existing Mac behavior and no-drag
controls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 027b66ac-fc51-48fe-88c1-f61b69c84a58

📥 Commits

Reviewing files that changed from the base of the PR and between 300e261 and c3b958e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • .gitattributes
  • README.md
  • docs/windows-wsl-setup.md
  • electron-builder.yml
  • hooks/redlog-send.sh
  • hooks/wsl-redlog-test.sh
  • package.json
  • src/core/api-server.ts
  • src/main/windows.ts
  • src/preload/index.ts
  • src/renderer/src/App.tsx
  • src/renderer/src/env.d.ts

Comment thread docs/windows-wsl-setup.md
Comment on lines +13 to +17
| Requirement | Notes |
|---|---|
| **Node.js 20 or 22 (LTS)** | **Not 24+** — newer Node has no prebuilt `better-sqlite3` binary yet, forcing a source build. |
| **Visual Studio Build Tools** | Install the **"Desktop development with C++"** workload. |
| **Python 3** | Required by `node-gyp` for the native rebuild. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== relevant files =="
git ls-files | rg '(^|/)(README\.md|docs/windows-wsl-setup\.md)$' || true

echo
echo "== docs/windows-wsl-setup.md around Node setup =="
if [ -f docs/windows-wsl-setup.md ]; then
  nl -ba docs/windows-wsl-setup.md | sed -n '1,80p'
fi

echo
echo "== README.md around Node/rebuild text =="
if [ -f README.md ]; then
  nl -ba README.md | sed -n '1,80p'
fi

echo
echo "== package files and engine/dependency clues =="
fd '(^|/)(package.json|package-lock.json|pnpm-lock.yaml|yarn.lock)$' -t f -x sh -c 'echo "--- $1"; sed -n "1,220p" "$1" | rg -n "engines|node|better-sqlite3|node-pty|electron|rebuild" -C 2 || true' sh {}

echo
echo "== search Node/exclusion mentions =="
rg -n "Node\.js [0-9]|Node [0-9]+|node [0-9]+|20 or 22|not 24|24|22|20|better-sqlite3|node-pty" -S .

Repository: guan4tou2/REDLOG

Length of output: 303


🌐 Web query:

Node.js current LTS version release date 24 status July 2026

💡 Result:

As of today, July 28, 2026, Node.js 24 (codenamed "Krypton") is in the Active LTS (Long Term Support) phase [1][2][3]. The most recent release for this version line is v24.19.0, which was prepared on July 22, 2026 [4]. Node.js 24 entered the Active LTS phase on October 28, 2025, and is scheduled to remain in this status until it transitions to Maintenance mode on October 20, 2026, with an eventual End-of-Life date of April 30, 2028 [1][2][3]. Additionally, the Node.js project announced security releases for the 24.x release line scheduled for, or shortly after, July 27, 2026, to address identified vulnerabilities [5].

Citations:


🌐 Web query:

better-sqlite3 Node.js 24 prebuilt bindings npm package

💡 Result:

As of July 28, 2026, better-sqlite3 supports Node.js 24 [1][2]. Prebuilt binaries for Node.js 24 were introduced in version 12.1.0 of the package [3][2]. If you are encountering installation issues or runtime errors indicating a version mismatch (such as being compiled against an older NODE_MODULE_VERSION), ensure your project is using better-sqlite3 version 12.1.0 or higher [2]. You can update your dependency in package.json to at least 12.1.0 to resolve this [2]: "better-sqlite3": "^12.1.0" If you are on an older version of the library (e.g., 11.x), it will not have the necessary prebuilt binaries for Node.js 24, which can lead to installation failures or attempts to compile from source [2]. Additionally, recent updates to better-sqlite3 have refactored how binaries are handled, moving away from prebuild-install and towards including prebuilt binaries directly within the package, with automatic selection at runtime [4]. If you still encounter issues: 1. Ensure you have updated to the latest version of better-sqlite3 [2]. 2. If compilation from source is required, ensure your environment has the necessary build tools (like python, make, and a C++ compiler) installed, as prebuilt binaries might not be available for every niche platform or architecture [4]. 3. For specific errors, check if you have cached older dependencies; running npm cache clean or deleting node_modules and package-lock.json before reinstalling is recommended [5].

Citations:


🌐 Web query:

node-pty Electron Node 24 build native module

💡 Result:

To use node-pty in an Electron application with Node 24, you must recompile the native module against the specific version of Electron (and its bundled Node.js ABI) rather than your system's Node.js version [1][2][3]. Failing to do so causes ABI mismatch errors, such as posix_spawnp failed or ModuleNotFoundError [1][4][5]. The recommended approach is to use the @electron/rebuild package [6][2][3]. Standard Workflow for Rebuilding 1. Install @electron/rebuild as a development dependency: npm install --save-dev @electron/rebuild 2. After installing your dependencies (which may install prebuilt binaries for your host system), trigger a rebuild specifically for your Electron version: npx electron-rebuild -f -w node-pty This command forces (-f) a rebuild of the specified module (-w) against the Electron version detected in your project [1][6]. Important Considerations - Automation: Ensure this step is part of your build process. If you use Electron Forge, it typically handles this automatically [2][3]. If using Electron Builder or other bundlers, you may need to add it to your postinstall script or as a specific build hook to ensure it runs during packaging [1][4][7]. - ABI Mismatches: If you encounter errors about missing files (e.g.,../build/Release/pty.node), the module was likely compiled for the wrong architecture or Node ABI [5][8]. Always verify that your rebuild step targets the correct Electron version [6]. - System Requirements: Building native modules requires a C++ compiler and python (typically required by node-gyp) installed on your system [6][2]. If you see errors related to missing build tools (e.g., distutils), ensure your development environment is configured for native compilation [1]. - Hoisted Dependencies: If you are using npm workspaces, ensure that @electron/rebuild can locate node-pty, especially if it is hoisted to the root of your repository [7]. You may need to specify the correct path to the module [7][9].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== docs/windows-wsl-setup.md around Node setup =="
if [ -f docs/windows-wsl-setup.md ]; then
  awk '{printf "%5d\t%s\n", NR, $0}' docs/windows-wsl-setup.md | sed -n '1,80p'
fi

echo
echo "== README.md around Node/rebuild text =="
if [ -f README.md ]; then
  awk '{printf "%5d\t%s\n", NR, $0}' README.md | sed -n '1,80p'
fi

echo
echo "== package files and dependency clues =="
fd '(^|/)(package.json|package-lock.json|pnpm-lock.yaml|yarn.lock)$' -t f -x sh -c 'echo "--- $1"; awk "{printf \"%5d\\t%s\\n\", NR, \$0}" "$1" | rg -n "engines|node|better-sqlite3|node-pty|electron|rebuild|`@electron/rebuild`" -C 3 || true' sh {}

echo
echo "== repository Node/native module mentions =="
rg -n "Node\.js [0-9]+|Node [0-9]+|node [0-9]+|20 or 22|not 24|24|22|20|better-sqlite3|node-pty|Node\.js LTS|EOL|Maintenance" -S .

echo
echo "== Node release metadata from public endpoint, deterministic parse =="
python3 - <<'PY'
import json, urllib.request
for version in ["22", "24"]:
    url = f"https://nodejs.org/download/release/index.json"
    try:
        data = json.load(urllib.request.urlopen(url, timeout=20))
    except Exception as e:
        print(f"NODE_INDEX_ERROR-{version}: {type(e).__name__}: {e}")
        continue
    versions = [r["version"] for r in data if r["version"].startswith("v" + version + ".")]
    print(f"NODE_VERSION_INDEX-{version}: count={len(versions)} latest={max(versions) if versions else None}")
    major_releases = {v["version"]: {"status": v["status"], "lts": v["lts"], "modules": v.get("modules")} for v in data if v["version"].startswith("v" + version + ".")}
    print("NODE_MAJOR_STATS-", version, {k: major_releases[k] for k in [k for k in major_releases if k.startswith(("v20.", "v22.", "v24."))]})
PY

Repository: guan4tou2/REDLOG

Length of output: 50373


Align the Node.js support policy across both setup documents.

Docs currently direct users from EOL Node.js 20 toward Node 20–22 and exclude Node 24+, while Node 24 is LTS and better-sqlite3 12.1.0+ supports Node 24. Update both files to state what versions Electron's native rebuild is tested for and remove the blanket “no prebuild” claim for 24+ unless the repo toolchain requires source rebuilds.

  • docs/windows-wsl-setup.md#L13-L17
  • README.md#L40-L43
📍 Affects 2 files
  • docs/windows-wsl-setup.md#L13-L17 (this comment)
  • README.md#L40-L43
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/windows-wsl-setup.md` around lines 13 - 17, Align the Node.js
requirements in docs/windows-wsl-setup.md (lines 13-17) and README.md (lines
40-43) with the versions tested by Electron’s native rebuild toolchain. Update
both documents consistently, include Node 24 only if supported by the repository
tooling, and remove the blanket “no prebuilt better-sqlite3 binary” claim unless
source rebuilds are actually required.

Source: MCP tools

Comment thread docs/windows-wsl-setup.md
Comment on lines +109 to +112
# Send an event from any script/hook (fire-and-forget; no-ops if unreachable)
hooks/redlog-send.sh "nmap -sV $TARGET" command_start
nmap -sV "$TARGET"
hooks/redlog-send.sh "nmap -sV $TARGET" command_end "{\"exit_code\":$?}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make the hook path independent of the working directory.

The example says this can be called from any script/hook, but hooks/redlog-send.sh is relative and only works when the current directory is the repository root. Use a configured absolute repository path, as the preceding diagnostic example does.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/windows-wsl-setup.md` around lines 109 - 112, Update the redlog-send.sh
invocations in the event example to use the configured absolute repository path
established by the preceding diagnostic example, rather than the relative
hooks/redlog-send.sh path. Preserve the existing arguments and fire-and-forget
workflow.

Comment thread docs/windows-wsl-setup.md
> integrity; plus per-producer enable/disable in project config. Until then, use
> workspace isolation (§5.1) as the real control.

### 5.3 Per-engagement isolation (built in)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the hyphenated form built-in.

-### 5.3 Per-engagement isolation (built in)
+### 5.3 Per-engagement isolation (built-in)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### 5.3 Per-engagement isolation (built in)
### 5.3 Per-engagement isolation (built-in)
🧰 Tools
🪛 LanguageTool

[grammar] ~160-~160: Use a hyphen to join words.
Context: ... ### 5.3 Per-engagement isolation (built in) Each project is a separate director...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/windows-wsl-setup.md` at line 160, Update the “Per-engagement isolation”
heading to use the hyphenated form “built-in.”

Source: Linters/SAST tools

Comment thread hooks/redlog-send.sh
Comment on lines +49 to +53
_cache="${TMPDIR:-/tmp}/.redlog-host-${PORT}"
HOST=""
if [[ -f "${_cache}" ]]; then
HOST="$(cat "${_cache}" 2>/dev/null)"
curl -sf --connect-timeout 1 --max-time 2 "http://${HOST}:${PORT}/api/health" >/dev/null 2>&1 || HOST=""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🔴 Critical | ⚡ Quick win

Store and validate the cached host securely.

Line 49 uses a predictable shared /tmp cache. Another local user can pre-seed it with an attacker host; after its fake health response, lines 97-99 send the RedLog bearer token there. Use a per-user 0700 cache directory and only accept 127.0.0.1 or the currently resolved gateway as cached values.

Proposed direction
- _cache="${TMPDIR:-/tmp}/.redlog-host-${PORT}"
+ _cache_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/redlog"
+ (umask 077 && mkdir -p "${_cache_dir}") || exit 0
+ _cache="${_cache_dir}/host-${PORT}"

Also resolve _gw before reading the cache and discard cached values other than 127.0.0.1 or "${_gw}".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hooks/redlog-send.sh` around lines 49 - 53, Update the cache setup in
redlog-send.sh to use a per-user cache directory with 0700 permissions instead
of the predictable shared /tmp path, and resolve _gw before reading the cache.
In the cached-host validation near _cache and HOST, accept only 127.0.0.1 or the
resolved _gw value before performing the health check; discard all other cached
hosts.

Comment thread hooks/redlog-send.sh
Comment on lines +90 to +94
else
# Minimal fallback without python3 (no EXTRA merge; basic escaping).
_esc() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
PAYLOAD="{\"agent_type\":\"${AGENT_TYPE}\",\"data\":{\"subtype\":\"${SUBTYPE}\",\"command\":\"$(_esc "${CMD}")\",\"source\":\"native\"}}"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not hand-roll JSON escaping in the fallback.

The fallback only escapes \ and ". A multiline command, tab, or other control character produces invalid JSON, so the hook silently drops the event. Use a real JSON encoder (for example jq -n) when Python is unavailable, or explicitly require Python.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hooks/redlog-send.sh` around lines 90 - 94, Replace the hand-rolled _esc JSON
construction in the Python-unavailable fallback of hooks/redlog-send.sh with a
real JSON encoder such as jq -n, passing AGENT_TYPE, SUBTYPE, and CMD as encoded
values so multiline text, tabs, quotes, backslashes, and other control
characters remain valid JSON; alternatively, require Python instead of emitting
an unsafe payload.

Comment thread hooks/wsl-redlog-test.sh
Comment on lines +120 to +125
code="$(curl -s -o /dev/null -w '%{http_code}' -X POST "${base}/api/events" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"agent_type":"shell","data":{"subtype":"command_start","command":"redlog-wsl-test echo hello","shell":"wsl-test"}}' \
2>/dev/null)"
[[ "${code}" == "201" ]] && ok "POST /api/events accepted (HTTP 201)" || no "POST /api/events returned HTTP ${code:-none}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make the round-trip event unique.

This posts the same payload on every run. The API returns 409 for duplicates, so a rerun within the dedup window falsely reports a broken WSL path. Add a nonce to data.command before posting.

Proposed fix
+nonce="$(date +%s%N)-$$"
 code="$(curl -s -o /dev/null -w '%{http_code}' -X POST "${base}/api/events" \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "Content-Type: application/json" \
-  -d '{"agent_type":"shell","data":{"subtype":"command_start","command":"redlog-wsl-test echo hello","shell":"wsl-test"}}' \
+  -d "{\"agent_type\":\"shell\",\"data\":{\"subtype\":\"command_start\",\"command\":\"redlog-wsl-test echo hello ${nonce}\",\"shell\":\"wsl-test\"}}" \
   2>/dev/null)"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
code="$(curl -s -o /dev/null -w '%{http_code}' -X POST "${base}/api/events" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"agent_type":"shell","data":{"subtype":"command_start","command":"redlog-wsl-test echo hello","shell":"wsl-test"}}' \
2>/dev/null)"
[[ "${code}" == "201" ]] && ok "POST /api/events accepted (HTTP 201)" || no "POST /api/events returned HTTP ${code:-none}"
nonce="$(date +%s%N)-$$"
code="$(curl -s -o /dev/null -w '%{http_code}' -X POST "${base}/api/events" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"agent_type\":\"shell\",\"data\":{\"subtype\":\"command_start\",\"command\":\"redlog-wsl-test echo hello ${nonce}\",\"shell\":\"wsl-test\"}}" \
2>/dev/null)"
[[ "${code}" == "201" ]] && ok "POST /api/events accepted (HTTP 201)" || no "POST /api/events returned HTTP ${code:-none}"
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 125-125: Note that A && B || C is not if-then-else. C may run when A is true.

(SC2015)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hooks/wsl-redlog-test.sh` around lines 120 - 125, Make the POST payload in
the WSL round-trip test unique on each run by generating a nonce and
incorporating it into data.command. Keep the existing event structure and HTTP
201 assertion unchanged, while ensuring the command still exercises the intended
redlog-wsl-test path.

Comment thread README.md Outdated

# Package as DMG/installer
npx electron-builder --mac # or --win / --linux
npm run dist:win # or dist:mac / dist:linux (electron-builder)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)(README\.md|package\.json|docs/windows-wsl-setup\.md)$' || true

echo "== README relevant lines =="
if [ -f README.md ]; then
  nl -ba README.md | sed -n '30,50p'
fi

echo "== package scripts =="
if [ -f package.json ]; then
  python3 - <<'PY'
import json
with open('package.json') as f:
    p=json.load(f)
print(json.dumps(p.get("scripts", {}), indent=2))
print("build:", p.get("build"))
print("devDependencies electron-builder:", p.get("devDependencies", {}).get("electron-builder"))
print("dependencies:", p.get("dependencies", {}))
PY
fi

echo "== searches for dist scripts =="
rg -n "dist:(win|mac|linux)|multi-platform|electron-builder|electron" package.json README.md docs 2>/dev/null || true

Repository: guan4tou2/REDLOG

Length of output: 283


🌐 Web query:

electron documentation multi-platform build AppImage cross-compile Windows macOS

💡 Result:

Electron-builder does not support cross-compiling AppImage targets directly from macOS or Windows [1]. By design, AppImages must be built on a Linux environment [1]. To build an AppImage on a non-Linux host, you must use Docker [2][1]. Electron-builder provides official Docker images (such as electronuserland/builder) that allow you to package your application for Linux from any platform that supports Docker [3][1]. Key requirements and considerations for multi-platform builds: 1. Native Dependencies: If your application uses native C++ modules, cross-compilation is notoriously difficult [4]. While electron-builder has improved its ability to handle native module rebuilding [5], it is generally recommended to either use prebuilt binaries (prebuild/prebuild-install) or have dedicated build nodes for each target platform to ensure compatibility [4][6]. 2. Docker Workflow: To build an AppImage from macOS or Windows, you typically run a Docker container that mounts your project directory [1]. This environment provides the necessary Linux toolchain to generate the AppImage [1]. Example command structure: docker run --rm -ti \ --env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|...') \ -v ${PWD}:/project \ electronuserland/builder \ /bin/bash -c "npm install && npx electron-builder --linux AppImage" 3. Limitations: While electron-builder facilitates multi-platform builds, certain outputs are platform-restricted [2]. For example, macOS DMG files should generally be built on a macOS host due to code signing requirements, and Windows installers (.exe/.msi) are best built on a Windows host [2][7]. For most production workflows, the recommended approach is to use a CI/CD pipeline (such as GitHub Actions) that spawns separate runners for Linux, macOS, and Windows, rather than attempting to cross-compile every target from a single machine [2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== package scripts and electron-builder config =="
python3 - <<'PY'
import json
from pathlib import Path
p=json.loads(Path('package.json').read_text())
print(json.dumps({
    "scripts": p.get("scripts", {}),
    "build": p.get("build"),
    "electron-builder-version": p.get("devDependencies", {}).get("electron-builder")
}, indent=2, sort_keys=True))
PY

echo "== dist script target grep =="
python3 - <<'PY'
from pathlib import Path
for f in ['README.md','docs/windows-wsl-setup.md','package.json']:
    text=Path(f).read_text(errors='replace').splitlines()
    for i,line in enumerate(text,1):
        if 'dist:' in line.lower() or 'electron-builder' in line.lower() or 'multi-platform' in line.lower() or 'AppImage' in line:
            print(f"{f}:{i}: {line}")
PY

echo "== README lines 30-45 =="
python3 - <<'PY'
from pathlib import Path
lines=Path('README.md').read_text(errors='replace').splitlines()
for i in range(30, min(len(lines), 48)+1):
    print(f"{i:3}: {lines[i-1]}")
PY

echo "== docs/windows-wsl-setup relevant =="
python3 - <<'PY'
from pathlib import Path
lines=Path('docs/windows-wsl-setup.md').read_text(errors='replace').splitlines()
for i,line in enumerate(lines,1):
    if 'node' in line.lower() or 'dist:' in line.lower() or 'electron-builder' in line.lower():
        print(f"{i:4}: {line}")
PY

Repository: guan4tou2/REDLOG

Length of output: 3698


Document the build host required for each dist target.

dist:win/dist:mac/dist:linux do not all share the same host requirements for production packaging, especially AppImage/macOS DMG signing. Add per-target host/CI guidance instead of presenting them as direct alternatives.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 37, Update the README build instructions around the
dist:win, dist:mac, and dist:linux targets to document the required build host
or CI environment for each production package, including AppImage and macOS DMG
signing constraints. Replace the current direct-alternatives wording with
per-target guidance while preserving the existing command references.

Source: MCP tools

Comment thread src/renderer/src/App.tsx
onClick={() => setShowMarker(true)}
className="px-2.5 py-1 text-[10px] font-medium bg-red-500/10 text-red-400 rounded-md hover:bg-red-500/20 border border-red-500/15 transition-colors"
title="Ctrl+Shift+M"
title={isMac ? '⌘⇧M' : 'Ctrl+Shift+M'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use one marker shortcut label everywhere.

The button tooltip shows Ctrl+Shift+M, while the dashboard shows Ctrl+⇧M. Reuse a single markerShortcut constant to keep the hints consistent.

Also applies to: 256-256

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/renderer/src/App.tsx` at line 98, Define a single markerShortcut constant
for the platform-specific marker shortcut label, then reuse it in the button
tooltip and dashboard display instead of maintaining separate inline strings.
Ensure both locations render the same label for macOS and non-macOS platforms.

Slimmed re-apply onto current main — keeps only what main still lacks
(main already fixed the api-server scan type and has a fuller
electron-builder.yml + release workflow):

- windows.ts: platform-conditional titleBarStyle — keep hiddenInset on macOS,
  use hidden + native titleBarOverlay on Windows/Linux so min/max/close stay
  usable behind the custom drag region.
- Expose process.platform via preload; App.tsx drops mac-only traffic-light
  padding on Windows, pads right to clear the window-controls overlay, and shows
  Ctrl instead of the Cmd glyph in shortcut hints.
- hooks/redlog-send.sh + hooks/wsl-redlog-test.sh: WSL-aware event sender and
  diagnostic (resolve the token path from the Windows profile; reach the API
  over WSL2 mirrored networking).
- .gitattributes: pin shell/python hooks to LF (CRLF shebang breaks under WSL).
- docs/windows-wsl-setup.md + README: setup, packaging, WSL networking, and
  operational privacy / isolating private activity.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@guan4tou2
guan4tou2 force-pushed the windows-support-v2 branch from c3b958e to f4379bb Compare July 29, 2026 01:42
@guan4tou2 guan4tou2 changed the title feat(windows): platform-aware title bar, packaging & WSL hooks feat(windows): platform-aware title bar + WSL hooks Jul 29, 2026
@guan4tou2

Copy link
Copy Markdown
Owner Author

Superseded by #4 — rebased onto v0.4.7 main with additional PowerShell hooks and updated WSL integration.

@guan4tou2 guan4tou2 closed this Jul 29, 2026
guan4tou2 added a commit that referenced this pull request Jul 30, 2026
… Integrations / Data

An audit flagged the 'data' Settings tab as a dumping ground — 10 unrelated
FieldGroups (screenshot quality, overlay HUD × 5 controls, clipboard, update
checks, browser panel, CDP, export JSON, scope-filtered export, integrity
anchors, profile sync). Reorganize into 8 focused tabs (was 7):

  general       — engagement / operator / language  (unchanged; +i18n Language)
  hud           — overlay (mark button, flash, scale, emphasize IP, dock)  [new]
  capture       — hooks + screenshot quality + clipboard                    [was 'hooks']
  network       — IP monitoring + VPN adapters      (unchanged)
  scope         — scope rules                       (unchanged)
  integrations  — MCP + operators + deconfliction + browser + CDP  [was 'team']
  data          — updates + export + scope export + integrity + profile sync (slim)
  plugins       — plugin registry                   (unchanged)

Data drops from 10 groups → 5. Each remaining tab is coherent (all groups
share a "why they exist" story).

Also fixed a P0 bug the audit surfaced (finding #3): four sibling checkboxes
in the overlay group each re-derived `showMarkButton: config.overlay?.
showMarkButton !== false` in their onChange, which silently re-flipped the
mark-button toggle whenever the user changed any other overlay setting.
Killed via perl replace across all 4 sites; spreading ...config.overlay
already carries the current value.

Also fixed P1 #20 (hardcoded English "Language" title) — moved to
`settings.language` i18n key.

Deferred audit findings (P0 bugs, still open): toast auto-dismiss timer
sharing across bursts (#6), didScrollToNow ref never resets on re-focus
(#7), ⌘1..9 shortcut order doesn't match sidebar order (#8), TargetView
dead scope_violation branch (#4), double marker-shortcut listener (#5),
native window.confirm() for operator delete (#2), alert() for CDP test
(#1). These get their own follow-up commits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
guan4tou2 added a commit that referenced this pull request Jul 30, 2026
… pin

- Built-in Terminal now records complete stdout onto shell.command_end events.
  Per-command output buffer in terminal-manager, drained by api-server on
  command_end (source=builtin-terminal). Redaction still applies. Capped at
  256 KB per command with output_truncated flag; the .cast file remains the
  full record for anything larger.
- Shell hook: command_end now carries data.cwd so downstream views can show
  where a command ran without joining across events.
- Timeline (audit #3): scrolling to the earliest edge auto-triggers loadMore
  instead of requiring the "load more" chip click.
- Terminal tabs (audit #16): live label now shows ~/<cwd basename> and
  ✕<code> when the last command failed, driven off command_end events.
- Findings Marks: pin toggle floats important marks to the top; state
  persisted in localStorage (chain-immutable events stay unchanged).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
guan4tou2 added a commit that referenced this pull request Jul 30, 2026
- HUD corner-snap keychord ⌘⌥ + Arrow was swallowed by macOS Sequoia's
  built-in window tiling. Add Shift → ⌘⇧⌥ + Arrow, clockwise mapping:
  ↑=TL, →=TR, ↓=BR, ←=BL.
- events.query now takes `before?: number`. Timeline loadMore anchors on
  the oldest event it already holds and queries strictly older events,
  so the auto-load-on-scroll-left actually walks back through history
  instead of re-fetching the same latest 200 (audit #3 follow-up).
- Marks: pin toggle was on every list row and overlapped titles on
  hover. Move it into the mark detail panel (low-frequency action) and
  keep only a small ★ indicator on the list row for pinned marks.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants