Commit graph

177 commits

Author SHA1 Message Date
wujunchen
f2e197453c fix: prevent modal confirmation promise from resolving twice
The regenerate confirmation modal's onClose callback fired after button
click handlers, calling resolve() a second time. While Promise.resolve
is idempotent, this was confusing. Added explicit settlement tracking
so the promise resolves exactly once regardless of how the modal closes.

Change-Id: Ief4cbb78f15fe220a20adaf8343d744ffa8c1653
2026-04-27 12:34:33 +08:00
wujunchen
b02d0f4f30 test: add cache pruning interleaved with put test
Verify that when a new entry is added via put() and the cache exceeds
maxCacheEntries, the oldest entry (by timestamp) is pruned and the
pruned state is correctly persisted to disk.

Change-Id: Ia937800a97d7591877e1d2d1fe808b86858735e1
2026-04-27 12:30:56 +08:00
wujunchen
cfdd985f78 test: add batch state isolation and cancellation tests
Verify that two concurrent BatchRunState objects don't interfere with
each other (cancelling one doesn't affect the other), and that stats
accumulate correctly when processing is stopped mid-iteration.

Change-Id: Id32b27307beafe49594cfde6fa818b2f22b87c66
2026-04-27 12:29:42 +08:00
wujunchen
593817734b test: add streaming cancellation edge case tests
Cover pre-aborted signal (aborted before fetch starts) and mid-read
abort (signal aborted while reading response body). Both verify that
abort listeners are properly cleaned up after rejection.

Change-Id: I0760f6ed051de1504e9b7aeead01a10cfd12476e
2026-04-27 12:28:36 +08:00
wujunchen
1d3aa81678 fix: close abort signal race window in streaming fetch
The previous code checked signal.aborted before adding the listener,
creating a timing window where the signal could abort between the check
and addEventListener. Now the listener is always registered first, then
signal.aborted is checked after, ensuring no abort event is missed.

Change-Id: I1abc3ad21e5bb93559d66922edf7c325a977bc65
2026-04-27 12:22:43 +08:00
wujunchen
09f39dde8d fix: make normalizeSettings return a new object instead of mutating input
normalizeSettings previously modified its input parameter in-place.
While callers already created copies before calling it, the function
signature was misleading. Now it creates a shallow copy internally and
operates on that, with a Readonly<PluginSettings> parameter type to
signal intent. Added a test verifying the original object is unchanged.

Change-Id: I7600ac37930bbcebb02aa7c84d8988cb7aa71196
2026-04-27 12:20:56 +08:00
wujunchen
816b015e56 chore: bump version to 1.0.4
Change-Id: Id5040ec82babe747976121e07b7eabe1f6d82406
2026-04-27 12:11:29 +08:00
wujunchen
ff1116d7f4 fix: pass --max-tokens to Claude Code CLI to prevent output truncation
The CLI path was not forwarding settings.apiMaxTokens, causing the
model to use its own default which is too small for long documents
with many CJK cards. This was the root cause of repeated "LLM 返回
非 JSON" errors — the JSON was being cut off mid-card.

Change-Id: Ia738418e2e6cf7f919752cb3128a82768d95cedf
2026-04-27 11:58:04 +08:00
wujunchen
abce923f14 fix: salvage truncated LLM JSON and make errors copyable
- Add repairTruncatedCardsJson to recover complete cards when output
  is cut off mid-card (e.g. token limit reached)
- Log raw LLM response to console on parse failure for debugging
- Make error panel text selectable and add "copy error" button

Change-Id: I4e76121138888234d42f84f3695cbbfd6beba886
2026-04-27 11:56:40 +08:00
wujunchen
5f12113fcd chore: improve engineering quality and hardening
- Fix CI to run all 4 test files (was missing direct-modules.test.js)
- Remove unused ESLint dependencies (eslint, @typescript-eslint/*, eslint-plugin-obsidianmd)
- Enable noImplicitReturns in tsconfig.json for stricter type safety
- Make applyApiProviderPreset return new object instead of mutating input
- Add per-file error handling in batch processing loop with error count in summary
- Narrow all catch clause types to unknown with proper instanceof narrowing

Change-Id: I76975dbd5ebdb5645d18c5858c8a52fd6da3405e
2026-04-27 11:15:35 +08:00
wujunchen
b1e35fc8fc chore: bump version to 1.0.3
Change-Id: I58a40e2a7037c83bed96f30af077c096314160f2
2026-04-27 10:46:01 +08:00
wujunchen
d75107d84c chore: update versions.json for 1.0.2 release
Change-Id: Icc8e905a4b117a5707d6e6b48729a8d6dc60a619
2026-04-27 10:45:27 +08:00
wujunchen
6e83d216c2 feat: add generate button to empty state panel
When a note has no cached parallel notes, the empty state now shows a
clickable "Generate" button so users can trigger generation directly
without going through the command palette. Closes #2.

Change-Id: I879897168ef77c44e0ab570e9c094fa9af9f66d4
2026-04-27 10:24:05 +08:00
wujunchen
6aba90bfd3 fix: remove unnecessary async from catch handler
The catch callback no longer contains any await expressions
after the previous refactor removed await on sync view methods.

Change-Id: I054c50fe209aba0e925bd1838896228bce686841
2026-04-26 21:12:16 +08:00
wujunchen
da535cb064 fix: address remaining Obsidian review bot required issues
- Remove unnecessary TFile cast (instanceof already narrows)
- Remove await on non-Promise view methods (loadFor, renderLoading, renderError)
- Remove async from CacheManager.touch() (no await expression)
- Replace this-aliasing with captured locals in batch modal
- Use CSS class instead of inline style for modal input width
- Fix sentence case in settings UI text

Change-Id: I2a222c6429eb7e4d69761cca8369956fef510054
2026-04-26 19:34:45 +08:00
wujunchen
de08ec778a chore: add eslint tooling dependencies
Change-Id: I3f855a85e1ed9ef45a0f77210d5a68081a967d59
2026-04-26 19:25:51 +08:00
wujunchen
3d8d72b66e refactor: split settings tab renderers
Change-Id: I456ddd16868150b2e22f5592c97d579a3540e48d
2026-04-26 19:17:12 +08:00
wujunchen
486060bddf test: cover cache manager with fake adapter
Change-Id: I83f6b71a46af31f783522faa53bffbfc6c4bc54d
2026-04-26 18:31:17 +08:00
wujunchen
557908ca44 fix: clean up streaming abort listener
Change-Id: I9fa8ace7bc0fa723466ef851f7ec2960c6638eba
2026-04-26 18:29:48 +08:00
wujunchen
bc51acd00e fix: parse multiline sse events
Change-Id: I9c013dbe6840a0892836eb5d71206c6fcde5ec78
2026-04-26 18:27:28 +08:00
wujunchen
846e32301a test: import pure modules directly
Change-Id: Ia029de2ac4c3cb3ddb7ea638c868d6347af5c67e
2026-04-26 18:25:50 +08:00
wujunchen
2364e62911 chore: check build artifact consistency
Change-Id: I485ee9ef2eaf584a1c1fcf890ee85fb82a34a8fb
2026-04-26 18:22:11 +08:00
wujunchen
70f9a39cd7 refactor: extract provider response parsers
Change-Id: I6884999f34594faec349378deb59e68972e07355
2026-04-26 18:20:49 +08:00
wujunchen
6dd7ef15a4 test: cover cli edge cases
Change-Id: Ia6114ab7ba24e32f7f86ff76710a596b0c24682c
2026-04-26 18:16:38 +08:00
wujunchen
174fa7295d feat: expose streaming timeout setting
Change-Id: Ide69c0f0fe208a557024f9f77d83c9d1215391cf
2026-04-26 18:14:43 +08:00
wujunchen
9098de6884 feat: validate batch folder input
Change-Id: I137fa046e77781e063ee782af4321b7277d64d51
2026-04-26 18:12:38 +08:00
wujunchen
d8dc82362b feat: support cancellable batch generation
Change-Id: I89302f58995e4e15fbf77c20c87a94832e572d20
2026-04-26 18:10:17 +08:00
wujunchen
ebc882c2f1 refactor: encapsulate cache rename
Change-Id: I89ee56c071c8e5404f8eb9ea744172957811d714
2026-04-26 18:05:38 +08:00
wujunchen
fe05ed1a2d test: cover generation orchestration
Change-Id: Iff416f01c0f09111e67e1ad67957b85fdb19623a
2026-04-26 17:59:35 +08:00
wujunchen
2d4bef9539 refactor: extract batch generation helpers
Change-Id: I16ad657b783b65cc5b3e36a6ea163cc19740b651
2026-04-26 17:54:35 +08:00
wujunchen
b199f56a35 refactor: extract generation orchestration
Change-Id: I17002ff04b0d79d8ec27da3dbb4b08df9bf3659e
2026-04-26 17:45:43 +08:00
wujunchen
9ed36570b5 refactor: restore strict lint hygiene
Change-Id: I26917328ec55e529242dfd8e4c42af0b3fcd58b7
2026-04-26 17:41:28 +08:00
wujunchen
89e1ab9d5c chore: bump version to 1.0.2
Change-Id: I40e3893b061e73620e9e7d8f818684d3620c1d9f
2026-04-26 16:01:39 +08:00
wujunchen
89d28d1113 fix: address all required issues from Obsidian plugin review bot
- Remove `parallel-reader-` prefix from command IDs (Obsidian auto-namespaces)
- Remove default hotkeys to avoid conflicts with user keybindings
- Replace `as TFile` casts with `instanceof TFile` checks
- Make onunload sync, remove detachLeavesOfType (preserves leaf positions)
- Use `vault.configDir` instead of hardcoded `.obsidian`
- Replace `window.confirm` with Obsidian Modal dialog
- Fix unhandled promises with `void` or `await`
- Remove unnecessary `async` from methods without `await`
- Use `new Setting().setHeading()` instead of raw HTML headings
- Fix promise-returning callbacks in event listeners
- Fix error type narrowing with `instanceof Error`
- Apply sentence case to UI text labels

Change-Id: I6e850d8a13b458d5cf1ad91227bf1772636b56b9
2026-04-26 15:57:16 +08:00
fancivez
e0acce7f6d
Merge pull request #1 from fancive/feat/engineering-improvements
refactor: engineering improvements batch
2026-04-26 15:43:18 +08:00
Claude
69af9938c6
build: update compiled main.js artifact
https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:21:53 +00:00
Claude
02fc5678ae
feat: add folder-level batch summarization command
Register parallel-reader-batch-generate command. It prompts the user for a
folder path via a Modal, finds all .md files in that folder (non-recursive),
skips files whose cache is still valid, and runs runForFile() sequentially
on the rest, showing per-file progress notices. Add i18n keys for the new
UI strings in both zh and en.

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:18:58 +00:00
Claude
10d811f197
refactor: upgrade Biome lint rules
Promote noExplicitAny from warn to error and enable noNonNullAssertion
at warn level. Fix the two resulting errors in src/schema.ts by introducing
a JsonSchema interface to replace the any-typed local variables.

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:16:36 +00:00
Claude
a74e7c3e07
test: add tests for i18n, streaming, and cli modules
Extend tests/modules.test.js with:
- parseSseBuffer: partial buffer, multi-event chunk, skipped non-data lines,
  malformed JSON line handling
- i18n: multi-variable interpolation, zh translation, missing-key fallback
- cli: resolveCliPath with override path trimming and mocked fs.existsSync
  to verify filesystem search and bare-name fallback

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:15:30 +00:00
Claude
e7384fd875
feat: add streaming timeout protection
Add streamingTimeoutMs field to PluginSettings (default 120000ms). In
streamingFetch(), use Promise.race between the stream reader and a timeout
promise that aborts the AbortController and throws a clear timeout error.
External cancellation signals are forwarded to the same controller so only
one abort path is needed.

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:13:52 +00:00
Claude
dbb8ea4a5b
refactor: make cache entry updates immutable
touchCacheEntry() now returns a new object via spread instead of mutating
the entry in-place. CacheManager.replaceCards() likewise creates a new entry
object instead of mutating existing fields. Update tests to assert the new
immutable semantics (returned value differs from input by reference).

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:12:55 +00:00
Claude
64ebbaef36
refactor: replace any types in providers.ts with proper interfaces
Define RequestUrlFunction, AnthropicMessagesBody, OpenAiChatBody,
OpenAiResponsesBody, GeminiBody/GeminiGenerationConfig typed interfaces.
Replace all ~14 any usages with unknown + type narrowing or concrete types.
Drop the eslint-disable comments that were papering over the any usages.

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:10:28 +00:00
Claude
57d25501d6
refactor: add typed wrappers for Obsidian API boundaries
Add CmEditorView, ObsidianEditorWithCm, ObsidianMenuItem, and ObsidianMenu
interfaces to src/types.ts. Replace (editor as any).cm and (it: any) casts
in main.ts with these typed wrappers, eliminating all any casts in the
scroll-sync and file-menu code paths.

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:08:46 +00:00
Claude
87904811e2
refactor: extract CacheManager from main.ts
Move all cache persistence methods and state (_cacheSaveTimer, _cacheDirty)
into a new CacheManager class in src/cache-manager.ts. Plugin delegates to
it via thin wrappers that preserve the existing method names tested by the
test suite. main.ts reduced from 826 to 713 lines.

https://claude.ai/code/session_016QvEfqw6YZ3RjwBHrJ4w8S
2026-04-26 06:07:03 +00:00
wujunchen
f86f45fe73 docs: simplify CLI backend description to match auto-detection
Change-Id: I8bc223bb1c0508b1669159b0528859a99586fa08
2026-04-26 12:14:19 +08:00
wujunchen
68163219a6 docs: simplify installation guide for non-technical users
Change-Id: I452fb6eef4c07c083153c7a8742d02110b407279
2026-04-26 12:13:45 +08:00
wujunchen
4cace369bf chore: bump version to 1.0.1
Change-Id: I1341830221a8859b0783d2d69aaee85e2c6be3bb
2026-04-26 11:29:32 +08:00
wujunchen
38ba0acdb2 fix: parse Claude Code JSON array output and drop --model flag
Claude Code `--output-format json` returns a JSON array of event
objects, not a single object. Parse the array and extract the
result event. Also stop passing --model to let Claude Code use
its own default model. Revert timeout to 120s.

Change-Id: I5b5d4aa589ff78c0a2806a3e700bac0676a9b354
2026-04-26 11:09:47 +08:00
wujunchen
625ac4e5fe fix: raise CLI timeout from 120s to 300s
Change-Id: I1c6a66ed23c6908d6045042e57e50efce1910f9e
2026-04-26 11:08:13 +08:00
wujunchen
2bc7288a44 docs: modern English README with badges and star history
Switch to English as default README with badge bar (release, CI,
license, stars) and star-history chart. Add separate README.zh-CN.md
for Chinese version. Remove project structure section.

Change-Id: I3bc378bb024e1e75db95e08fd932b29e4d4b1c63
2026-04-26 11:00:29 +08:00