Repository navigation
feat(mobile): improve cross-device agent Live Activities #4978
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
Closed
zortos293
wants to merge
11
commits into
pingdotgg:main
from
zortos293:feat/mobile-agent-activity-t3notch
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
861c328
feat(mobile): improve cross-device Live Activities
zortos293 a86a68a
fix(mobile): address Live Activity review feedback
zortos293 a93fab9
fix mobile agent activity summaries
zortos293 0a87c82
fix agent activity provider artwork
zortos293 667effa
handle capped agent activity heroes
zortos293 ed980af
republish activity on provider changes
zortos293 58d8f1c
serialize agent activity republishes
zortos293 2aa5939
allow concurrent agent activity threads
zortos293 582700d
serialize agent activity aggregates per user
zortos293 6d0e574
close agent activity publish ordering gaps
zortos293 8e3d1ba
Merge branch 'main' into feat/mobile-agent-activity-t3notch
zortos293 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,132 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| // Derives the widget extension's provider marks from the web app's icons. | ||
| // | ||
| // The Live Activity resolves its marks through an asset catalog (`Image | ||
| // assetName`), so it cannot import the React components in | ||
| // apps/web/src/components/Icons.tsx. Rather than hand-copy the path data and let | ||
| // it drift, generate the SVGs from that file and verify them in CI. | ||
| // | ||
| // node scripts/sync-provider-marks.mjs # write | ||
| // node scripts/sync-provider-marks.mjs --check # verify, exit 1 on drift | ||
|
|
||
| import * as NodeFSP from "node:fs/promises"; | ||
| import * as NodePath from "node:path"; | ||
| import * as NodeProcess from "node:process"; | ||
| import * as NodeURL from "node:url"; | ||
|
|
||
| const MOBILE_ROOT = NodePath.resolve( | ||
| NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)), | ||
| "..", | ||
| ); | ||
| const REPO_ROOT = NodePath.resolve(MOBILE_ROOT, "../.."); | ||
| const ICONS_SOURCE = NodePath.join(REPO_ROOT, "apps/web/src/components/Icons.tsx"); | ||
| const OUTPUT_DIR = NodePath.join(MOBILE_ROOT, "assets/widget"); | ||
|
|
||
| // Asset name -> the exported icon it comes from. The asset names are what | ||
| // withWidgetLogoAsset.cjs ships and what the widget layouts ask for; the | ||
| // components mirror PROVIDER_ICON_BY_PROVIDER in providerIconUtils.ts. | ||
| const MARKS = [ | ||
| { asset: "Codex", component: "OpenAI" }, | ||
| { asset: "Claude", component: "ClaudeAI" }, | ||
| { asset: "Cursor", component: "CursorIcon" }, | ||
| { asset: "Grok", component: "GrokIcon" }, | ||
| { asset: "OpenCode", component: "OpenCodeIcon" }, | ||
| ]; | ||
|
|
||
| // Cursor's mark is one path holding the outer cube and the inner facet. Nonzero | ||
| // winding fills both and collapses it to a featureless block, so it needs | ||
| // even-odd for the facet to cut through. | ||
| const EVEN_ODD = new Set(["Cursor"]); | ||
| // OpenCode's mark is a frame plus a dimmer inner block. A template image is a | ||
| // single colour, so the inner block is carried at partial opacity instead. | ||
| const INNER_BLOCK_OPACITY = "0.45"; | ||
|
|
||
| function componentBlock(source, name) { | ||
| const start = source.indexOf(`export const ${name}: Icon`); | ||
| if (start === -1) throw new Error(`Icons.tsx no longer exports ${name}`); | ||
| const end = source.indexOf("\nexport const ", start + 10); | ||
| return source.slice(start, end === -1 ? undefined : end); | ||
| } | ||
|
|
||
| function viewBox(block, name) { | ||
| const match = /viewBox="([^"]+)"/.exec(block); | ||
| if (!match) throw new Error(`${name} has no viewBox`); | ||
| return match[1]; | ||
| } | ||
|
|
||
| function pathTags(block) { | ||
| return [...block.matchAll(/<path\b([^>]*?)\/>/gs)].map((match) => match[1]); | ||
| } | ||
|
|
||
| function pathData(attributes, name) { | ||
| const match = /(?:^|\s)d="([^"]+)"/s.exec(attributes); | ||
| if (!match) throw new Error(`${name} has a <path> without a d attribute`); | ||
| return match[1]; | ||
| } | ||
|
|
||
| function renderSvg({ asset, block }) { | ||
| const box = viewBox(block, asset); | ||
| const [, , width, height] = box.split(/\s+/); | ||
| const fillRule = EVEN_ODD.has(asset) ? ' fill-rule="evenodd"' : ""; | ||
|
|
||
| let paths; | ||
| if (asset === "OpenCode") { | ||
| // Icons.tsx carries a light and a dark pair toggled by className; take the | ||
| // dark one, whose frame is the light shape on a dark surface. | ||
| const dark = pathTags(block).filter((attributes) => attributes.includes("dark:block")); | ||
| if (dark.length !== 2) { | ||
| throw new Error(`OpenCodeIcon no longer has exactly two dark-mode paths (${dark.length})`); | ||
| } | ||
| const [inner, frame] = dark; | ||
| paths = [ | ||
| ` <path fill="currentColor" fill-opacity="${INNER_BLOCK_OPACITY}" d="${pathData(inner, asset)}"/>`, | ||
| ` <path fill="currentColor" d="${pathData(frame, asset)}"/>`, | ||
| ]; | ||
| } else { | ||
| paths = pathTags(block).map( | ||
| (attributes) => ` <path fill="currentColor"${fillRule} d="${pathData(attributes, asset)}"/>`, | ||
| ); | ||
| } | ||
| if (paths.length === 0) throw new Error(`${asset} produced no paths`); | ||
|
|
||
| return ( | ||
| `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" ` + | ||
| `viewBox="${box}">\n${paths.join("\n")}\n</svg>\n` | ||
| ); | ||
| } | ||
|
|
||
| const checkOnly = NodeProcess.argv.includes("--check"); | ||
| const source = await NodeFSP.readFile(ICONS_SOURCE, "utf8"); | ||
|
|
||
| const drifted = []; | ||
| let written = 0; | ||
| for (const mark of MARKS) { | ||
| const svg = renderSvg({ asset: mark.asset, block: componentBlock(source, mark.component) }); | ||
| const target = NodePath.join(OUTPUT_DIR, `${mark.asset}.svg`); | ||
| const current = await NodeFSP.readFile(target, "utf8").catch(() => null); | ||
| if (current === svg) continue; | ||
| if (checkOnly) { | ||
| drifted.push(mark.asset); | ||
| continue; | ||
| } | ||
| await NodeFSP.mkdir(OUTPUT_DIR, { recursive: true }); | ||
| await NodeFSP.writeFile(target, svg); | ||
| written += 1; | ||
| console.log(`updated ${NodePath.relative(REPO_ROOT, target)}`); | ||
| } | ||
|
|
||
| if (checkOnly && drifted.length > 0) { | ||
| console.error( | ||
| `Provider marks are out of date with Icons.tsx: ${drifted.join(", ")}.\n` + | ||
| "Run `vp run --filter @t3tools/mobile sync:provider-marks` and commit the result.", | ||
| ); | ||
| NodeProcess.exit(1); | ||
| } | ||
| console.log( | ||
| checkOnly | ||
| ? `All ${MARKS.length} provider marks are current.` | ||
| : written === 0 | ||
| ? `All ${MARKS.length} provider marks were already current.` | ||
| : `Updated ${written} of ${MARKS.length} provider marks.`, | ||
| ); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.