Repository navigation
feat(chrome-extension): refresh Batch Download tree from a Feishu wiki - #148
Open
StrivingLee wants to merge 2 commits into
Open
StrivingLee wants to merge 2 commits into
StrivingLee wants to merge 2 commits into
Conversation
Add an optional "Refresh from Feishu wiki" card to the Batch Download page. Given a wiki page URL, it walks the page and everything under it in sidebar order (the same tree API the web app's sidebar uses) and rebuilds the tree: each page as "NNN - title" (numbering optional), a page with children followed by a same-name folder, non-document nodes dropped and reported. - Preview before replace: added / removed / renamed / moved pages. - "Refresh before each export" (off by default) gates Export/Resume: unchanged wikis start at once; changes wait for Apply and export, Export current tree, or Cancel. A failed walk never exports a stale tree. - Atomic: any failed request leaves the current tree untouched. - Pages are matched by wiki token, so in-session extractions and statuses carry over; ZIP paths follow the new names. - Per-wiki options: pages before the root, title overrides, top-level section filter (keeps full-tree numbering). - Auth: direct credentialed fetch, falling back to an in-tab fetch via chrome.scripting. No new permissions; URLs limited to manifest hosts. Also clear the log at the start of an export so refresh messages stay visible, and add unit tests plus a hermetic Playwright e2e suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An optional Refresh from Feishu wiki card on the Batch Download page. Paste a wiki page URL, and it rebuilds the tree from that page and everything under it, in sidebar order:
NNN - title(numbering can be turned off), and a page with children is followed by a same-name folderAdvanced options are stored per wiki: pages to place before the root, title overrides, and a top-level section filter (numbers stay as in the full tree).
Why
Large wikis drift: pages get added, renamed and reordered. Manual capture and Import State then go stale, and keeping them in sync by hand is error-prone.
How
wiki-hierarchy.ts: pure walk/build/diff/carry-over with no imports, unit-tested.wiki-fetch.ts: credentialedfetchfrom the extension page. If the session cookie isn't sent, it falls back to the same fetch inside a Feishu tab viachrome.scripting./space/api/wiki/v2/tree/get_info,get_node_child), throttled and retried. A failed walk leaves the tree untouched.host_permissions.Also: the log is now cleared at the start of an export, so refresh messages stay visible. README (EN and ZH) now describes Batch Download and the wiki refresh.
Notes
{placeholders}at runtime under the extension CSP, so the card fills placeholders itself.Tests
tests/wiki-hierarchy.test.ts: 12 unit tests (walk order and retry, abort, build, subsets, numbering width, diff, carry-over, URL host checks)apps/chrome-extension-e2e/tests/batch-download-wiki-refresh.e2e.test.ts: 5 Playwright journeys on the built extension against a stubbed Feishu API (no account needed)