要求智能體為新增查詢加入載入及錯誤處理路徑
Require the agent to add a loading and error path when it wires a new query
Sherotree 建議將新查詢介面缺少載入或錯誤處理視為未完成,並要求涵蓋載入、錯誤和成功狀態。他建議沿用現有載入骨架、錯誤或重試處理,並在提示詞及程式碼審查中檢查各分支;若父層已處理,應在 PR 指明。清單可能為空時,還要加入空狀態。
The PR wires a new query and renders the happy-path view. While the request is in flight, the section is blank. If it fails, the same blank stays, or a raw error object appears in the corner. The repo already has a loading skeleton, a query status flag, and an error state (a retry button, an inline alert, or the existing error helper). None of them made it into this file.
I've started treating a new query without loading and error paths as incomplete, not as a follow-up. The success view is easy to demo. The empty and failed moments are what users actually hit on a slow or unhappy network.
Why the happy path ships alone
The prompt often says "load the project and show the header." The model writes data && <Header /> and stops. Existing skeleton and error components are easy to miss if you do not name them. A TypeScript type that makes data required after a guard also hides the pending and error branches from the happy-path typings.
A "we'll add the spinner later" comment is how these land in production.
A simple query-UI policy
- A new query UI includes loading, error, and success
- Use the existing skeleton or loading helper, not a one-off "Loading..." string, unless the file already does that
- Use the existing error helper or retry pattern, not a raw error message dump
- Empty success (zero items) is a fourth path when the list can be empty
If the parent already handles loading and error, say so in the PR. Do not assume it does.
What to put in the prompt
This new query needs a loading path and an error path, not only the success view.
Use the existing skeleton or loading helper, and the existing error/retry helper.
If the list can be empty, use the existing empty state, not a blank region.
Do not leave a TODO for these paths.
Paste one nearby query UI that already has the three paths. In review, search the new hook-up for isLoading / isPending, isError / error, and a success render that is not the only branch.
Reject / send back
Reject
- A new query that only renders when data exists
- A blank section while the request is in flight
- A raw error object, or no error path at all
- A TODO that defers loading and error to a later PR
Accept
- A query UI with loading, error, and success, using existing helpers
- A note that the parent already owns those paths, with a pointer to it
- An empty-success path when the list can be empty
來源:DEV Community · dev.to