Skip to content

Add interactive mode to AI documentation generation#3554

Open
vinit-chauhan wants to merge 3 commits into
elastic:mainfrom
vinit-chauhan:doc_update_2
Open

Add interactive mode to AI documentation generation#3554
vinit-chauhan wants to merge 3 commits into
elastic:mainfrom
vinit-chauhan:doc_update_2

Conversation

@vinit-chauhan
Copy link
Copy Markdown
Contributor

Extend the elastic-package update documentation command with an interactive review mode, a browser-based preview of the generated docs, and a multi-file selection prompt. Also drop the AI-assisted disclaimer from the generated README.

By default, the command now runs in interactive mode; pass --non-interactive to keep the previous fire-and-forget behavior (used in CI and scripted runs).

Core changes:

  • cmd/update: add --non-interactive flag and thread it through handleStandardMode and selectDocumentationFile. Default is interactive.
  • docagent: after generation, run runInteractiveSectionReview which renders the README, prompts the user to Accept or Cancel, and on cancel restores the original README. If the model never produced a README, prompt to Try again (with a revision prompt) or Exit.
  • docagent/interactive.go + interactive_test.go: new file containing the interactive action loop (getUserAction, displayReadme, handleReadmeUpdate, handleUserAction, handleAcceptAction) with unit tests for the README-update detection logic.
  • cmd/updatedocumentation: when multiple .md files exist under _dev/build/docs, prompt the user to pick one in interactive mode instead of silently defaulting to README.md.
  • llmagent/ui (new package): TryBrowserPreview converts the rendered markdown to HTML using gomarkdown, writes it to a temp file, and opens it in the system browser (open / xdg-open / start). Includes an embedded _static/preview_template.html GitHub-style stylesheet with light and dark mode support.
  • internal/tui/textcomponent.go (new): unified Bubble Tea TextComponent supporting both a scrollable ViewMode (used as the terminal fallback when no browser is available, via ShowContent) and an EditMode text area (AskTextArea) for future multi-line input. Mouse and alternate-screen support enabled.
  • parsing/combiner.go + validators/structurevalidator_test.go: drop the disclaimer from CombineSectionsWithTitle and EnsureDocumentTitle, and update the structure-validator test fixture to match.
  • README.md: update the update documentation command docs to describe the interactive file-selection behavior alongside --doc-file.

mjwolf and others added 3 commits May 12, 2026 11:43
Co-authored-by: Jonathan Molinatto <jonathan.molinatto@gmail.com>
Co-authored-by: Quan Nguyen <quan.nguyen@elastic.co>
Co-authored-by: Cursor <cursoragent@cursor.com>
Propagate errors from restoreOriginalReadme through ActionResult so
cancellation paths surface failures instead of silently dropping them.
Resolves errcheck lint findings introduced when adapting the interactive
mode to the new core docagent structure that landed in main.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vinit-chauhan vinit-chauhan requested a review from a team as a code owner May 12, 2026 20:55
@vinit-chauhan vinit-chauhan self-assigned this May 12, 2026
@elasticmachine
Copy link
Copy Markdown
Collaborator

elasticmachine commented May 12, 2026

Copy link
Copy Markdown
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Reviewed changes in cmd and internal/tui.

model := newTextComponentModel(component)
program := tea.NewProgram(model)

finalModel, err := program.Run()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit. Methods that run TUI programs should be in runner.go, this file should only contain the new component.

}

// AskTextArea runs a text area dialog for multi-line input
func AskTextArea(message string) (string, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method is not used?

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.

4 participants