Skip to content

Feat: Kairos commands priority#441

Merged
nytamin merged 8 commits into
mainfrom
feat/kairos-tally-priority
Mar 16, 2026
Merged

Feat: Kairos commands priority#441
nytamin merged 8 commits into
mainfrom
feat/kairos-tally-priority

Conversation

@nytamin

@nytamin nytamin commented Feb 25, 2026

Copy link
Copy Markdown
Member

About the Contributor

This pull request is posted on behalf of the NRK.

Type of Contribution

This is a: Feature

Current Behavior

Commands sent to the Kairos vision mixer are sent in a "best effort" order.
In certain scenarios when updating several things at once, visual artifacts might show because "inner content" is not ready yet.

An example is when switching to a Split scene with multiple content boxes, the boxes might display the wrong content for a frame or two, because we switched to the Split before the boxes in it where ready.

New Behavior

We now build a "dependency graph" using the known state and mappings, in order to determine which commands should be sent in what order to ensure that sources are handled first.

Testing Instructions

This PR affects the Kairos device only.
Test by switching to split views on a Kairos.

Other Information

Note: This is based on #425

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

Overview

This PR introduces command priority ordering for the Kairos vision mixer integration, eliminating transient visual artifacts that occurred when multiple commands were sent simultaneously in arbitrary order. The implementation builds a dependency graph from the current device state and mappings to ensure sources and content are configured before layout and split changes are applied.

Key Changes

Dependency Updates

  • kairos-lib bumped from 0.2.3 to 1.0.0 in packages/timeline-state-resolver-types/package.json
  • kairos-connection updated from 0.2.3 to ^1.0.0 in packages/timeline-state-resolver/package.json to allow 1.x releases

New Modules

temporal-priority.ts – Core ordering logic

  • temporalPriorityOrderCommands(): computes dependency graph and returns commands ordered by temporal priority
  • buildDependencyGraph(): constructs dependency graph from Kairos state and mappings
  • orderCommandsByTemporalPriority(): sorts commands using computed priorities
  • Includes cycle detection and priority propagation across dependency chains

kairos-application-monitor.ts – Health monitoring

  • KairosApplicationMonitor class: periodically verifies Kairos integration health by checking existence of referenced scenes, clips, auxiliaries, inputs, and other items via TTL-based awareness tracking
  • Emits statusChanged and error events
  • Supports rapid check coalescing and scheduled monitoring intervals

Schema Changes

mappings.json

  • Added temporalPriority property (integer, default 0) to scene, scene-layer, aux, clip-player, ram-rec-player, image-store, and sound-player mappings with UI metadata

options.json

  • Added monitorState boolean property (default false) to enable application monitoring

Type System Refactoring

commands.ts

  • Introduced public type KairosCommandWithContext = CommandWithContext<KairosCommandAny, string>
  • Renamed KairosSoundPlayerCommand to KairosAudioPlayerCommand (updated throughout codebase)
  • Updated KairosCommandAny union to reference new audio command type

stateBuilder.ts

  • Refactored KairosDeviceState with new exported type aliases for each device component:
    • KairosDeviceStateScenes, KairosDeviceStateSceneSnapshots, KairosDeviceStateSceneLayers, KairosDeviceStateAux, KairosDeviceStateMacros, KairosDeviceStateClipPlayers, KairosDeviceStateRamRecPlayers, KairosDeviceStateImageStores, KairosDeviceStateSoundPlayers
  • Updated fromTimeline() signature to use Mappings<SomeMappingKairos> for better type specificity

Integration Updates

index.ts (KairosDevice)

  • Integrated KairosApplicationMonitor when options.monitorState is enabled
  • Monitor lifecycle management in init() and terminate()
  • Enhanced getStatus() to report monitor health status
  • Modified diffStates() to apply temporal priority ordering via temporalPriorityOrderCommands() after computing diffs
  • Updated convertTimelineStateToDeviceState() to notify monitor of state changes

Library Updates

kairosRamLoader.ts

  • Relaxed clipRef validation to accept any valid ref and verify realm type separately

media-players.ts

  • Updated import and type references from KairosSoundPlayerCommand to KairosAudioPlayerCommand

Test Coverage

temporal-priority.spec.ts – New comprehensive test suite (801 lines)

  • Tests dependency graph construction with various Kairos state configurations
  • Validates command ordering with Aux → Scene → Layer → ClipPlayer chains
  • Tests split view scenarios with prioritized layer ordering
  • Verifies influence of temporalPriority mappings on command sequences
  • Ensures explicit ordering of clip loads, source settings, and scene layer updates

