logo
  • Docs
  • API Reference
    Overview
    Functions
    acceptChangeProposal
    applyChangeSet
    attachConversation
    attachLabel
    commitIsAncestorOf
    commitIsDescendantOf
    createAccount
    createChangeProposal
    createChangeSet
    createCheckpoint
    createConversation
    createConversationMessage
    createHooks
    createLabel
    createLog
    createLspInMemoryEnvironment
    createQuerySync
    createServerProtocolHandler
    createVersion
    createVersionFromCommit
    detachConversation
    detachLabel
    ebEntity
    getTimestamp
    humanId
    mergeVersion
    nanoId
    newLixFile
    nextSequenceNumber
    normalizeDirectoryPath
    normalizeFilePath
    normalizePathSegment
    openLix
    random
    rejectChangeProposal
    selectCommitDiff
    selectVersionDiff
    selectWorkingDiff
    switchAccount
    switchVersion
    transition
    uuidV7
    uuidV7Sync
    validateLixSchema
    validateLixSchemaDefinition
    withWriterKey
    Type Aliases
    Account
    ActiveAccount
    Change
    ChangeAuthor
    DetectedChange
    EntityStateByVersionView
    EntityStateHistoryView
    EntityStateView
    EnvironmentActorHandle
    FromLixSchemaDefinition
    JSONType
    Lix
    LixActiveVersion
    LixChangeProposal
    LixChangeSet
    LixChangeSetElement
    LixCommit
    LixCommitEdge
    LixConversation
    LixConversationMessage
    LixDatabaseSchema
    LixDirectoryDescriptor
    LixEntity
    LixEntityCanonical
    LixEntityConversation
    LixEntityLabel
    LixFile
    LixFileDescriptor
    LixGenerated
    LixHooks
    LixInsertable
    LixKeyValue
    LixLabel
    LixLog
    LixPlugin
    LixSchemaDefinition
    LixSelectable
    LixServerProtocolHandlerContext
    LixUpdateable
    LixVersion
    LixVersionDescriptor
    LixVersionTip
    NewChange
    NewState
    NewStateByVersion
    NewStateByVersionRow
    NewStateRow
    QuerySync
    RenderDiffArgs
    SpawnActorOptions
    State
    StateByVersion
    StateByVersionRow
    StateByVersionRowUpdate
    StateByVersionUpdate
    StateByVersionView
    StateCommitChange
    StateHistory
    StateRow
    StateRowUpdate
    StateUpdate
    StateView
    StateWithTombstonesRow
    StateWithTombstonesView
    StoredSchema
    ToKysely
    Variables
    JSONTypeSchema
    LixAccountSchema
    LixActiveAccountSchema
    LixActiveVersionSchema
    LixChangeAuthorSchema
    LixChangeProposalSchema
    LixChangeSetElementSchema
    LixChangeSetSchema
    LixCommitEdgeSchema
    LixCommitSchema
    LixConversationMessageSchema
    LixConversationSchema
    LixDirectoryDescriptorSchema
    LixFileDescriptorSchema
    LixKeyValueSchema
    LixLabelSchema
    LixLogSchema
    LixSchemaDefinition
    LixStoredSchemaSchema
    LixVersionDescriptorSchema
    LixVersionTipSchema
    mockJsonPlugin
    Classes
    InMemoryEnvironment
    LixObservable
    OpfsSahEnvironment
    Interfaces
    LixEnvironment
    Previous pagerejectChangeProposalNext pageselectVersionDiff

    #Function: selectCommitDiff()

    selectCommitDiff(args: { after: string; before: string; hints?: { entityIds?: string[]; fileId?: string; includeUnchanged?: boolean; pluginKey?: string; schemaKeys?: string[]; }; lix: Lix; }): SelectQueryBuilder<any, "diff", DiffRow>

    Compare two commits and return differences between their leaf entity states.

    Reconstructs entity states at each commit by walking commit ancestry, then compares them. Unlike version-based diffs, this dynamically computes states without requiring version materialization.

    Diff status meanings:

    • added: Entity exists only in after commit
    • removed: Entity exists only in before commit
    • modified: Entity exists in both with different change_ids
    • unchanged: Entity exists in both with same change_id

    Uses fast-path optimization when includeUnchanged: false (default) by first identifying changed entity triples, then only reconstructing leaf states for those.

    The hints parameter filters results at the database level for better performance:

    • includeUnchanged: Include unchanged entities (default: true). Set false for fast-path optimization.
    • fileId: Limit to specific file
    • pluginKey: Filter by plugin that created changes
    • schemaKeys: Include only specific entity types
    • entityIds: Include only specific entities

    #Examples

    // Get changes between commits
    const changes = await selectCommitDiff({
      lix,
      before: 'abc123',
      after: 'xyz789',
      hints: { includeUnchanged: false }
    }).execute();
    // Filter by file and status
    const fileDiff = await selectCommitDiff({ lix, before, after })
      .where('diff.file_id', '=', 'messages.json')
      .where('diff.status', '!=', 'unchanged')
      .execute();

    #Parameters

    ParameterType
    args{ after: string; before: string; hints?: { entityIds?: string[]; fileId?: string; includeUnchanged?: boolean; pluginKey?: string; schemaKeys?: string[]; }; lix: Lix; }
    args.afterstring
    args.beforestring
    args.hints?{ entityIds?: string[]; fileId?: string; includeUnchanged?: boolean; pluginKey?: string; schemaKeys?: string[]; }
    args.hints.entityIds?string[]
    args.hints.fileId?string
    args.hints.includeUnchanged?boolean
    args.hints.pluginKey?string
    args.hints.schemaKeys?string[]
    args.lixLix

    #Returns

    SelectQueryBuilder<any, "diff", DiffRow>