Skip to content

Document next_flow in async_create_entry in RepairsFlow#2985

Open
iluvdata wants to merge 12 commits into
home-assistant:masterfrom
iluvdata:master
Open

Document next_flow in async_create_entry in RepairsFlow#2985
iluvdata wants to merge 12 commits into
home-assistant:masterfrom
iluvdata:master

Conversation

@iluvdata
Copy link
Copy Markdown

@iluvdata iluvdata commented Mar 7, 2026

Proposed change

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features for which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Remove stale or deprecated documentation

Checklist

  • I have read and followed the documentation guidelines.
  • I have verified that my changes render correctly in the documentation.

Additional information

Summary by CodeRabbit

  • Documentation
    • Updated repair flow examples to reflect revised return conventions and adjusted imports.
    • Added examples showing how repair flows can forward completed fixes into entry/config/options/subentry reconfiguration flows, including how to pass issue identifiers and the expected next-flow format.
    • Clarified lifecycle behavior: when forwarding, integrations must explicitly remove the original issue after successful reconfiguration, with a reconfigure snippet demonstrating deletion.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 7, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Updated documentation in docs/core/platform/repairs.md to use RepairsFlowResult return types, adjust imports, and add examples and guidance for forwarding completed repairs via next_flow, including lifecycle responsibilities for deleting issues after reconfiguration.

Changes

Cohort / File(s) Summary
Documentation
docs/core/platform/repairs.md
Examples updated to return RepairsFlowResult from async_step_init/async_step_confirm and imports adjusted. Added guidance and examples for forwarding repairs using next_flow into entry/config/options/subentry flows (examples with FlowType, flow_id, SubentryFlowContext + SOURCE_RECONFIGURE, FlowType.CONFIG_SUBENTRIES_FLOW). Clarified next_flow restrictions (e.g., reconfigure-only sources for certain flow types), passing issue_id and expected next_flow tuple shape, and added lifecycle note requiring integrations to explicitly delete the issue after reconfiguration (example using ir.async_delete_issue(...)). Lines changed: +126/-4.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: documenting the next_flow feature in async_create_entry within RepairsFlow, which aligns with the documentation additions shown in the summary.
Description check ✅ Passed The PR description follows the template structure with the Type of change properly selected and all checklist items marked complete, though the 'Proposed change' section is empty and only a core PR link is provided without an issue number.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
docs/core/platform/repairs.md (2)

136-136: Remove trailing whitespace.

Lines 136, 138, 160, and 162 have trailing whitespace after the commas. Consider removing these for cleaner formatting.

