Repository navigation
feat(widgets): shim show_widget html onto upstream HtmlRender #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { assert, describe, it } from "@effect/vitest"; | ||
| import * as Effect from "effect/Effect"; | ||
|
|
||
| import { | ||
| authorWidgetFromIntent, | ||
| shouldBypassBuilder, | ||
| T3TEAM_WIDGET_BUILDER_UNAVAILABLE, | ||
| } from "./t3team-widgetBuilder.ts"; | ||
|
|
||
| describe("t3team-widgetBuilder", () => { | ||
| it("shouldBypassBuilder is true only when widgetCode is non-empty", () => { | ||
| assert.isTrue(shouldBypassBuilder({ widgetCode: "<div/>" })); | ||
| assert.isFalse(shouldBypassBuilder({ widgetCode: "" })); | ||
| }); | ||
|
|
||
| it.effect("authorWidgetFromIntent fails without inventing HTML", () => | ||
| Effect.gen(function* () { | ||
| const result = yield* authorWidgetFromIntent({ | ||
| intent: "Show a chart", | ||
| title: "chart", | ||
| format: "html", | ||
| }).pipe(Effect.result); | ||
| assert.strictEqual(result._tag, "Failure"); | ||
| if (result._tag === "Failure") { | ||
| assert.strictEqual(result.failure, T3TEAM_WIDGET_BUILDER_UNAVAILABLE); | ||
| assert.include(result.failure, "widget_code"); | ||
| } | ||
| }), | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /** | ||
| * Intent → builder/authoring seam for `t3team.widget.show` / `thread.showWidget` | ||
| * (design intent PJ 2026-08-29, Epic 24 widget composition default). | ||
| * | ||
| * Flow: intent → builder subagent → widgetCode → format routing (html shim | widget tier). | ||
| * Raw `widget_code` bypasses this module entirely (required for deterministic workflow replay). | ||
| * | ||
| * The full builder loop (reuse-check → draft → typecheck → preview via HtmlRender → fix) is | ||
| * not wired to a model in this change-set; callers that pass only `intent` get a clear error | ||
| * until the subagent lands. Do not invent placeholder HTML here. | ||
| */ | ||
|
|
||
| import * as Effect from "effect/Effect"; | ||
|
|
||
| import type { T3TeamWidgetFormat, T3TeamWidgetShowInput } from "./t3team-widgetShowCore.ts"; | ||
|
|
||
| export const T3TEAM_WIDGET_BUILDER_UNAVAILABLE = | ||
| "Widget builder subagent is not connected yet. Pass widget_code to skip the builder " + | ||
| "(required for deterministic workflow replay), or retry once intent authoring is available."; | ||
|
|
||
| /** True when the caller supplied raw widget code and should skip the builder. */ | ||
| export function shouldBypassBuilder(parsed: Pick<T3TeamWidgetShowInput, "widgetCode">): boolean { | ||
| return parsed.widgetCode.length > 0; | ||
| } | ||
|
|
||
| export interface AuthorWidgetFromIntentInput { | ||
| readonly intent: string; | ||
| readonly title: string; | ||
| readonly format: T3TeamWidgetFormat; | ||
| } | ||
|
|
||
| export interface AuthorWidgetFromIntentResult { | ||
| readonly widgetCode: string; | ||
| readonly format: T3TeamWidgetFormat; | ||
| } | ||
|
|
||
| /** | ||
| * Author widget markup from an intent. Until the builder subagent is wired, this always | ||
| * fails with {@link T3TEAM_WIDGET_BUILDER_UNAVAILABLE} — never invents HTML. | ||
| */ | ||
| export function authorWidgetFromIntent( | ||
| _input: AuthorWidgetFromIntentInput, | ||
| ): Effect.Effect<AuthorWidgetFromIntentResult, string> { | ||
| return Effect.fail(T3TEAM_WIDGET_BUILDER_UNAVAILABLE); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any caller following the new model-facing recommendation to provide only
intentreaches this function, which unconditionally returnsT3TEAM_WIDGET_BUILDER_UNAVAILABLE; consequently the newly preferred/default path can never display a widget. Either keepintentout of the MCP/catalog/workflow contracts until the builder exists, or implement the builder before directing agents to use it.Useful? React with 👍 / 👎.