diffState.spec.ts

  • Updated import path for KairosCommandWithContext from commands module

Other Changes

  • DeviceInstance.ts: Updated StateHandler type parameter from CommandWithContext<any, any> to CommandWithContext<unknown, unknown>
  • Removed TODO comment about temporal order from diffState.ts (now implemented)

Impact

  • Only the Kairos device integration is affected
  • No breaking changes to public APIs, but several type refinements and additions
  • Feature is opt-in via monitorState option
  • Documentation updates remain outstanding

Monitor Kairos status, to ensure that all resources mentioned in mappings and state exists on the Kairos.
# Conflicts:
#	packages/timeline-state-resolver/src/integrations/kairos/index.ts
@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Walkthrough

The PR updates Kairos dependencies, adds KairosApplicationMonitor for runtime health checks, implements temporal-priority-based command ordering, refactors Kairos device-state types into exported aliases, renames a sound command type to audio, extends schemas with temporalPriority and monitorState, and adds tests and minor type/validation tweaks.

Changes

Cohort / File(s) Summary
Dependency updates
packages/timeline-state-resolver-types/package.json, packages/timeline-state-resolver/package.json
Bumped kairos-lib 0.2.3 → 1.0.0 and kairos-connection 0.2.3 → ^1.0.0.
Schemas
packages/timeline-state-resolver/src/integrations/kairos/$schemas/mappings.json, packages/timeline-state-resolver/src/integrations/kairos/$schemas/options.json
Added temporalPriority to multiple mappings and monitorState option; formatting changes to required arrays.
Command types & imports
packages/timeline-state-resolver/src/integrations/kairos/commands.ts, .../diffState/media-players.ts, .../diffState.ts, .../__tests__/diffState.spec.ts
Renamed KairosSoundPlayerCommandKairosAudioPlayerCommand; introduced/exported KairosCommandWithContext in commands.ts and updated import paths in diff modules/tests.
Temporal priority feature
packages/timeline-state-resolver/src/integrations/kairos/temporal-priority.ts, .../diffState.ts, .../index.ts
New temporal-priority module: builds dependency graph, propagates priorities, and reorders diff commands; integrated into diffStates.
Application monitoring
packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts, .../index.ts
Added KairosApplicationMonitor class, lifecycle integration in KairosDevice (init, terminate, status influence), and monitor-driven status reporting.
Device state refactor
packages/timeline-state-resolver/src/integrations/kairos/stateBuilder.ts
Extracted per-entity exported type aliases (scenes, layers, players, etc.) and updated KairosDeviceState shape and fromTimeline generics.
Runtime/validation & small typing
packages/timeline-state-resolver/src/integrations/kairos/lib/kairosRamLoader.ts, packages/timeline-state-resolver/src/service/DeviceInstance.ts
Relaxed clipRef validation with early return for unsupported realms; tightened StateHandler generic from any to unknown.
Tests
packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts
Added comprehensive temporal priority tests (~801 lines) covering dependency scenarios and ordering expectations.

Sequence Diagram(s)

sequenceDiagram
    participant Timeline
    participant KairosDevice
    participant KairosApplicationMonitor
    participant KairosConnection
    participant DiffEngine
    participant TemporalPrioritizer
    participant CommandQueue

    Timeline->>KairosDevice: convertTimelineStateToDeviceState()
    KairosDevice->>KairosDevice: build device state (StateBuilder)
    KairosDevice->>KairosApplicationMonitor: updateMappings & updateDeviceState

    Timeline->>KairosDevice: diffStates(old, new)
    KairosDevice->>DiffEngine: diffKairosStates()
    DiffEngine-->>KairosDevice: commands (unordered)

    KairosDevice->>TemporalPrioritizer: temporalPriorityOrderCommands(commands)
    TemporalPrioritizer->>TemporalPrioritizer: buildDependencyGraph()
    TemporalPrioritizer->>TemporalPrioritizer: propagate temporalPriority
    TemporalPrioritizer-->>KairosDevice: ordered commands

    KairosDevice->>CommandQueue: return prioritized commands
Loading
sequenceDiagram
    participant KairosDevice
    participant KairosApplicationMonitor
    participant KairosConnection
    participant StatusEmitter

    KairosDevice->>KairosApplicationMonitor: init (if monitorState enabled)
    KairosApplicationMonitor->>KairosApplicationMonitor: schedule checks

    loop monitor interval
        KairosApplicationMonitor->>KairosApplicationMonitor: collect aware refs (mappings + deviceState)
        KairosApplicationMonitor->>KairosConnection: exists(ref)
        KairosConnection-->>KairosApplicationMonitor: exists result / error
        alt status changed
            KairosApplicationMonitor->>StatusEmitter: emit statusChanged
            StatusEmitter-->>KairosDevice: receive status
            KairosDevice->>KairosDevice: refresh connection state
        end
    end

    KairosDevice->>KairosApplicationMonitor: terminate()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • Julusian
  • chandrashekar-nallamilli

