Repository navigation
feat(import-detail): lock regenerate and hand off to the wiki app editor - #19
Conversation
Splits into two PRs: hiding Explore/generate-only Wiki tabs and folding publish into a renamed Tree->Wiki tab, then locking Regenerate after first publish and linking each page to its real editor in the Wiki app instead of round-tripping edits through Wikify. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Explore and the standalone generate-only Wiki tab are hidden (their components stay on disk, unreferenced). Tree is renamed to Wiki and now also carries the publish action, via a new compact WikiPublish control extracted from the old WikiGenerate.vue.
Remove the docs/superpowers spec + plan markdown files added while drafting this change - not meant to ship in the PR. Also reformats the Route FormControl in WikiPublish.vue to satisfy prettier (CI was failing the Frappe Linter job on line length).
Per review feedback - shrink the multi-line note explaining the tab list down to a single line.
- Legacy /import/:name/wiki links resolve to the consolidated "tree" (Wiki) panel instead of falling back to PDF. - WikiPublish's Publish/Regenerate button is always subtle, so "Approve & Build Graph" stays the toolbar's one solid action.
generate_wiki no longer accepts calls once a Wikify Import has reached Completed - a fully-published wiki's Wiki Documents should only be edited from the Wiki app's own editor from that point on, never silently overwritten by a re-run from Wikify.
- WikiPublish shows a "Published" badge instead of Regenerate once an import reaches Completed, matching the API now rejecting that call. - SectionTree opens a page's real Wiki app editor (/wiki-app/spaces/:space/page/:doc) in a new tab on click once published, instead of Wikify's own (now potentially stale) preview, with a banner explaining the handoff.
|
| if imp.status == "Completed": | ||
| frappe.throw(_("This wiki has already been published — edit pages directly in the Wiki app.")) | ||
| if imp.status not in ("Graphed", "Stopped"): |
There was a problem hiding this comment.
Published lock can be bypassed
The new lock rejects generation only while the import is currently Completed. However, the completed Wiki screen still exposes Approve & Build Graph, and build_graph unconditionally changes the import back to Graphed. The same import can then pass this API's Graphed check and be regenerated, defeating the intended one-way handoff. Completed imports also retain active rename, reorder, exclusion, and deletion controls, so their source tree can diverge from the published wiki. The completed-state restriction needs to cover graph building and tree mutations as well as generate_wiki.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: wikify/api/imports.py
Line: 119-121
Comment:
**Published lock can be bypassed**
The new lock rejects generation only while the import is currently `Completed`. However, the completed Wiki screen still exposes **Approve & Build Graph**, and `build_graph` unconditionally changes the import back to `Graphed`. The same import can then pass this API's `Graphed` check and be regenerated, defeating the intended one-way handoff. Completed imports also retain active rename, reorder, exclusion, and deletion controls, so their source tree can diverge from the published wiki. The completed-state restriction needs to cover graph building and tree mutations as well as `generate_wiki`.
**Knowledge Base Used:**
- [Wiki review and generation UI](https://app.greptile.com/bwh-tech/-/custom-context/knowledge-base/bwhtech/wikify/-/docs/wiki-review-and-generation-ui.md)
- [Backend API and realtime services](https://app.greptile.com/bwh-tech/-/custom-context/knowledge-base/bwhtech/wikify/-/docs/backend-api-and-realtime-services.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.- build_graph and the tree mutation endpoints (reorder/rename/toggle include/delete) now reject once the owning import is Completed, so Approve & Build Graph can no longer flip a published import back to Graphed and reopen the regenerate path, and the source tree can no longer drift from what's already published. - ImportDetail reloads the section tree (not just the import doc) on publish completion, so wiki_document is populated before the tree switches into its published, click-to-editor mode.
add_wiki_title_customizations() decided whether to (re)create the title-widening Property Setter by reading frappe.get_meta(), a process-level cache that isn't transaction-aware. In CI's full test run this let an earlier test's rolled-back Property Setter still read as present via the stale cache, so a later test's call skipped recreating it - leaving 0 rows where 1 was expected (test_running_again_keeps_one_property_setter). Check the Property Setter's own existence in the DB instead, which is what the function is actually trying to guarantee.
| has_setter = frappe.db.exists( | ||
| "Property Setter", {"doc_type": doctype, "field_name": "title", "property": "fieldtype"} | ||
| ) |
There was a problem hiding this comment.
If an existing Property Setter still defines title as a narrow type such as Data, this existence check treats it as valid and skips make_property_setter. The Wiki title field therefore remains subject to the old length constraint even though this setup is intended to repair title storage during installation and migration. Check the setter's configured value against WIDE_TEXT_FIELDTYPES and replace it when necessary.
Knowledge Base Used: Application services and data model
Prompt To Fix With AI
This is a comment left during a code review.
Path: wikify/install.py
Line: 33-35
Comment:
**Invalid setters skip repair**
If an existing Property Setter still defines `title` as a narrow type such as `Data`, this existence check treats it as valid and skips `make_property_setter`. The Wiki title field therefore remains subject to the old length constraint even though this setup is intended to repair title storage during installation and migration. Check the setter's configured value against `WIDE_TEXT_FIELDTYPES` and replace it when necessary.
**Knowledge Base Used:** [Application services and data model](https://app.greptile.com/bwh-tech/-/custom-context/knowledge-base/bwhtech/wikify/-/docs/application-services-and-data.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Approve & Build Graph, drag-to-reorder, and the per-row rename/ exclude/delete menu were still visibly enabled after publish even though the API now rejects all of them - clicking any of them just produced an error toast. Hide them once published, matching the Publish button's own Published-badge treatment.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
What's done
generate_wikinow rejects a regenerate once a Wikify Import has reachedCompleted— a published wiki's pages should only be edited from the Wiki app's own editor from that point on.WikiPublishshows a "Published" badge instead of the Regenerate button once that happens.SectionTreeopens a page's real Wiki app editor (/wiki-app/spaces/:space/page/:doc) in a new tab when you click it post-publish, instead of Wikify's own (now potentially stale) preview, with a banner explaining the handoff.Depends on #18 (branched from its head) — tab cleanup lands first.
Screenshot
Demo
page@8e7525da0698a0f2348a18c5a21fc123.webm