Skip to content

Commit 375f73e

Browse files
agviegasclaude
andcommitted
types(history): setSourceIcon, so an app can say which tool wrote a commit
Regenerated from platform_builtin-components d6c232d. A commit's badge is no longer always the Revit logo: components.get(GitHistoryManager).setSourceIcon("rhino", "<url|data:|svg>") The diff is larger than that one method because the same distribute run also carries the encoding repair: those types had been through a utf8 -> cp1252 -> utf8 round trip and their comments were full of doubled characters. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent b7c9e0e commit 375f73e

1 file changed

Lines changed: 66 additions & 41 deletions

File tree

src/built-in/index.ts

Lines changed: 66 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ export type ContextMode = "default" | "hidden";
11421142
/** The three kinds of change a commit can carry. */
11431143
export type ChangeKind = "create" | "update" | "delete";
11441144
/**
1145-
* Stable id for a commit across models — which is now just its guid.
1145+
* Stable id for a commit across models which is now just its guid.
11461146
*
11471147
* It used to have to be `${model}:${id}`, because the id was a per-model version number and every
11481148
* model had a commit 3. A guid needs no help being unique, and that is exactly what it was for.
@@ -1155,25 +1155,25 @@ export declare const commitKey: (c: {
11551155
}) => string;
11561156
/** How the commit is shown in 3D: review colours, or the model as it ended up. */
11571157
export type HighlightMode = "colored" | "plain";
1158-
/** Dominant change type of a commit: delete → create → update. */
1158+
/** Dominant change type of a commit: delete create update. */
11591159
export declare function dominantChange(commit: RevitFlowCommit): DominantChange;
11601160
/**
1161-
* GitHistoryManager — headless engine for the revit-flow git-history built-in.
1161+
* GitHistoryManager headless engine for the revit-flow git-history built-in.
11621162
*
1163-
* Owns ALL viewer mutation for the change outlines. It does NOT load the model —
1163+
* Owns ALL viewer mutation for the change outlines. It does NOT load the model
11641164
* the user opens a model from the Project Files panel, and this manager reacts to
11651165
* that load: it reads the model's hidden `revitflow_history.json` (if any) and
11661166
* publishes the commit list. Showing a commit outlines its changed elements
1167-
* (create → green, update → blue, delete → red) via three independently-colored
1168-
* `OBF.Outliner` groups — a cheap post-process outline that never recolors the
1167+
* (create green, update blue, delete red) via three independently-colored
1168+
* `OBF.Outliner` groups a cheap post-process outline that never recolors the
11691169
* fragment geometry. The Lit panel (`top-git-history`) is intent-only: it calls
11701170
* these methods and subscribes to the events below.
11711171
*
11721172
* Data model, per loaded model (fileId == modelId), all HIDDEN children of it:
1173-
* - revitflow_history.json — { model, commits: [{ id, parent, author, source,
1173+
* - revitflow_history.json { model, commits: [{ id, parent, author, source,
11741174
* timestamp, changes:[{type,uniqueId}], counts }] }. The first commit is the
11751175
* INITIAL full-model capture (its geometry == the visible baseline file).
1176-
* - revitflow_frag_<N>.frag — delta fragments for commit N (its created+modified
1176+
* - revitflow_frag_<N>.frag delta fragments for commit N (its created+modified
11771177
* geometry), loaded on demand so created elements can be colored.
11781178
*/
11791179
declare class _GitHistoryManager extends OBC.Component {
@@ -1186,15 +1186,40 @@ declare class _GitHistoryManager extends OBC.Component {
11861186
readonly onError: OBC.Event<string>;
11871187
/** The GUID currently selected in the 3D view (null when the selection is cleared). */
11881188
readonly onSelectedGuidChanged: OBC.Event<string | null>;
1189+
/** A source icon was added or replaced. */
1190+
readonly onSourceIconsChanged: OBC.Event<void>;
1191+
/**
1192+
* Which mark to draw on a commit, by the application that wrote it.
1193+
*
1194+
* Every commit already says who made it, in `source`. The panel used to draw the Revit logo on
1195+
* all of them regardless, which was true while Revit was the only thing that could write one and
1196+
* became a lie the moment anything else did: a commit from another tool would claim to be a
1197+
* Revit commit, on the one part of the row whose whole job is to say where a change came from.
1198+
*
1199+
* The format is deliberately open about who writes history, so the icons have to be too. This is
1200+
* the registry. Only `revit` is built in; an application adds its own:
1201+
*
1202+
* const history = components.get(GitHistoryManager);
1203+
* history.setSourceIcon("rhino", "https://…/rhino.svg"); // a URL, or a data: URI
1204+
* history.setSourceIcon("tekla", "<svg viewBox='0 0 24 24'>…</svg>"); // or the markup
1205+
*
1206+
* A source with no icon gets a neutral one rather than somebody else's.
1207+
*/
1208+
readonly sourceIcons: Map<string, string>;
1209+
/**
1210+
* @param source the commit's own `source` value, matched case-insensitively.
1211+
* @param icon a URL, a `data:` URI, or inline `<svg>` markup.
1212+
*/
1213+
setSourceIcon(source: string, icon: string): void;
11891214
world?: OBC.World;
11901215
/**
11911216
* What happens to elements that are NOT part of the selected commit:
1192-
* "default" — left as they are (the change outlines sit on the full model)
1193-
* "hidden" — hidden entirely, isolating the commit's elements
1217+
* "default" left as they are (the change outlines sit on the full model)
1218+
* "hidden" hidden entirely, isolating the commit's elements
11941219
*
11951220
* A dimmed ("ghost") middle ground was dropped: the fragments x-ray writes depth
11961221
* from the pixels its screen door keeps, so dimmed geometry still occluded the very
1197-
* elements under review — worse the denser the model in front. Fixing that properly
1222+
* elements under review worse the denser the model in front. Fixing that properly
11981223
* belongs in the renderer, not here, so this offers the two states that are exact.
11991224
*/
12001225
contextMode: ContextMode;
@@ -1212,18 +1237,18 @@ declare class _GitHistoryManager extends OBC.Component {
12121237
prefetchRadius: number;
12131238
/**
12141239
* How a commit is presented in 3D:
1215-
* "colored" — outline created/edited/deleted in their colours (the review lens)
1216-
* "plain" — no outlines: the model simply as it stood AFTER the commit, so the
1240+
* "colored" outline created/edited/deleted in their colours (the review lens)
1241+
* "plain" no outlines: the model simply as it stood AFTER the commit, so the
12171242
* deleted elements are hidden rather than painted red
12181243
*/
12191244
highlightMode: HighlightMode;
1220-
/** @deprecated kept so older callers still compile — maps onto contextMode. */
1245+
/** @deprecated kept so older callers still compile maps onto contextMode. */
12211246
get isolateChanges(): boolean;
1222-
/** Green — created elements. */
1247+
/** Green created elements. */
12231248
readonly COLOR_CREATED = "#22c55e";
1224-
/** Golden yellow — modified elements. */
1249+
/** Golden yellow modified elements. */
12251250
readonly COLOR_MODIFIED = "#e3b341";
1226-
/** Red — deleted elements. */
1251+
/** Red deleted elements. */
12271252
readonly COLOR_DELETED = "#ef4444";
12281253
readonly GROUP_CREATED = "revitflow-created";
12291254
readonly GROUP_MODIFIED = "revitflow-modified";
@@ -1232,7 +1257,7 @@ declare class _GitHistoryManager extends OBC.Component {
12321257
private _projectId?;
12331258
/**
12341259
* One entry per loaded revit-flow model. Commit ids are per-model version numbers, so
1235-
* they collide across models — every commit is tagged with its modelId and a commit is
1260+
* they collide across models every commit is tagged with its modelId and a commit is
12361261
* addressed by {@link commitKey}, never by id alone.
12371262
*/
12381263
private _models;
@@ -1304,7 +1329,7 @@ declare class _GitHistoryManager extends OBC.Component {
13041329
init(client: PlatformClient): Promise<void>;
13051330
/**
13061331
* Follow the viewer's selection so the element view tracks whatever the user clicks in
1307-
* 3D — no "trace this" button to press. The Highlighter's events appear asynchronously
1332+
* 3D no "trace this" button to press. The Highlighter's events appear asynchronously
13081333
* (they're registered when the viewer sets it up), so retry briefly until they exist.
13091334
*/
13101335
private _watchSelection;
@@ -1313,7 +1338,7 @@ declare class _GitHistoryManager extends OBC.Component {
13131338
/**
13141339
* Probe a loaded model for a sibling visible `revitflow_history.json` in its
13151340
* folder. If present, adopt it as the active model and publish its commits.
1316-
* Silent for non-revit models and for our own delta frags — only genuine
1341+
* Silent for non-revit models and for our own delta frags only genuine
13171342
* fetch/parse failures raise onError.
13181343
*/
13191344
private _probeModel;
@@ -1348,7 +1373,7 @@ declare class _GitHistoryManager extends OBC.Component {
13481373
* Show the model as it stood AT `commit`: the visible baseline is the model at its
13491374
* INITIAL commit, and everything created later lives in per-commit delta .frags loaded
13501375
* as separate models. Those deltas stay loaded (the prefetch window keeps neighbours
1351-
* warm), so stepping BACK has to hide the ones from later commits — otherwise a wall
1376+
* warm), so stepping BACK has to hide the ones from later commits otherwise a wall
13521377
* added in commit 3 was still sitting there while you were looking at commit 2.
13531378
* Only touches deltas of the commit's own model; other models keep their own state.
13541379
*/
@@ -1388,7 +1413,7 @@ declare class _GitHistoryManager extends OBC.Component {
13881413
selectedGuids(): Promise<string[]>;
13891414
selectedGuid(): Promise<string | null>;
13901415
/**
1391-
* Select every element the commit touched, in the viewer's own selection — so the
1416+
* Select every element the commit touched, in the viewer's own selection so the
13921417
* usual tools (properties, isolate, zoom) work on it like any hand-made selection.
13931418
* Honours the current type filter, so "only deletions" selects only those.
13941419
* @returns how many elements ended up selected.
@@ -1402,11 +1427,11 @@ declare class _GitHistoryManager extends OBC.Component {
14021427
private _outliner;
14031428
/**
14041429
* Create the three independently-colored outline groups once. The viewer
1405-
* owns the Outliner's DEFAULT group (selection) — we only add our own named
1430+
* owns the Outliner's DEFAULT group (selection) we only add our own named
14061431
* groups and never touch "default".
14071432
*/
14081433
private _ensureGroups;
1409-
/** Clear our three outline groups only — leaves the viewer's default group. */
1434+
/** Clear our three outline groups only leaves the viewer's default group. */
14101435
private _clearOutlines;
14111436
/**
14121437
* Resolve each change bucket's GUIDs to localIds across every loaded model
@@ -1420,7 +1445,7 @@ declare class _GitHistoryManager extends OBC.Component {
14201445
private _dropSuperseded;
14211446
/**
14221447
* Hide (or restore) the elements a commit deleted. Tracked separately from the context
1423-
* modes so switching Colored↔Plain doesn't disturb ghosting or the rest of the model.
1448+
* modes so switching Colored↔Plain doesn't disturb ghosting or the rest of the model.
14241449
*/
14251450
private _applyDeletedVisibility;
14261451
/**
@@ -1429,14 +1454,14 @@ declare class _GitHistoryManager extends OBC.Component {
14291454
* THE BUG THIS EXISTS FOR. The baseline .frag holds the whole model as of the first
14301455
* commit, and every later commit ships a delta .frag with the geometry it created AND
14311456
* the geometry it modified. Both stay in the scene. For a CREATED element that is
1432-
* right — it exists in exactly one place. For a MODIFIED one it is not: the element is
1457+
* right it exists in exactly one place. For a MODIFIED one it is not: the element is
14331458
* in the baseline at its old shape and in the delta at its new one, and the viewer drew
14341459
* both. Measured 2026-08-05 on a wall whose height Quim raised: the new wall stood
14351460
* proud of the old one, with the coincident faces z-fighting into a dotted band.
14361461
*
14371462
* The rule is the obvious one once stated: for any element, only the newest VISIBLE
14381463
* source may draw it. Deltas are walked newest-first, each guid is claimed by the first
1439-
* source that has it, and every older copy — in an older delta or in the baseline — is
1464+
* source that has it, and every older copy in an older delta or in the baseline is
14401465
* hidden. Deltas newer than the commit being shown are already hidden wholesale by
14411466
* `_applyFutureVisibility`, so they never get to claim anything.
14421467
*
@@ -1454,13 +1479,13 @@ declare class _GitHistoryManager extends OBC.Component {
14541479
* load that commit's delta, which is the last place its geometry existed.
14551480
*/
14561481
private _ensureDeletedGeometry;
1457-
/** GUIDs → { modelId: Set<localId> } across the given models. */
1482+
/** GUIDs { modelId: Set<localId> } across the given models. */
14581483
private _buildMap;
14591484
private _mergeMaps;
14601485
/**
14611486
* Dim ("ghost") or hide every element that is NOT part of the shown commit, per the
14621487
* chosen context mode. Best-effort per model: a model that doesn't support the call is
1463-
* simply left alone — the outlines still convey the change.
1488+
* simply left alone the outlines still convey the change.
14641489
*/
14651490
private _applyContext;
14661491
/** Undo whatever the context mode did: drop the ghost overlay and restore visibility. */
@@ -1479,42 +1504,42 @@ declare class _GitHistoryManager extends OBC.Component {
14791504
}
14801505

14811506
/**
1482-
* GitHistoryManager — headless engine for the revit-flow git-history built-in.
1507+
* GitHistoryManager headless engine for the revit-flow git-history built-in.
14831508
*
1484-
* Owns ALL viewer mutation for the change outlines. It does NOT load the model —
1509+
* Owns ALL viewer mutation for the change outlines. It does NOT load the model
14851510
* the user opens a model from the Project Files panel, and this manager reacts to
14861511
* that load: it reads the model's hidden `revitflow_history.json` (if any) and
14871512
* publishes the commit list. Showing a commit outlines its changed elements
1488-
* (create → green, update → blue, delete → red) via three independently-colored
1489-
* `OBF.Outliner` groups — a cheap post-process outline that never recolors the
1513+
* (create green, update blue, delete red) via three independently-colored
1514+
* `OBF.Outliner` groups a cheap post-process outline that never recolors the
14901515
* fragment geometry. The Lit panel (`top-git-history`) is intent-only: it calls
14911516
* these methods and subscribes to the events below.
14921517
*
14931518
* Data model, per loaded model (fileId == modelId), all HIDDEN children of it:
1494-
* - revitflow_history.json — { model, commits: [{ id, parent, author, source,
1519+
* - revitflow_history.json { model, commits: [{ id, parent, author, source,
14951520
* timestamp, changes:[{type,uniqueId}], counts }] }. The first commit is the
14961521
* INITIAL full-model capture (its geometry == the visible baseline file).
1497-
* - revitflow_frag_<N>.frag — delta fragments for commit N (its created+modified
1522+
* - revitflow_frag_<N>.frag delta fragments for commit N (its created+modified
14981523
* geometry), loaded on demand so created elements can be colored.
14991524
*/
15001525
export type GitHistoryManager = InstanceType<typeof _GitHistoryManager>;
15011526
/**
1502-
* GitHistoryManager — headless engine for the revit-flow git-history built-in.
1527+
* GitHistoryManager headless engine for the revit-flow git-history built-in.
15031528
*
1504-
* Owns ALL viewer mutation for the change outlines. It does NOT load the model —
1529+
* Owns ALL viewer mutation for the change outlines. It does NOT load the model
15051530
* the user opens a model from the Project Files panel, and this manager reacts to
15061531
* that load: it reads the model's hidden `revitflow_history.json` (if any) and
15071532
* publishes the commit list. Showing a commit outlines its changed elements
1508-
* (create → green, update → blue, delete → red) via three independently-colored
1509-
* `OBF.Outliner` groups — a cheap post-process outline that never recolors the
1533+
* (create green, update blue, delete red) via three independently-colored
1534+
* `OBF.Outliner` groups a cheap post-process outline that never recolors the
15101535
* fragment geometry. The Lit panel (`top-git-history`) is intent-only: it calls
15111536
* these methods and subscribes to the events below.
15121537
*
15131538
* Data model, per loaded model (fileId == modelId), all HIDDEN children of it:
1514-
* - revitflow_history.json — { model, commits: [{ id, parent, author, source,
1539+
* - revitflow_history.json { model, commits: [{ id, parent, author, source,
15151540
* timestamp, changes:[{type,uniqueId}], counts }] }. The first commit is the
15161541
* INITIAL full-model capture (its geometry == the visible baseline file).
1517-
* - revitflow_frag_<N>.frag — delta fragments for commit N (its created+modified
1542+
* - revitflow_frag_<N>.frag delta fragments for commit N (its created+modified
15181543
* geometry), loaded on demand so created elements can be colored.
15191544
*/
15201545
export const GitHistoryManager = { uuid: '3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81' } as typeof _GitHistoryManager & { uuid: '3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81' };

0 commit comments

Comments
 (0)