Complete "Lowering perceived latency" pattern documentation
- Expand `App_ontoolinputpartial_progressiveRendering` example in `app.examples.ts` to show full state management pattern with `toolInputs` and `toolInputsPartial` variables - Add healed JSON caveat to `ontoolinputpartial` JSDoc in `app.ts` - Update `patterns.md` to reference the expanded example and document the streaming preview pattern - Remove empty `lowerPerceivedLatency` placeholder from `patterns.tsx` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
dce143e92e
commit
a1ae100ef0
2 changed files with 33 additions and 18 deletions
|
|
@ -60,13 +60,14 @@ Listen for display mode changes via {@link app!App.onhostcontextchanged onhostco
|
|||
|
||||
{@includeCode ./patterns.tsx#persistData}
|
||||
|
||||
## [TODO] Lower perceived latency / manage loading time
|
||||
## Lowering perceived latency
|
||||
|
||||
Leverage partial inputs to show widgets as possible.
|
||||
Use {@link app!App.ontoolinputpartial ontoolinputpartial} to receive streaming tool arguments as they arrive, allowing you to show a loading preview before the complete input is available.
|
||||
|
||||
Beware of partial JSON being partial (but healed), so some of your objects may not be complete (e.g. in a list you may need to skip the last item if your code validates input schemas strictly).
|
||||
{@includeCode ../src/app.examples.ts#App_ontoolinputpartial_progressiveRendering}
|
||||
|
||||
{@includeCode ./patterns.tsx#lowerPerceivedLatency}
|
||||
> [!IMPORTANT]
|
||||
> Partial arguments are "healed" JSON — the host closes unclosed brackets/braces to produce valid JSON. This means objects may be incomplete (e.g., the last item in an array may be truncated). Don't rely on partial data for critical operations; use it only for preview UI.
|
||||
|
||||
## [TODO] Supporting both iframe & MCP Apps in same binary
|
||||
|
||||
|
|
|
|||
|
|
@ -111,17 +111,6 @@ function persistData(app: App) {
|
|||
//#endregion persistData
|
||||
}
|
||||
|
||||
/**
|
||||
* Example: Lower perceived latency / manage loading time
|
||||
*/
|
||||
function lowerPerceivedLatency(app: App) {
|
||||
//#region lowerPerceivedLatency
|
||||
// TODO: Leverage partial inputs to show widgets as possible.
|
||||
// Beware of partial JSON being partial (but healed),
|
||||
// so some objects may not be complete.
|
||||
//#endregion lowerPerceivedLatency
|
||||
}
|
||||
|
||||
/**
|
||||
* Example: Supporting both iframe & MCP Apps in same binary
|
||||
*/
|
||||
|
|
@ -147,6 +136,5 @@ void errorsToModel;
|
|||
void hostStylingVanillaJs;
|
||||
void hostStylingReact;
|
||||
void persistData;
|
||||
void lowerPerceivedLatency;
|
||||
void iframeAndMcpApps;
|
||||
void migrateFromOpenai;
|
||||
|
|
|
|||
Loading…
Reference in a new issue