Skip to content

Fix/watch folder#41

Merged
amemya merged 8 commits into
mainfrom
fix/watch-folder
Jun 3, 2026
Merged

Fix/watch folder#41
amemya merged 8 commits into
mainfrom
fix/watch-folder

Conversation

@amemya

@amemya amemya commented Jun 2, 2026

Copy link
Copy Markdown
Owner

自動書き出しが動作しない問題を修正

resolved #40

@amemya amemya requested a review from Copilot June 2, 2026 16:20
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9e875e6a-7ff8-4714-be22-3d582ff81e7f

📥 Commits

Reviewing files that changed from the base of the PR and between d23dcae and 53518c6.

📒 Files selected for processing (2)
  • frontend/src/App.tsx
  • handler.go

📝 Walkthrough

Summary by CodeRabbit

  • 新機能

    • 画像配信にトークン付きURLとサーバ側キャッシュを導入し、配信の効率と安全性を向上しました(古いキャッシュは自動で整理されます)。
  • バグ修正

    • フロントエンドのファイル処理イベントの異なるペイロード形式に対応し、互換性と堅牢性を改善しました。
    • 画像選択時のパス管理と返却される画像URLの扱いを安定化しました。

Walkthrough

画像配信をトークンキャッシュで解決し、選択画像はトークン付きURLで公開します。フロントエンドはWails v2/v3のprocess_fileイベントペイロード差異に対応する型定義と分岐処理を追加します。

Changes

Token-based image serving

Layer / File(s) Summary
Token cache infrastructure
handler.go
ImageHandlerimgMuimageTokenspathToTokenimageTokenOrderを追加。NewImageHandlerで初期化し、registerImageTokenは既存トークン再利用・順序更新・上限(100)超過時の古いエントリ破棄を行う。
Image request handler with token lookup
handler.go
handleImagetokenクエリがあればキャッシュでパスを解決し、なければapp.getCurrentImagePath()へフォールバック。パス未解決時の404メッセージをトークン文言に変更。
Image URL generation with tokens
app.go
doOpenImagecurrentImagePathをスレッドセーフに更新。handlerが初期化済みならregisterImageToken(filePath)/api/image?token=...&t=...を生成し、handler==nil時は従来の/api/image?t=...を返す。
Frontend event type safety
frontend/src/App.tsx
ProcessFileResult/ProcessFileData/WailsProcessFileEventのインターフェイスを追加。Events.On("process_file", ...)event.dataが配列なら先頭要素、非配列ならそのまま扱う分岐へ変更し、result/imageURL/exportの存在を検証。

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • amemya/ExifFrame#15: 本PRのトークンベースExifResult.ImageURL生成と/api/imageトークンルックアップの流れは、このPRで導入されたImageHandlerベースの画像HTTP転送フローを拡張しています。
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive タイトル「Fix/watch folder」はPRの主な変更内容(自動書き出し機能の修正)に関連していますが、具体的な修正内容を特定しにくく、やや曖昧です。 タイトルをより具体的にして、修正内容を明確にしてください。例:「Fix automatic export when adding images to watched folder」など。
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed 説明「自動書き出しが動作しない問題を修正」はissue #40の解決に直接関連しており、変更内容と関連性があります。
Linked Issues check ✅ Passed Issue #40は「監視対象フォルダに画像をドロップしても書き出されない」という問題を指しており、このPRの変更内容(トークンキャッシング、イベントハンドリング改善)がこの問題に対応しているようです。
Out of Scope Changes check ✅ Passed すべての変更が自動書き出し機能の修正に関連しており、トークンキャッシング、イベント処理、ファイルパス管理はすべてこの目標に対応しています。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/watch-folder

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 and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

このPRは、監視フォルダに画像を追加した際の「自動書き出し(auto export)」が動作しない問題(Issue #40)を修正し、バックグラウンド処理時でも正しい画像をプレビュー/保存できるようにする変更です。複数ファイルが並行処理される状況で currentImagePath 参照が競合しやすい点を、画像ごとのトークンURLで解消する意図が読み取れます。

Changes:

  • /api/imagetoken を導入し、画像ごとに確実に同一ファイルを配信できるように変更
  • process_file イベントの payload 形状差(Wails v2/v3)を吸収するようフロント側の受信処理を更新
  • 画像トークンのキャッシュ(imageTokens)を追加

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
handler.go 画像配信エンドポイントにトークン解決を追加し、並行処理時の取り違えを防止
app.go 画像オープン時にトークン付きの ImageURL を生成してフロントへ返却
frontend/src/App.tsx process_file イベントの Wails v2/v3 差異を吸収して自動処理を継続可能に

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread handler.go
Comment on lines +148 to +156
// Optional: Limit size to prevent memory leaks if many images are opened
if len(h.imageTokens) >= 100 {
// Evict one pseudo-random entry to free space.
// (YAGNI: A full LRU is over-engineering for a simple 100-item desktop app cache)
for k := range h.imageTokens {
delete(h.imageTokens, k)
break
}
}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@handler.go`:
- Around line 146-160: 現在の擬似ランダム削除は直近に登録したトークンを誤って退避し得るため、h.imageTokens を FIFO
で退避するよう変更してください: ハンドラ構造体に挿入順を保持するスライス(例: imageTokenOrder
[]string)を追加し、registerImageToken 内でトークン登録時にそのスライスへ append
し、容量超過時はスライスの先頭要素を取り出して
map(h.imageTokens)から削除してからスライスを前詰め(または先頭ポップ)して古い順に退避するよう実装し、handleImage
が参照するトークンが削られないようにしてください。
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fcc44988-af6c-497f-aeaa-cff8f903f679

📥 Commits

Reviewing files that changed from the base of the PR and between 0323ab6 and d23dcae.

📒 Files selected for processing (3)
  • app.go
  • frontend/src/App.tsx
  • handler.go

Comment thread handler.go
@amemya amemya requested a review from Copilot June 2, 2026 23:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@amemya amemya merged commit 034bf04 into main Jun 3, 2026
1 check passed
@amemya amemya deleted the fix/watch-folder branch June 3, 2026 01:29
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