@@ -12,13 +12,14 @@ import {
1212} from "../sessions/session-key.ts" ;
1313import { GatewayBoardProvider } from "./gateway-provider.ts" ;
1414import { applyMockBoardOp , normalizeMockBoardSnapshot } from "./mock-ops.ts" ;
15+ import { emptyBoardSnapshot , normalizeBoardWidgetTitle } from "./provider-helpers.ts" ;
1516import {
1617 EventStream ,
1718 ValueSignal ,
1819 type BoardEventStream ,
1920 type BoardSnapshotSignal ,
2021} from "./provider-signals.ts" ;
21- import type { BoardProvider } from "./provider-types.ts" ;
22+ import type { BoardPinMcpAppInput , BoardPinWidgetInput , BoardProvider } from "./provider-types.ts" ;
2223import type { BoardWidgetAppViewState } from "./view-types.ts" ;
2324import { canvasWidgetNameForDocument , mcpAppWidgetNameForViewId } from "./widget-names.ts" ;
2425export type { BoardCommandEvent } ;
@@ -29,26 +30,6 @@ export { GatewayBoardProvider } from "./gateway-provider.ts";
2930
3031type BoardGatewayClient = Pick < GatewayBrowserClient , "request" | "addEventListener" > ;
3132
32- type BoardPinPlacement = {
33- title ?: string ;
34- name ?: string ;
35- tabId ?: string ;
36- size ?: "sm" | "md" | "lg" | "xl" | "full" ;
37- after ?: string ;
38- } ;
39-
40- type BoardPinWidgetInput = BoardPinPlacement & { docId : string } ;
41- type BoardPinMcpAppInput = BoardPinPlacement & { viewId : string } ;
42-
43- function emptySnapshot ( sessionKey : string ) : BoardSnapshot {
44- return { sessionKey, revision : 0 , tabs : [ ] , widgets : [ ] } ;
45- }
46-
47- function boardWidgetTitle ( title : string | undefined ) : string | undefined {
48- const normalized = title ?. trim ( ) ?? "" ;
49- return normalized ? Array . from ( normalized ) . slice ( 0 , 80 ) . join ( "" ) : undefined ;
50- }
51-
5233function mockSnapshot ( sessionKey : string ) : BoardSnapshot {
5334 return {
5435 sessionKey,
@@ -113,7 +94,7 @@ class NullProvider implements BoardProvider {
11394 readonly events : BoardEventStream < BoardCommandEvent > = new EventStream < BoardCommandEvent > ( ) ;
11495
11596 constructor ( readonly sessionKey = "" ) {
116- this . snapshot$ = new ValueSignal ( emptySnapshot ( sessionKey ) ) ;
97+ this . snapshot$ = new ValueSignal ( emptyBoardSnapshot ( sessionKey ) ) ;
11798 }
11899
119100 async applyOps ( _ops : BoardOp [ ] ) : Promise < void > { }
@@ -185,7 +166,7 @@ class MockBoardProvider implements BoardProvider {
185166 async pinWidget ( input : BoardPinWidgetInput ) : Promise < void > {
186167 const snapshot = this . snapshotSignal . value ;
187168 const name = input . name ?? canvasWidgetNameForDocument ( input . docId ) ;
188- const title = boardWidgetTitle ( input . title ) ;
169+ const title = normalizeBoardWidgetTitle ( input . title ) ;
189170 const tabId = input . tabId ?? snapshot . tabs [ 0 ] ?. tabId ?? "main" ;
190171 const tabs = snapshot . tabs . length
191172 ? snapshot . tabs
@@ -219,7 +200,7 @@ class MockBoardProvider implements BoardProvider {
219200 async pinMcpApp ( input : BoardPinMcpAppInput ) : Promise < void > {
220201 const snapshot = this . snapshotSignal . value ;
221202 const name = input . name ?? mcpAppWidgetNameForViewId ( input . viewId ) ;
222- const title = boardWidgetTitle ( input . title ) ;
203+ const title = normalizeBoardWidgetTitle ( input . title ) ;
223204 const tabId = input . tabId ?? snapshot . tabs [ 0 ] ?. tabId ?? "main" ;
224205 const tabs = snapshot . tabs . length
225206 ? snapshot . tabs
0 commit comments