arcane-os 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -407,27 +407,60 @@ function effectiveDashboardVisibility(definitions=[],visibility={}){
407
407
  );
408
408
  }
409
409
 
410
- function formatAIRuntimeProgress(progress,fallback){
411
- const phase=is.string(progress?.phase)&&progress.phase
412
- ?progress.phase
413
- :fallback;
414
- const completed=progress?.completed;
415
- const total=progress?.total;
416
- const unit=is.string(progress?.unit)
417
- ?progress.unit
418
- :'';
419
- if(!is.finite(completed)
420
- ||!is.finite(total)
421
- ||total<=0
422
- ||!unit){
423
- return phase;
410
+ function formatAIRuntimeProgress(progress, fallback) {
411
+ const phase = is.string(progress?.phase) && progress.phase
412
+ ? progress.phase
413
+ : fallback;
414
+ const parts = [phase];
415
+ const message = is.string(progress?.message) && progress.message
416
+ ? progress.message
417
+ : is.string(progress?.stage) && progress.stage
418
+ ? progress.stage
419
+ : '';
420
+ if (message && message !== phase) {
421
+ parts.push(message);
424
422
  }
425
- return `${phase} · ${completed} of ${total} ${unit}`;
423
+ const item = is.string(progress?.item) && progress.item
424
+ ? progress.item
425
+ : is.string(progress?.file) && progress.file
426
+ ? progress.file
427
+ : '';
428
+ if (item && item !== message) {
429
+ parts.push(item);
430
+ }
431
+ const completed = progress?.completed;
432
+ const total = progress?.total;
433
+ const unit = is.string(progress?.unit)
434
+ ? progress.unit
435
+ : '';
436
+ if (is.finite(completed) && is.finite(total) && total > 0 && unit) {
437
+ parts.push(`${completed} of ${total} ${unit}`);
438
+ } else if (is.finite(completed) && completed >= 0 && unit === 'files') {
439
+ parts.push(`${completed} files complete`);
440
+ }
441
+ if (is.finite(progress?.elapsedMs) && progress.elapsedMs >= 0) {
442
+ const elapsedSeconds = Math.floor(progress.elapsedMs / 1000);
443
+ const hours = Math.floor(elapsedSeconds / 3600);
444
+ const minutes = Math.floor(elapsedSeconds % 3600 / 60);
445
+ const seconds = elapsedSeconds % 60;
446
+ parts.push(
447
+ hours > 0
448
+ ? `${hours}h ${minutes}m elapsed`
449
+ : minutes > 0
450
+ ? `${minutes}m ${String(seconds).padStart(2, '0')}s elapsed`
451
+ : `${seconds}s elapsed`
452
+ );
453
+ }
454
+ if (progress?.heartbeat === true) {
455
+ parts.push('Still working');
456
+ }
457
+ return parts.join(' · ');
426
458
  }
427
459
 
428
460
  function createSTTActivationController({
429
461
  host,
430
462
  button,
463
+ progress = null,
431
464
  onChange,
432
465
  EventClass=globalThis.CustomEvent,
433
466
  eventSource=null
@@ -595,6 +628,40 @@ function createSTTActivationController({
595
628
  &&['unloaded','loading','unloading','error'].includes(role.state);
596
629
  }
597
630
 
631
+ function renderProgress() {
632
+ if (!progress) {
633
+ return;
634
+ }
635
+ const active = !destroyed
636
+ && (requestPending || ['loading', 'unloading'].includes(role?.state));
637
+ progress.hidden = !active;
638
+ if (!active) {
639
+ progress.removeAttribute('value');
640
+ progress.removeAttribute('max');
641
+ progress.removeAttribute('aria-valuetext');
642
+ return;
643
+ }
644
+ const completed = role?.progress?.completed;
645
+ const total = role?.progress?.total;
646
+ const unit = role?.progress?.unit;
647
+ if (!is.finite(completed)
648
+ || completed < 0
649
+ || !is.finite(total)
650
+ || total <= 0
651
+ || !is.string(unit)
652
+ || !unit) {
653
+ progress.removeAttribute('value');
654
+ progress.removeAttribute('max');
655
+ } else {
656
+ progress.max = total;
657
+ progress.value = completed;
658
+ }
659
+ progress.setAttribute(
660
+ 'aria-valuetext',
661
+ status()
662
+ );
663
+ }
664
+
598
665
  async function request(nextAction){
599
666
  if(destroyed||requestPending||action()!==nextAction){
600
667
  return false;
@@ -647,6 +714,7 @@ function createSTTActivationController({
647
714
  ||action()!==nextAction){
648
715
  return false;
649
716
  }
717
+ renderProgress();
650
718
  onChange();
651
719
  if(destroyed
652
720
  ||generation!==requestGeneration
@@ -715,6 +783,7 @@ function createSTTActivationController({
715
783
  if(!destroyed&&generation===requestGeneration){
716
784
  requestPending=false;
717
785
  try{
786
+ renderProgress();
718
787
  onChange();
719
788
  }catch(error){
720
789
  arcaneLogging.error('Unable to render STT activation state:',error);
@@ -749,6 +818,7 @@ function createSTTActivationController({
749
818
  requestPending=false;
750
819
  }
751
820
  role=nextRole;
821
+ renderProgress();
752
822
  }
753
823
 
754
824
  function destroy(){
@@ -758,6 +828,7 @@ function createSTTActivationController({
758
828
  destroyed=true;
759
829
  requestGeneration+=1;
760
830
  requestPending=false;
831
+ renderProgress();
761
832
  try{
762
833
  button.removeEventListener('click',activateSelectedSTT);
763
834
  }catch(error){