Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

Applications need a way to react when translation live update events are received (e.g., refresh UI, log changes).

Changes

  • New LiveUpdateCallback interface - Functional interface in cc.modlabs.klassicx.translation.interfaces for receiving LiveUpdateEvent notifications

  • TranslationManager callback support

    • registerLiveUpdateCallback(callback) - Register for notifications
    • unregisterLiveUpdateCallback(callback) - Unregister, returns success boolean
    • Uses CopyOnWriteArrayList for thread-safe concurrent access
    • Callbacks invoked before internal event processing in the live updates collector
  • Translations convenience methods - Exposes registration/unregistration at singleton level

Usage

Translations.registerLiveUpdateCallback { event ->
    when (event) {
        is KeyUpdatedEvent -> refreshUI(event.locale)
        is KeyCreatedEvent -> logNewKey(event.key)
        is KeyDeletedEvent -> removeFromCache(event.keyId)
        is HelloEvent -> println("Connected: ${event.permission}")
    }
}

Tests

Added 7 tests covering callback invocation for all event types, multiple callback support, and unregistration behavior.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.modlabs.cc
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/KlassicX/KlassicX/build/tmp/test/work @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath16319203949745440357txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 1' (dns block)
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/KlassicX/KlassicX/build/tmp/test/work @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath10581063890304351738txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 1' (dns block)
  • jitpack.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • nexus.fruxz.dev
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • nexus.modlabs.cc
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add callback for liveUpdates translations</issue_title>
<issue_description>Applications should be able to register a callback function that runs on translation liveUpdate events</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@diffy-bot
Copy link

diffy-bot bot commented Nov 26, 2025

Git Diff Summary

No diff content was provided — there is nothing to summarize.

How to provide a diff:

  • Paste the output of git diff (or git diff --staged) into the message.
  • Or attach a patch file (unified diff / .patch).
  • Optionally include the commit range (e.g., git diff HEAD~1..HEAD) or PR link.

You can generate a new summary by commenting @diffy-bot

Copilot AI changed the title [WIP] Add callback for liveUpdates translations Add callback for liveUpdates translations Nov 26, 2025
Copilot AI requested a review from CoasterFreakDE November 26, 2025 23:06
@CoasterFreakDE CoasterFreakDE marked this pull request as ready for review November 27, 2025 16:04
Removed unused Maven repositories and re-enabled the 'dev.fruxz:ascend' dependency, which was previously commented out due to sandbox network restrictions.
@CoasterFreakDE CoasterFreakDE merged commit b7f4825 into main Nov 27, 2025
2 of 3 checks passed
@CoasterFreakDE CoasterFreakDE deleted the copilot/add-callback-liveupdates-translations branch November 27, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add callback for liveUpdates translations

2 participants