Poem

🐰
Hopping through mappings with a twitch of my ear,
Priorities sorted so commands appear clear,
A monitor watches each scene and each cue,
Audio now named, types tidy and new,
I nibble the bugs and cheer — integration, hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "Feat: Kairos commands priority" directly summarizes the main change: introducing priority-based ordering for Kairos commands to handle dependencies correctly.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/kairos-tally-priority

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nytamin nytamin force-pushed the feat/kairos-tally-priority branch from fb6e1b1 to 19b1a7a Compare February 25, 2026 13:24
@nytamin nytamin marked this pull request as ready for review February 25, 2026 13:34
@nytamin nytamin changed the title Feat/kairos tally priority Feat: Kairos commands priority Feb 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts (1)

338-353: Consider removing stale commented interface block.

This commented-out block is dead code and adds maintenance noise in a new file.

🧹 Optional cleanup
-// export interface Aware {
-// 	sceneLayers: Set<SceneLayerRef>
-// 	sceneSnapshot: Set<SceneSnapshotRef>
-// 	sceneLayerEffects: Set<SceneLayerEffectRef>
-
-// 	auxes: Set<AuxRef>
-// 	macros: Set<MacroRef>
-// 	anySources: Set<AnySourceRef>
-
-// 	soundPlayers: Set<AudioPlayerRef>
-
-// 	mediaClips: Set<MediaClipRef>
-// 	mediaStills: Set<MediaStillRef | MediaImageRef>
-// 	mediaRamRecs: Set<MediaRamRecRef>
-// 	mediaSounds: Set<MediaSoundRef>
-// }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts`
around lines 338 - 353, Remove the stale commented-out Aware interface block
(the commented lines starting with "export interface Aware" and its properties
like sceneLayers, sceneSnapshot, sceneLayerEffects, auxes, macros, anySources,
soundPlayers, mediaClips, mediaStills, mediaRamRecs, mediaSounds) from
kairos-application-monitor.ts to eliminate dead code and reduce maintenance
noise; if the interface is needed later, restore it from VCS rather than keeping
it commented in the file.
packages/timeline-state-resolver/src/integrations/kairos/index.ts (1)

93-104: Side-effecting state notifications inside convertTimelineStateToDeviceState.