✨ Remove trailing spaces
-            return self.async_create_entry(
-                title="", data={}, 
-                next_flow=(
-                    FlowType.CONFIG_SUBENTRIES_FLOW, 
+            return self.async_create_entry(
+                title="", data={},
+                next_flow=(
+                    FlowType.CONFIG_SUBENTRIES_FLOW,
                     next_flow["flow_id"]
                 )
             )
-return self.async_create_entry(
-    title="", data={}, 
-    next_flow=(
-        FlowType.OPTIONS_FLOW,
+return self.async_create_entry(
+    title="", data={},
+    next_flow=(
+        FlowType.OPTIONS_FLOW,
         next_flow["flow_id"]
     )
 )

Also applies to: 138-138, 160-160, 162-162

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/core/platform/repairs.md` at line 136, Remove the trailing whitespace
after commas in the snippet shown (e.g. the "title=\"\", data={," fragment) on
the affected lines (136, 138, 160, 162); edit those lines to remove the extra
spaces immediately following the commas so they read without trailing spaces
(e.g. "title=\"\", data={}"). Ensure no other trailing spaces remain in the
surrounding lines.

103-103: Remove unused import.

ConfirmRepairFlow is imported on line 103 but not used in the code example. Consider removing it to keep the example focused.

🧹 Remove unused import
-from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow
+from homeassistant.components.repairs import RepairsFlow
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/core/platform/repairs.md` at line 103, The import line currently
includes an unused symbol ConfirmRepairFlow; remove ConfirmRepairFlow from the
import so only the used RepairsFlow is imported (i.e., update the import that
reads "from homeassistant.components.repairs import ConfirmRepairFlow,
RepairsFlow" to import only RepairsFlow).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/core/platform/repairs.md`:
- Around line 153-166: The example uses the symbol ConfigFlowResult but it's not
imported; add an import for ConfigFlowResult from homeassistant.config_entries
in the module's imports so the options flow snippet (where async_init is called
and async_create_entry with next_flow is returned) will not raise a NameError.
- Around line 101-147: The example references SubentryFlowContext but does not
import it; add the missing import so the symbol is defined (e.g., import
SubentryFlowContext from the same module that provides subentry APIs) and ensure
the example's imports at the top include SubentryFlowContext so
Issue1RepairFlow.async_step_confirm can call SubentryFlowContext without a
NameError.
- Line 138: The explanatory text incorrectly references
FlowType.SUBENTRIES_FLOW; update that text to use the correct enum member
FlowType.CONFIG_SUBENTRIES_FLOW so it matches the code example (replace any
occurrence of FlowType.SUBENTRIES_FLOW in the explanatory paragraph with
FlowType.CONFIG_SUBENTRIES_FLOW).

---

Nitpick comments:
In `@docs/core/platform/repairs.md`:
- Line 136: Remove the trailing whitespace after commas in the snippet shown
(e.g. the "title=\"\", data={," fragment) on the affected lines (136, 138, 160,
162); edit those lines to remove the extra spaces immediately following the
commas so they read without trailing spaces (e.g. "title=\"\", data={}"). Ensure
no other trailing spaces remain in the surrounding lines.
- Line 103: The import line currently includes an unused symbol
ConfirmRepairFlow; remove ConfirmRepairFlow from the import so only the used
RepairsFlow is imported (i.e., update the import that reads "from
homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow" to
import only RepairsFlow).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09eba6b2-0c59-4c94-9758-e0b7e657dcf0

📥 Commits

Reviewing files that changed from the base of the PR and between 974c323 and 29e1d6e.

📒 Files selected for processing (1)
  • docs/core/platform/repairs.md

Comment thread docs/core/platform/repairs.md
Comment thread docs/core/platform/repairs.md Outdated
Comment thread docs/core/platform/repairs.md
Updated context source description for next_flow issue repair flows.
Comment thread docs/core/platform/repairs.md
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/core/platform/repairs.md`:
- Around line 101-147: The example uses vol.Schema({}) in
Issue1RepairFlow.async_step_confirm but never imports voluptuous; add the
missing top-level import "import voluptuous as vol" alongside the other imports
so vol.Schema is defined and the async_step_confirm return self.async_show_form
call works correctly.
- Around line 154-167: The snippet uses an undefined config_entry; change it to
read the entry id from self.data (e.g. assign config_entry_id =
self.data["entry_id"]) and pass that id into
self.hass.config_entries.options.async_init instead of config_entry.entry_id,
then use the returned next_flow in the existing self.async_create_entry call
(keeping FlowType.OPTIONS_FLOW and next_flow["flow_id"]) so the example is
consistent with the earlier snippet.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f620fa80-3d80-4ab5-af81-f0209e897336

📥 Commits

Reviewing files that changed from the base of the PR and between 29e1d6e and 1aa79a1.

📒 Files selected for processing (1)
  • docs/core/platform/repairs.md

Comment thread docs/core/platform/repairs.md
Comment thread docs/core/platform/repairs.md
@iluvdata
Copy link
Copy Markdown
Author

Retested with dev branch of frontend and next flow is no longer working even for config flows. The dialog is created then closed. There were many recent updates to ha-dialog.ts that appears to have broken this. Investigating a frontend patch.

@MartinHjelmare
Copy link
Copy Markdown
Member

Ok, thanks for the update. I'll draft this then.

@MartinHjelmare MartinHjelmare marked this pull request as draft March 12, 2026 11:41
iluvdata added 2 commits April 3, 2026 12:30
Updated return types RepairsFlowResult instead of data_entry_flow.FlowResult. Added notes on issue lifecycle and next_flow usage.
@iluvdata
Copy link
Copy Markdown
Author

iluvdata commented Apr 3, 2026

The bug with ha-dialog.ts has been addressed. There is an additional minor frontend bug fix pending as noted in home-assistant/core#165091.

@iluvdata iluvdata marked this pull request as ready for review April 3, 2026 16:47
Updated documentation to reflect the changes to the backend in the draft PR
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/core/platform/repairs.md`:
- Line 224: The docs reference uses the wrong class name: change
`RepairFlow.async_create_entry` to the correct API symbol
`RepairsFlow.async_create_entry` so the documentation matches the codebase;
update the text where the class is mentioned to use
`RepairsFlow.async_create_entry` (and ensure any nearby cross-references or
links also use `RepairsFlow`) so the API reference is accurate.
- Around line 227-243: The docstring in the async_step_reconfigure example is
opened but not closed, causing invalid Python; close the triple-quoted docstring
for the function async_step_reconfigure (i.e., add the closing triple quotes
after the line """Config entry reconfigure""") so the snippet compiles, keeping
the rest of the logic (calls to ir.async_delete_issue,
self.async_update_reload_and_abort, and _get_reconfigure_entry) unchanged.
- Line 147: In the lifecycle note that mentions using next_flow in the repair
flow's async_abort, fix the misspelling and broken fragment: change
"responsiblity" to "responsibility" and update the markdown link from
[delete](`#deleting_an_issue`) to use the correct heading fragment
[delete](`#deleting-an-issue`) so it matches the target heading; locate the
sentence referencing next_flow and async_abort to apply these two text fixes.
- Around line 177-190: The example incorrectly types the result of
repairs_flow_handler.async_init as RepairsFlow; change the variable declaration
so next_flow is typed as RepairsFlowResult (the flow result mapping returned by
async_init) and then use next_flow["flow_id"] when passing
(FlowType.REPAIR_FLOW, next_flow["flow_id"]) into self.async_create_entry;
update the declaration that currently reads something like repairs_flow_handler:
RepairsFlowManager = async_get(self.hass) / next_flow: RepairsFlow = await
repairs_flow_handler.async_init(...) to instead declare next_flow as
RepairsFlowResult while keeping the call to repairs_flow_handler.async_init and
the self.async_create_entry usage unchanged.
🪄 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: CHILL

Plan: Pro

Run ID: f7cd75c5-607d-4b24-ae9c-806fa4817b1d

📥 Commits

Reviewing files that changed from the base of the PR and between aa9cfd6 and 557fd54.

📒 Files selected for processing (1)
  • docs/core/platform/repairs.md

Comment thread docs/core/platform/repairs.md Outdated
Comment thread docs/core/platform/repairs.md
Comment thread docs/core/platform/repairs.md Outdated
Comment thread docs/core/platform/repairs.md
@iluvdata
Copy link
Copy Markdown
Author

  1. Added documentation of repair flow as a repair flow's next_flow as discussed in Add next_flow to Repair Flows core#165091 (comment).
  2. Removed requirement that next_flows init step be SOURCE_RECONFIGURE.

@iluvdata iluvdata marked this pull request as draft April 28, 2026 01:16
Clarified the usage of `context` for `issue_id` in `RepairsFlowManager` and updated notes on issue deletion in repair flows.
@iluvdata iluvdata marked this pull request as ready for review April 29, 2026 16:41
Clarified how `data` and `issue_id` get passed into the `RepairsFlow`.
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