@@ -223,24 +223,6 @@ function buildTwoStatus(state) {
223223 relationship : state . two . relationship ?? null ,
224224 } ;
225225
226- if ( state . two . selectedCell ) {
227- const r = state . two . selectedCell . r ;
228- const c = state . two . selectedCell . c ;
229- const selectedCell = { r, c } ;
230- if ( trials > 0 ) {
231- const jointCount = joint [ r ] ?. [ c ] ?? 0 ;
232- const pJoint = jointCount / trials ;
233- const pA = ( countsA [ r ] ?? 0 ) / trials ;
234- const pB = ( countsB [ c ] ?? 0 ) / trials ;
235- selectedCell . pJoint = pJoint ;
236- selectedCell . pA = pA ;
237- selectedCell . pB = pB ;
238- selectedCell . pAGivenB = pB > 0 ? pJoint / pB : null ;
239- selectedCell . pBGivenA = pA > 0 ? pJoint / pA : null ;
240- }
241- data . selectedCell = selectedCell ;
242- }
243-
244226 const sections = normalizeSections ( state . sections ) ;
245227 if ( sections . jointDistribution ) {
246228 data . jointDistribution = {
@@ -325,10 +307,35 @@ export function createActivityLogger() {
325307 lastTrials = trials ;
326308 }
327309
310+ function logCellClick ( state , source ) {
311+ if ( state . mode !== 'two' ) return ;
312+ if ( ! state . two . selectedCell ) return ;
313+
314+ const defA = state . two . definitionA ;
315+ const defB = state . two . definitionB ;
316+ if ( ! defA || ! defB ) return ;
317+
318+ const r = state . two . selectedCell . r ;
319+ const c = state . two . selectedCell . c ;
320+
321+ postEvent ( {
322+ type : 'click' ,
323+ data : {
324+ source,
325+ cell : { r, c } ,
326+ labels : {
327+ a : defA . labels [ r ] ?? null ,
328+ b : defB . labels [ c ] ?? null ,
329+ } ,
330+ } ,
331+ } ) ;
332+ }
333+
328334 return {
329335 logAppStart,
330336 logSettingsChange,
331337 logRunReset,
332338 maybeLogStatus,
339+ logCellClick,
333340 } ;
334341}
0 commit comments