Calling updateMappings and updateDeviceState on the monitor inside a method whose name implies a pure conversion is a bit surprising. This is a pragmatic placement (it's the only point where both mappings and device state are available), but worth a brief inline comment noting why the monitor is updated here.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/timeline-state-resolver/src/integrations/kairos/index.ts` around
lines 93 - 104, The method convertTimelineStateToDeviceState currently performs
side effects by calling this._kairosApplicationMonitor?.updateMappings(...) and
updateDeviceState(...) even though its name suggests a pure conversion; add a
brief inline comment immediately above those monitor calls (near
KairosStateBuilder.fromTimeline and the two updateMappings/updateDeviceState
lines) stating that this is intentionally done here because this is the only
place where both mappings and the derived KairosDeviceState are available and
the monitor must be notified, and mark that this method therefore performs a
deliberate side-effect for clarity.
packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts (2)

33-33: Local variable Mappings shadows the imported type Mappings.

The local const Mappings on this line (and similarly at Lines 214, 411, 605) shadows the Mappings type imported on Line 5. TypeScript allows this because the import is type-only, but it can confuse readers. Consider renaming the local variables (e.g., testMappings or kaMappings) for clarity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts`
at line 33, Rename the local constant `Mappings` (e.g., to `testMappings` or
`kairosMappings`) so it no longer shadows the imported type `Mappings`; update
its declaration `const Mappings: Mappings<SomeMappingKairos> = {` and every use
of that local variable in this test (and the other occurrences you noted at the
same file: the declarations around lines 214, 411, 605) to the new name while
keeping the type annotation `Mappings<SomeMappingKairos>` unchanged.

712-751: In-place mutation of shared Mappings object is fragile.

The test mutates Mappings.scene2Content.options.temporalPriority directly and cleans up with delete at the end of each scoped block. This is fine today since Jest runs synchronously within a single test(), but it's brittle if someone later restructures or adds assertions between blocks without realizing the shared mutation pattern. A safer approach would be to spread/clone the mappings per sub-case.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts`
around lines 712 - 751, The test mutates the shared Mappings object via
Mappings.scene2Content.options.temporalPriority and then deletes it—make a
cloned per-case mapping instead to avoid fragile shared state: create a
shallow/deep clone (e.g., structuredClone or JSON deep clone) into a local
variable (e.g., localMappings), set
localMappings.scene2Content.options.temporalPriority = 1000, call
temporalPriorityOrderCommands(state, localMappings,
diffKairosStates(EMPTY_STATE, state, localMappings)), run the assertions against
the returned commands, and remove the in-place delete; do the same pattern for
other sub-cases so each uses its own cloned Mappings instance.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts`:
- Line 787: Fix the typo in the test comment that reads "The the ones with no
temporalPriority" by changing it to "Then the ones with no temporalPriority";
locate the string in the temporal-priority.spec test file (search for the exact
phrase "The the ones with no temporalPriority") and update the comment text so
the sentence reads correctly.

In
`@packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts`:
- Around line 241-243: The issue is a malformed message string that inserts an
extra ')' into the monitor issue text; locate the code in
kairos-application-monitor.ts where the ResponseError branch pushes to the
issues array (the line using issues.push(`${description}) not found on the
Kairos.`)) and remove the stray parenthesis so the pushed string reads
`${description} not found on the Kairos.` to fix the noisy status text.

In
`@packages/timeline-state-resolver/src/integrations/kairos/temporal-priority.ts`:
- Around line 244-245: The branch handling media-player commands always maps
media-player:do to refClipPlayer, causing ram-rec-player and sound-player
actions to get the wrong temporal priority; update the branch that checks
command.command.type === 'media-player:do' to inspect command.command.playerType
and dispatch to the correct reference function (e.g., use refRamRecPlayer for
playerType 'ram-rec-player', refSoundPlayer for 'sound-player', and
refClipPlayer for clip players), ensuring the code paths that call
refClipPlayer, refRamRecPlayer, and refSoundPlayer use the correct playerId from
command.command.playerId.

---

Nitpick comments:
In
`@packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts`:
- Line 33: Rename the local constant `Mappings` (e.g., to `testMappings` or
`kairosMappings`) so it no longer shadows the imported type `Mappings`; update
its declaration `const Mappings: Mappings<SomeMappingKairos> = {` and every use
of that local variable in this test (and the other occurrences you noted at the
same file: the declarations around lines 214, 411, 605) to the new name while
keeping the type annotation `Mappings<SomeMappingKairos>` unchanged.
- Around line 712-751: The test mutates the shared Mappings object via
Mappings.scene2Content.options.temporalPriority and then deletes it—make a
cloned per-case mapping instead to avoid fragile shared state: create a
shallow/deep clone (e.g., structuredClone or JSON deep clone) into a local
variable (e.g., localMappings), set
localMappings.scene2Content.options.temporalPriority = 1000, call
temporalPriorityOrderCommands(state, localMappings,
diffKairosStates(EMPTY_STATE, state, localMappings)), run the assertions against
the returned commands, and remove the in-place delete; do the same pattern for
other sub-cases so each uses its own cloned Mappings instance.

In `@packages/timeline-state-resolver/src/integrations/kairos/index.ts`:
- Around line 93-104: The method convertTimelineStateToDeviceState currently
performs side effects by calling
this._kairosApplicationMonitor?.updateMappings(...) and updateDeviceState(...)
even though its name suggests a pure conversion; add a brief inline comment
immediately above those monitor calls (near KairosStateBuilder.fromTimeline and
the two updateMappings/updateDeviceState lines) stating that this is
intentionally done here because this is the only place where both mappings and
the derived KairosDeviceState are available and the monitor must be notified,
and mark that this method therefore performs a deliberate side-effect for
clarity.

In
`@packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts`:
- Around line 338-353: Remove the stale commented-out Aware interface block (the
commented lines starting with "export interface Aware" and its properties like
sceneLayers, sceneSnapshot, sceneLayerEffects, auxes, macros, anySources,
soundPlayers, mediaClips, mediaStills, mediaRamRecs, mediaSounds) from
kairos-application-monitor.ts to eliminate dead code and reduce maintenance
noise; if the interface is needed later, restore it from VCS rather than keeping
it commented in the file.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0de8867 and 19b1a7a.

⛔ Files ignored due to path filters (2)
  • packages/timeline-state-resolver-types/src/generated/kairos.ts is excluded by !**/generated/**
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (15)
  • packages/timeline-state-resolver-types/package.json
  • packages/timeline-state-resolver/package.json
  • packages/timeline-state-resolver/src/integrations/kairos/$schemas/mappings.json
  • packages/timeline-state-resolver/src/integrations/kairos/$schemas/options.json
  • packages/timeline-state-resolver/src/integrations/kairos/__tests__/diffState.spec.ts
  • packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts
  • packages/timeline-state-resolver/src/integrations/kairos/commands.ts
  • packages/timeline-state-resolver/src/integrations/kairos/diffState.ts
  • packages/timeline-state-resolver/src/integrations/kairos/diffState/media-players.ts
  • packages/timeline-state-resolver/src/integrations/kairos/index.ts
  • packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts
  • packages/timeline-state-resolver/src/integrations/kairos/lib/kairosRamLoader.ts
  • packages/timeline-state-resolver/src/integrations/kairos/stateBuilder.ts
  • packages/timeline-state-resolver/src/integrations/kairos/temporal-priority.ts
  • packages/timeline-state-resolver/src/service/DeviceInstance.ts

Comment on lines +241 to +243
if (e instanceof ResponseError) {
issues.push(`${description}) not found on the Kairos.`)
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix malformed monitor issue message formatting.

Line 242 currently adds an extra ) which produces noisy status text.

💡 Proposed fix
-					issues.push(`${description}) not found on the Kairos.`)
+					issues.push(`${description} not found on the Kairos.`)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (e instanceof ResponseError) {
issues.push(`${description}) not found on the Kairos.`)
} else {
if (e instanceof ResponseError) {
issues.push(`${description} not found on the Kairos.`)
} else {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/timeline-state-resolver/src/integrations/kairos/kairos-application-monitor.ts`
around lines 241 - 243, The issue is a malformed message string that inserts an
extra ')' into the monitor issue text; locate the code in
kairos-application-monitor.ts where the ResponseError branch pushes to the
issues array (the line using issues.push(`${description}) not found on the
Kairos.`)) and remove the stray parenthesis so the pushed string reads
`${description} not found on the Kairos.` to fix the noisy status text.

