Skip to content

feat: 差分ビュー・ライブ変更レビュー・Git 履歴・リンクチェックを追加 - #33

Merged
simota merged 1 commit into
mainfrom
feat/diff-history-linkcheck
Nov 6, 2026
Merged

simota merged 1 commit into
mainfrom
feat/diff-history-linkcheck

Conversation

@simota

@simota simota commented Nov 6, 2026

Copy link
Copy Markdown
Owner

概要

「何が変わったか」を確認する機能と、Markdown のリンク切れ検出を追加します。

  • 差分ビュー: 任意の 2 テキストファイルを左右/統合表示で比較。単語単位ハイライト、変更箇所ナビ(n/p)、空白無視、省略行の展開、行番号から該当行へ移動、パッチのコピー/.patch 保存、ファイル変更時の自動再比較、Secret Safe 対応
  • ライブ変更レビュー: 開いた後に外部で編集されたファイルにパンくず横の「変更あり +N −M」チップを表示し、開いた時点との差分を確認(D キー)。「確認済みにする」で基準を更新
  • Git 履歴: /api/git/log・/api/git/show を追加し、HEAD や直近 30 コミットとの比較に対応。/api/git/status でファイルツリーに M/A/U バッジと「Git: 変更のみ」絞り込みを追加
  • リンクチェック: /api/links/check で通常リンク・画像・参照定義・wiki リンクのリンク切れを、ビューアと同じ規則で検出。同名ファイルを修正候補として提示。TOC パネルに文書別の結果を表示し、フォルダ/ルートの右クリックからレポート(Markdown チェックリストとしてコピー可)を開ける
  • 入口: ファイルツリーの右クリックメニュー、ツールバーの Diff ボタン、D キー。ヘルプ・README・CHANGELOG・CLAUDE.md も更新

セキュリティ

  • Git はシェルを介さず execFile で実行(status / log / show のみ)。リビジョンは HEAD・HEAD~N・コミットハッシュに限定し、タイムアウトと出力上限を設定、fsmonitor とフックは無効化
  • パスはすべて既存の safePath を通す(ルート外・シンボリックリンク経由の脱出は 403)。git show の応答は CSP: sandbox
  • Secret Safe モードでは差分表示とパッチの両方をマスク

テスト

  • tests/text-diff.test.mjs(9 件): 乱数データでの再構成照合、GNU patch での適用確認を含む
  • tests/history-links.test.mjs(8 件): Git API(サブフォルダをルートにした場合を含む)、不正リビジョン・パス、リンクチェック
  • tests/diff-linkcheck.spec.ts(E2E 8 件)
  • 結果: unit 44 pass / 1 skip(既存)、E2E 418 pass / 3 skip(既存)、tsc strict・build・コントラストチェック成功

既知の制約

  • 「開いた時点」のスナップショットはタブのメモリ上のみ(リロードで消える、最大 50 ファイル)。分割ビュー右側と 5MB 超の分割読み込みファイルは対象外
  • パッチは「改行なしで終わるファイル」の印を出力しない
  • 見出しアンカー(file.md#section)の存在チェックと外部 URL のチェックは対象外

Generated by Claude Code

- テキスト差分エンジン (Myers, 単語単位ハイライト, unified patch) と差分ビュー
  (左右/統合表示, 変更箇所ナビ, 空白無視, 行ジャンプ, パッチのコピー/保存,
  Secret Safe 対応, ファイル変更時の自動再比較)
- 開いた後に外部で変更されたファイルに「変更あり +N −M」チップを表示し、
  開いた時点との差分を確認・確認済みにできるようにする (D キー)
- Git 履歴 API (/api/git/status, /api/git/log, /api/git/show) を追加し、
  HEAD・過去コミットとの比較、ファイルツリーの変更バッジと「Git: 変更のみ」絞り込みに対応
- Markdown のリンク切れ検出 API (/api/links/check) とレポート画面、
  TOC パネルの文書別リンク切れ表示を追加
- ファイルツリーの右クリックメニューに比較・履歴・リンクチェックの導線を追加
- 単体テスト (差分エンジン, Git/リンクチェック API) と E2E テストを追加

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L4uUUgYQkS1qRWZ3odMQPM
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T11:32:04.157418Z 2bbedd4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@simota
simota merged commit 8d13bb5 into main Nov 6, 2026
3 checks passed
@simota
simota deleted the feat/diff-history-linkcheck branch November 6, 2026 11:30

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2bbedd440b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/diff-view.ts
Comment on lines +363 to +365
if (isSecretSafeModeEnabled()) {
oldText = maskSecrets(oldText);
newText = maskSecrets(newText);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Apply format-aware secret masking before comparing files

With Secret Safe enabled, comparing CSV files containing an apiKey column or YAML files containing block-valued passwords exposes secrets in both the diff and exported patches. The generic maskSecrets() leaves CSV values untouched and only masks the | marker in password: |, leaving the actual block content visible. The main viewer already protects these cases using maskCsvSecrets() and maskYamlSecrets() in src/main.ts; apply equivalent format-aware masking to each diff source before computing the result.

Useful? React with 👍 / 👎.

Comment thread src/text-diff.ts
const out: DiffOp[] = [];
let dels: DiffOp[] = [];
let ins: DiffOp[] = [];
const flush = () => { out.push(...dels, ...ins); dels = []; ins = []; };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid spreading large change blocks into push arguments

When a comparison contains a sufficiently large insertion or deletion, spreading the entire block into push() exceeds the JavaScript argument limit. For example, diffLines('', 'x\n'.repeat(150000)) throws RangeError: Maximum call stack size exceeded, despite the input being only 300 KB and therefore below the diff view's 4 MB limit. This also affects live-change tracking because updateLiveChangeChip() invokes the same function while loading files. Append operations iteratively so the approximate-diff fallback can handle large changes without throwing.

Useful? React with 👍 / 👎.

Comment thread server.mjs
/** Extract { raw, dest, kind, index } for every inline, image, reference and wiki link. */
function extractMarkdownLinks(text) {
const links = [];
const inline = /(!?)\[(?:[^\]\\]|\\.)*\]\(\s*(<[^>\n]*>|[^\s)]+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/g;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve balanced parentheses in Markdown link destinations

For a valid Markdown link such as [guide](guide/a(b).md), this expression stops at the first closing parenthesis and extracts guide/a(b instead of guide/a(b).md. Consequently, the checker reports a broken link even when the file exists and the viewer opens it correctly; conversely, an existing truncated path can hide a genuinely missing target. Parse balanced or escaped parentheses according to the viewer's Markdown rules rather than treating the first ) as the destination terminator.

Useful? React with 👍 / 👎.

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