Comment thread packages/timeline-state-resolver/src/integrations/kairos/temporal-priority.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts (1)

712-800: Consider isolating mapping mutations to avoid test pollution on failure.

The code mutates Mappings.scene2Content.options.temporalPriority directly and relies on delete for cleanup. If an assertion fails before cleanup, subsequent test blocks would inherit the polluted state. Consider creating a fresh mappings copy for each block.

♻️ Suggested approach using spread for isolated test blocks
{
  // Test with high temporalPriority on scene2
  const testMappings: Mappings<MappingKairosSceneLayer> = {
    ...Mappings,
    scene2Content: {
      ...Mappings.scene2Content,
      options: { ...Mappings.scene2Content.options, temporalPriority: 1000 },
    },
  }
  
  const commands = temporalPriorityOrderCommands(
    state,
    testMappings,
    diffKairosStates(EMPTY_STATE, state, testMappings)
  )
  // ... assertions ...
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts`
around lines 712 - 800, The test mutates global Mappings (e.g.
Mappings.scene2Content.options.temporalPriority / scene3Content) and relies on
delete for cleanup which can leak state on assertion failures; instead create
isolated copies (e.g. const testMappings = { ...Mappings, scene2Content: {
...Mappings.scene2Content, options: { ...Mappings.scene2Content.options,
temporalPriority: 1000 } } } ) and pass testMappings into
temporalPriorityOrderCommands and diffKairosStates (use EMPTY_STATE and state as
before) so each block runs with its own mapping snapshot and no deletes are
needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts`:
- Around line 712-800: The test mutates global Mappings (e.g.
Mappings.scene2Content.options.temporalPriority / scene3Content) and relies on
delete for cleanup which can leak state on assertion failures; instead create
isolated copies (e.g. const testMappings = { ...Mappings, scene2Content: {
...Mappings.scene2Content, options: { ...Mappings.scene2Content.options,
temporalPriority: 1000 } } } ) and pass testMappings into
temporalPriorityOrderCommands and diffKairosStates (use EMPTY_STATE and state as
before) so each block runs with its own mapping snapshot and no deletes are
needed.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19b1a7a and 724c25d.

📒 Files selected for processing (2)
  • packages/timeline-state-resolver/src/integrations/kairos/__tests__/temporal-priority.spec.ts
  • packages/timeline-state-resolver/src/integrations/kairos/temporal-priority.ts

@nytamin nytamin merged commit efe07d6 into main Mar 16, 2026
33 checks passed
@nytamin nytamin deleted the feat/kairos-tally-priority branch March 16, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants