@viamrobotics/test-widgets 0.16.0 → 0.17.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.
Files changed (132) hide show
  1. package/dist/components/api-section.svelte +58 -50
  2. package/dist/components/api-section.svelte.d.ts +24 -11
  3. package/dist/components/content-rect.svelte +6 -0
  4. package/dist/components/content-rect.svelte.d.ts +1 -0
  5. package/dist/components/error.svelte +9 -0
  6. package/dist/components/error.svelte.d.ts +6 -0
  7. package/dist/components/index.d.ts +4 -2
  8. package/dist/components/index.js +4 -2
  9. package/dist/components/is-moving.svelte +26 -34
  10. package/dist/components/is-moving.svelte.d.ts +4 -5
  11. package/dist/components/progress.svelte +1 -0
  12. package/dist/components/queries.svelte +7 -0
  13. package/dist/components/queries.svelte.d.ts +4 -0
  14. package/dist/components/query.svelte +7 -0
  15. package/dist/components/query.svelte.d.ts +4 -0
  16. package/dist/components/section/index.d.ts +2 -0
  17. package/dist/components/section/index.js +2 -0
  18. package/dist/components/section/section-error-reporter.d.ts +8 -0
  19. package/dist/components/section/section-error-reporter.js +7 -0
  20. package/dist/components/section/section-error.svelte +36 -0
  21. package/dist/components/section/section-error.svelte.d.ts +9 -0
  22. package/dist/components/section/section-errors.svelte +132 -5
  23. package/dist/components/section/section.svelte +7 -1
  24. package/dist/components/section/section.svelte.d.ts +3 -0
  25. package/dist/components/section/use-section-errors.svelte.d.ts +1 -0
  26. package/dist/components/section/use-section-errors.svelte.js +11 -1
  27. package/dist/components/stop-button.svelte +1 -5
  28. package/dist/components/stop-button.svelte.d.ts +0 -1
  29. package/dist/components/stop.svelte +2 -2
  30. package/dist/components/widgets/arm/arm.svelte +24 -32
  31. package/dist/components/widgets/arm/get-joint-positions-widget.svelte +9 -8
  32. package/dist/components/widgets/arm/manual-mode-widget.svelte +13 -4
  33. package/dist/components/widgets/arm/manual-mode.svelte +1 -5
  34. package/dist/components/widgets/arm/manual-mode.svelte.d.ts +0 -1
  35. package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +10 -4
  36. package/dist/components/widgets/arm/move-to-joint-positions.svelte +1 -11
  37. package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +0 -1
  38. package/dist/components/widgets/arm/move-to-position-control.svelte +22 -18
  39. package/dist/components/widgets/arm/move-to-position.svelte +0 -4
  40. package/dist/components/widgets/arm/move-to-position.svelte.d.ts +0 -1
  41. package/dist/components/widgets/arm/quick-move-widget.svelte +10 -4
  42. package/dist/components/widgets/arm/quick-move.svelte +1 -4
  43. package/dist/components/widgets/arm/quick-move.svelte.d.ts +0 -1
  44. package/dist/components/widgets/audio-input/audio-input.svelte +76 -74
  45. package/dist/components/widgets/audio-input/get-properties-widget.svelte +15 -15
  46. package/dist/components/widgets/audio-output/audio-output.svelte +83 -81
  47. package/dist/components/widgets/audio-output/get-properties-widget.svelte +15 -15
  48. package/dist/components/widgets/base/base.svelte +70 -37
  49. package/dist/components/widgets/base/move-straight-widget.svelte +16 -4
  50. package/dist/components/widgets/base/quick-move-widget.svelte +25 -9
  51. package/dist/components/widgets/base/set-power-widget.svelte +20 -8
  52. package/dist/components/widgets/base/set-velocity-widget.svelte +20 -8
  53. package/dist/components/widgets/base/spin-widget.svelte +20 -8
  54. package/dist/components/widgets/board/read-write-pins.svelte +2 -2
  55. package/dist/components/widgets/button/push.svelte +2 -2
  56. package/dist/components/widgets/camera/camera.svelte +15 -23
  57. package/dist/components/widgets/camera/live-or-polling-video.svelte +12 -9
  58. package/dist/components/widgets/custom-control/__tests__/__fixtures__/with-sibling.svelte +10 -0
  59. package/dist/components/widgets/custom-control/control-frame.svelte +60 -0
  60. package/dist/components/widgets/custom-control/control-frame.svelte.d.ts +10 -0
  61. package/dist/components/widgets/custom-control/create-control-host.svelte.d.ts +19 -0
  62. package/dist/components/widgets/custom-control/create-control-host.svelte.js +28 -0
  63. package/dist/components/widgets/custom-control/custom-control.d.ts +35 -0
  64. package/dist/components/widgets/custom-control/custom-control.js +85 -0
  65. package/dist/components/widgets/custom-control/custom-control.svelte +45 -0
  66. package/dist/components/widgets/custom-control/custom-control.svelte.d.ts +14 -0
  67. package/dist/components/widgets/discovery/discovery.svelte +10 -15
  68. package/dist/components/widgets/encoder/encoder.svelte +20 -18
  69. package/dist/components/widgets/encoder/get-position-widget.svelte +18 -15
  70. package/dist/components/widgets/gantry/gantry.svelte +50 -74
  71. package/dist/components/widgets/gantry/get-position-widget.svelte +14 -13
  72. package/dist/components/widgets/gantry/home.svelte +21 -10
  73. package/dist/components/widgets/gantry/move-to-position-widget.svelte +2 -1
  74. package/dist/components/widgets/gantry/move-to-position.svelte +1 -4
  75. package/dist/components/widgets/gantry/move-to-position.svelte.d.ts +0 -1
  76. package/dist/components/widgets/gantry/quick-move-widget.svelte +2 -1
  77. package/dist/components/widgets/gantry/quick-move.svelte +1 -5
  78. package/dist/components/widgets/gantry/quick-move.svelte.d.ts +0 -1
  79. package/dist/components/widgets/generic/generic.svelte +7 -5
  80. package/dist/components/widgets/gripper/grab-widget.svelte +26 -0
  81. package/dist/components/widgets/gripper/grab-widget.svelte.d.ts +7 -0
  82. package/dist/components/widgets/gripper/grab.svelte +3 -19
  83. package/dist/components/widgets/gripper/grab.svelte.d.ts +1 -2
  84. package/dist/components/widgets/gripper/gripper.svelte +10 -12
  85. package/dist/components/widgets/gripper/is-holding-something.svelte +18 -19
  86. package/dist/components/widgets/gripper/open-widget.svelte +26 -0
  87. package/dist/components/widgets/gripper/open-widget.svelte.d.ts +7 -0
  88. package/dist/components/widgets/gripper/open.svelte +3 -19
  89. package/dist/components/widgets/gripper/open.svelte.d.ts +1 -2
  90. package/dist/components/widgets/input-controller/input-controller.svelte +7 -14
  91. package/dist/components/widgets/input-controller/webgamepad.svelte +2 -2
  92. package/dist/components/widgets/motion/motion.svelte +27 -35
  93. package/dist/components/widgets/motion/move-widget.svelte +32 -12
  94. package/dist/components/widgets/motion/move-widget.svelte.d.ts +6 -0
  95. package/dist/components/widgets/motion/move.svelte +1 -13
  96. package/dist/components/widgets/motion/move.svelte.d.ts +0 -1
  97. package/dist/components/widgets/motor/go-for-view.svelte +16 -8
  98. package/dist/components/widgets/motor/go-to-view.svelte +12 -4
  99. package/dist/components/widgets/motor/motor.svelte +88 -54
  100. package/dist/components/widgets/motor/quick-move-widget.svelte +16 -8
  101. package/dist/components/widgets/motor/set-power-widget.svelte +12 -4
  102. package/dist/components/widgets/motor/set-rpm-widget.svelte +12 -4
  103. package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +7 -10
  104. package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +7 -10
  105. package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +7 -10
  106. package/dist/components/widgets/movement-sensor/get-position-widget.svelte +7 -10
  107. package/dist/components/widgets/movement-sensor/movement-sensor.svelte +55 -56
  108. package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +2 -1
  109. package/dist/components/widgets/power-sensor/get-current-widget.svelte +7 -10
  110. package/dist/components/widgets/power-sensor/get-power-widget.svelte +7 -10
  111. package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +7 -10
  112. package/dist/components/widgets/power-sensor/power-sensor.svelte +26 -38
  113. package/dist/components/widgets/sensor/sensor.svelte +5 -10
  114. package/dist/components/widgets/servo/move-widget.svelte +2 -1
  115. package/dist/components/widgets/servo/move.svelte +1 -4
  116. package/dist/components/widgets/servo/move.svelte.d.ts +0 -1
  117. package/dist/components/widgets/servo/quick-move-widget.svelte +2 -1
  118. package/dist/components/widgets/servo/quick-move.svelte +1 -5
  119. package/dist/components/widgets/servo/quick-move.svelte.d.ts +0 -1
  120. package/dist/components/widgets/servo/servo.svelte +44 -33
  121. package/dist/components/widgets/slam/get-position-widget.svelte +7 -10
  122. package/dist/components/widgets/slam/move-on-map.svelte +6 -5
  123. package/dist/components/widgets/slam/move-on-map.svelte.d.ts +2 -1
  124. package/dist/components/widgets/slam/slam.svelte +64 -79
  125. package/dist/components/widgets/switch/position.svelte +2 -2
  126. package/package.json +3 -2
  127. package/dist/components/mutation-section.svelte +0 -75
  128. package/dist/components/mutation-section.svelte.d.ts +0 -18
  129. package/dist/components/mutation-view.svelte +0 -29
  130. package/dist/components/mutation-view.svelte.d.ts +0 -10
  131. package/dist/components/section-title.svelte +0 -65
  132. package/dist/components/section-title.svelte.d.ts +0 -15
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
- import ErrorDisplay from '../error.svelte'
2
+ import { Icon, Tooltip } from '@viamrobotics/prime-core'
3
+
3
4
  import { errorKey } from './error-key'
4
5
 
5
6
  interface Props {
@@ -7,12 +8,138 @@
7
8
  }
8
9
 
9
10
  const { errors }: Props = $props()
11
+
12
+ const COPIED_MS = 750
13
+
14
+ const count = $derived(errors.length)
15
+ const hasErrors = $derived(count > 0)
16
+ const summary = $derived(hasErrors ? `${count} ${count === 1 ? 'error' : 'errors'}` : 'No errors')
17
+ const text = $derived(errors.map((error) => `${error.name}: ${error.message}`).join('\n'))
18
+
19
+ let copied = $state(false)
20
+ let copiedTimer: ReturnType<typeof setTimeout> | undefined
21
+
22
+ const label = $derived.by(() => {
23
+ if (copied) return `Copied ${summary}`
24
+ return hasErrors ? `${summary}, copy to clipboard` : summary
25
+ })
26
+
27
+ const iconName = $derived.by(() => {
28
+ if (copied) return 'check'
29
+ return hasErrors ? 'alert-circle' : 'alert-circle-outline'
30
+ })
31
+
32
+ // The cue replays only when the held set changes to a non-empty one, so a steady failing poll
33
+ // fires once and each new distinct error or failed attempt fires again.
34
+ let lastKeys = ''
35
+ let arrivals = 0
36
+ const arrival = $derived.by(() => {
37
+ const keys = errors.map((error) => errorKey(error)).join('\0\0')
38
+ if (keys !== lastKeys) {
39
+ lastKeys = keys
40
+ if (keys !== '') arrivals += 1
41
+ }
42
+
43
+ return arrivals
44
+ })
45
+
46
+ const copy = async () => {
47
+ if (!hasErrors) return
48
+ try {
49
+ await globalThis.navigator.clipboard.writeText(text)
50
+ copied = true
51
+ clearTimeout(copiedTimer)
52
+ copiedTimer = setTimeout(() => {
53
+ copied = false
54
+ }, COPIED_MS)
55
+ } catch (error) {
56
+ console.error('Failed to copy errors to clipboard', error)
57
+ }
58
+ }
59
+
60
+ $effect(() => () => clearTimeout(copiedTimer))
10
61
  </script>
11
62
 
12
- {#if errors.length > 0}
13
- <div class="flex w-full flex-col gap-1">
63
+ <Tooltip let:tooltipID>
64
+ <button
65
+ type="button"
66
+ aria-label={label}
67
+ aria-describedby={tooltipID}
68
+ onclick={copy}
69
+ class={[
70
+ // The pseudo-element pads the hit area to 24px (WCAG 2.5.8) without growing the heading row.
71
+ 'relative inline-flex items-center gap-0.5 p-0.5 after:absolute after:-inset-0.5',
72
+ {
73
+ 'text-gray-6': !hasErrors && !copied,
74
+ 'text-danger-dark hover:bg-medium': hasErrors && !copied,
75
+ 'text-success-dark': copied,
76
+ },
77
+ ]}
78
+ >
79
+ {#key arrival}
80
+ <span class={['inline-flex rounded-full', arrival > 0 && 'arrival']}>
81
+ <Icon name={iconName} />
82
+ </span>
83
+ {/key}
84
+ {#if hasErrors}
85
+ <span class="font-roboto-mono text-xs leading-none">{count}</span>
86
+ {/if}
87
+ </button>
88
+ <div
89
+ slot="description"
90
+ class="flex flex-col gap-1"
91
+ >
92
+ <div class="text-gray-5 flex justify-between gap-3">
93
+ <span>{summary}</span>
94
+ {#if hasErrors}
95
+ <span>{copied ? 'Copied' : 'Click to copy'}</span>
96
+ {/if}
97
+ </div>
14
98
  {#each errors as error (errorKey(error))}
15
- <ErrorDisplay lastError={error} />
99
+ <p class="font-roboto-mono">{error.name}: {error.message}</p>
16
100
  {/each}
17
101
  </div>
18
- {/if}
102
+ </Tooltip>
103
+
104
+ <style>
105
+ @keyframes arrival {
106
+ 0% {
107
+ transform: scale(1) rotate(0deg);
108
+ background-color: transparent;
109
+ }
110
+ 15% {
111
+ transform: scale(1.35) rotate(-14deg);
112
+ background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
113
+ }
114
+ 30% {
115
+ transform: scale(1.35) rotate(14deg);
116
+ background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
117
+ }
118
+ 45% {
119
+ transform: scale(1.35) rotate(-14deg);
120
+ background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
121
+ }
122
+ 60% {
123
+ transform: scale(1.35) rotate(14deg);
124
+ background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
125
+ }
126
+ 80% {
127
+ transform: scale(1.35) rotate(0deg);
128
+ background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
129
+ }
130
+ 100% {
131
+ transform: scale(1) rotate(0deg);
132
+ background-color: transparent;
133
+ }
134
+ }
135
+
136
+ .arrival {
137
+ animation: arrival 600ms cubic-bezier(0.165, 0.84, 0.44, 1) 1;
138
+ }
139
+
140
+ @media (prefers-reduced-motion: reduce) {
141
+ .arrival {
142
+ animation: none;
143
+ }
144
+ }
145
+ </style>
@@ -2,11 +2,17 @@
2
2
  import type { Snippet } from 'svelte'
3
3
  import type { HTMLAttributes } from 'svelte/elements'
4
4
 
5
+ import { provideSectionErrorReporter, type SectionErrorReporter } from './section-error-reporter'
6
+
5
7
  interface Props extends HTMLAttributes<HTMLElement> {
6
8
  children: Snippet
9
+ /** Collects errors that `Section.Error` parts inside the section report, e.g. `useSectionErrors`' result. */
10
+ errorReporter?: SectionErrorReporter
7
11
  }
8
12
 
9
- const { children, class: className, ...rest }: Props = $props()
13
+ const { children, errorReporter, class: className, ...rest }: Props = $props()
14
+
15
+ provideSectionErrorReporter(() => errorReporter)
10
16
  </script>
11
17
 
12
18
  <section
@@ -1,7 +1,10 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type SectionErrorReporter } from './section-error-reporter';
3
4
  interface Props extends HTMLAttributes<HTMLElement> {
4
5
  children: Snippet;
6
+ /** Collects errors that `Section.Error` parts inside the section report, e.g. `useSectionErrors`' result. */
7
+ errorReporter?: SectionErrorReporter;
5
8
  }
6
9
  declare const Section: import("svelte").Component<Props, {}, "">;
7
10
  type Section = ReturnType<typeof Section>;
@@ -15,4 +15,5 @@ export declare const dedupeErrors: (errors: (Error | null)[]) => Error[];
15
15
  export declare const useSectionErrors: (getSources: () => SectionSources) => {
16
16
  readonly errors: Error[];
17
17
  readonly isLoading: boolean;
18
+ report(getError: () => Error | null): () => void;
18
19
  };
@@ -1,3 +1,4 @@
1
+ import { SvelteSet } from 'svelte/reactivity';
1
2
  import { errorKey } from './error-key';
2
3
  export const dedupeErrors = (errors) => {
3
4
  const present = errors.filter((error) => error !== null);
@@ -23,9 +24,12 @@ export const useSectionErrors = (getSources) => {
23
24
  }
24
25
  return held;
25
26
  });
27
+ // Errors that `Section.Error` parts inside the section report, e.g. an inner form's mutation.
28
+ const reported = new SvelteSet();
26
29
  const errors = $derived.by(() => {
27
30
  const mutationErrors = (getSources().mutations ?? []).map((mutation) => mutation.error);
28
- return dedupeErrors([...queryErrors, ...mutationErrors]);
31
+ const reportedErrors = [...reported].map((getError) => getError());
32
+ return dedupeErrors([...queryErrors, ...mutationErrors, ...reportedErrors]);
29
33
  });
30
34
  const isLoading = $derived(errors.length === 0 && (getSources().queries ?? []).some((query) => query.isLoading));
31
35
  return {
@@ -35,5 +39,11 @@ export const useSectionErrors = (getSources) => {
35
39
  get isLoading() {
36
40
  return isLoading;
37
41
  },
42
+ report(getError) {
43
+ reported.add(getError);
44
+ return () => {
45
+ reported.delete(getError);
46
+ };
47
+ },
38
48
  };
39
49
  };
@@ -1,14 +1,11 @@
1
1
  <script lang="ts">
2
2
  import { Button } from '@viamrobotics/prime-core'
3
3
 
4
- import ErrorDisplay from './error.svelte'
5
-
6
4
  interface Props {
7
5
  onStop: () => void
8
- error: Error | null
9
6
  }
10
7
 
11
- const { error, onStop }: Props = $props()
8
+ const { onStop }: Props = $props()
12
9
  </script>
13
10
 
14
11
  <Button
@@ -18,4 +15,3 @@
18
15
  >
19
16
  Stop
20
17
  </Button>
21
- <ErrorDisplay lastError={error} />
@@ -1,6 +1,5 @@
1
1
  interface Props {
2
2
  onStop: () => void;
3
- error: Error | null;
4
3
  }
5
4
  declare const StopButton: import("svelte").Component<Props, {}, "">;
6
5
  type StopButton = ReturnType<typeof StopButton>;
@@ -53,11 +53,11 @@
53
53
 
54
54
  <ApiSection
55
55
  class="grow flex-col gap-4"
56
- title="Stop"
56
+ method="Stop"
57
57
  {api}
58
+ mutations={[stopMutation]}
58
59
  >
59
60
  <StopButton
60
- error={stopMutation.error}
61
61
  onStop={() => {
62
62
  stopMutation.mutate([])
63
63
  }}
@@ -9,7 +9,7 @@
9
9
  import ApiSection from '../../api-section.svelte'
10
10
  import ConnectionStatus from '../../connection-status.svelte'
11
11
  import IsMoving from '../../is-moving.svelte'
12
- import Query from '../../query.svelte'
12
+ import { Section } from '../../section'
13
13
  import StopButton from '../../stop-button.svelte'
14
14
  import { ResourceTriplets } from '../../../resource-triplet'
15
15
 
@@ -72,43 +72,35 @@
72
72
  >
73
73
  <ApiSection
74
74
  class="grow flex-col gap-4"
75
- title="GetJointPositions"
75
+ method="GetJointPositions"
76
76
  api={ResourceTriplets.Arm}
77
- bottomText="Updates automatically"
77
+ queries={[jointPositionsQuery]}
78
78
  >
79
- <Query query={jointPositionsQuery}>
80
- {#if jointPositionsQuery.data}
81
- <GetJointPositions positions={jointPositionsQuery.data.values} />
82
- {/if}
83
- </Query>
79
+ {#if jointPositionsQuery.data}
80
+ <GetJointPositions positions={jointPositionsQuery.data.values} />
81
+ {/if}
82
+ <Section.Text class="mt-auto">Updates automatically</Section.Text>
84
83
  </ApiSection>
85
84
  <ApiSection
86
85
  class="grow flex-col gap-4"
87
- title="MoveToJointPositions"
86
+ method="MoveToJointPositions"
88
87
  api={ResourceTriplets.Arm}
88
+ queries={[jointPositionsQuery, kinematicsQuery]}
89
+ mutations={[moveToJointPosMutation]}
89
90
  >
90
- <Query query={jointPositionsQuery}>
91
- {#if jointPositionsQuery.data}
92
- <MoveToJointPositions
93
- positions={jointPositionsQuery.data.values}
94
- {moveToJointPositions}
95
- lastError={moveToJointPosMutation.error}
96
- {jointLimitsDegrees}
97
- isMoving={motionTracking.isTracking}
98
- />
99
- {/if}
100
- </Query>
101
- </ApiSection>
102
- <ApiSection
103
- class="grow flex-col gap-4"
104
- title="MoveToPosition"
105
- api={ResourceTriplets.Arm}
106
- >
107
- <MoveToPositionControl
108
- {partID}
109
- {resourceName}
110
- />
91
+ {#if jointPositionsQuery.data}
92
+ <MoveToJointPositions
93
+ positions={jointPositionsQuery.data.values}
94
+ {moveToJointPositions}
95
+ {jointLimitsDegrees}
96
+ isMoving={motionTracking.isTracking}
97
+ />
98
+ {/if}
111
99
  </ApiSection>
100
+ <MoveToPositionControl
101
+ {partID}
102
+ {resourceName}
103
+ />
112
104
  </div>
113
105
 
114
106
  <!-- Control actions sidebar -->
@@ -117,11 +109,11 @@
117
109
  >
118
110
  <ApiSection
119
111
  class="grow flex-col gap-4"
120
- title="Stop"
112
+ method="Stop"
121
113
  api={ResourceTriplets.Arm}
114
+ mutations={[stopMutation]}
122
115
  >
123
116
  <StopButton
124
- error={stopMutation.error}
125
117
  onStop={() => {
126
118
  stopMutation.mutate([], {})
127
119
  }}
@@ -3,7 +3,8 @@
3
3
  import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
4
4
 
5
5
  import ApiSection from '../../api-section.svelte'
6
- import Query from '../../query.svelte'
6
+ import { Section } from '../../section'
7
+ import { ResourceTriplets } from '../../../resource-triplet'
7
8
 
8
9
  import GetJointPositions from './get-joint-positions.svelte'
9
10
 
@@ -24,13 +25,13 @@
24
25
  </script>
25
26
 
26
27
  <ApiSection
27
- title="GetJointPositions"
28
- bottomText="Updates automatically"
28
+ method="GetJointPositions"
29
+ api={ResourceTriplets.Arm}
30
+ queries={[query]}
29
31
  class="grow flex-col gap-4"
30
32
  >
31
- <Query {query}>
32
- {#if query.data}
33
- <GetJointPositions positions={query.data.values} />
34
- {/if}
35
- </Query>
33
+ {#if query.data}
34
+ <GetJointPositions positions={query.data.values} />
35
+ {/if}
36
+ <Section.Text class="mt-auto">Updates automatically</Section.Text>
36
37
  </ApiSection>
@@ -7,6 +7,8 @@
7
7
  } from '@viamrobotics/svelte-sdk'
8
8
 
9
9
  import ApiSection from '../../api-section.svelte'
10
+ import { Section } from '../../section'
11
+ import { useSectionErrors } from '../../section/use-section-errors.svelte'
10
12
  import { ResourceTriplets } from '../../../resource-triplet'
11
13
 
12
14
  import ManualMode from './manual-mode.svelte'
@@ -36,6 +38,12 @@
36
38
 
37
39
  const setManualModeMutation = createResourceMutation(client, 'setManualMode')
38
40
 
41
+ // The band renders no ApiSection, so it reads the same sources through the errors indicator.
42
+ const bandErrors = useSectionErrors(() => ({
43
+ queries: [propertiesQuery, manualModeQuery],
44
+ mutations: [setManualModeMutation],
45
+ }))
46
+
39
47
  const setManualMode = (manualMode: boolean, enabledFor: number) => {
40
48
  setManualModeMutation.mutate([manualMode, enabledFor], {})
41
49
  }
@@ -45,27 +53,28 @@
45
53
  {#if band}
46
54
  <section
47
55
  aria-label="SetManualMode"
48
- class="border-b px-4 py-3"
56
+ class="flex items-start justify-between gap-2 border-b px-4 py-3"
49
57
  >
50
58
  <ManualMode
51
59
  title="ManualMode"
52
60
  isManualMode={manualModeQuery.data ?? false}
53
61
  isPending={setManualModeMutation.isPending}
54
62
  {setManualMode}
55
- lastError={setManualModeMutation.error}
56
63
  />
64
+ <Section.Errors errors={bandErrors.errors} />
57
65
  </section>
58
66
  {:else}
59
67
  <ApiSection
60
- title="SetManualMode"
68
+ method="SetManualMode"
61
69
  api={ResourceTriplets.Arm}
70
+ queries={[propertiesQuery, manualModeQuery]}
71
+ mutations={[setManualModeMutation]}
62
72
  class="grow flex-col gap-4"
63
73
  >
64
74
  <ManualMode
65
75
  isManualMode={manualModeQuery.data ?? false}
66
76
  isPending={setManualModeMutation.isPending}
67
77
  {setManualMode}
68
- lastError={setManualModeMutation.error}
69
78
  />
70
79
  </ApiSection>
71
80
  {/if}
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { Button, Icon, Label, NumericInput, Tooltip } from '@viamrobotics/prime-core'
3
3
 
4
- import ErrorDisplay from '../../error.svelte'
5
4
  import StatusPill from '../../status-pill.svelte'
6
5
  import { numberValueFromEvent } from '../../../event-handlers'
7
6
 
@@ -12,11 +11,10 @@
12
11
  title?: string
13
12
  isManualMode: boolean
14
13
  isPending: boolean
15
- lastError: Error | null
16
14
  setManualMode: (manualMode: boolean, enabledFor: number) => void
17
15
  }
18
16
 
19
- const { title, isManualMode, isPending, setManualMode, lastError }: Props = $props()
17
+ const { title, isManualMode, isPending, setManualMode }: Props = $props()
20
18
 
21
19
  let enabledFor = $state(90)
22
20
  let enableAfter = $state(5)
@@ -147,6 +145,4 @@
147
145
  Manual mode puts the arm into gravity compensation or servo release mode so the arm can be moved
148
146
  by hand.
149
147
  </p>
150
-
151
- <ErrorDisplay {lastError} />
152
148
  </div>
@@ -3,7 +3,6 @@ interface Props {
3
3
  title?: string;
4
4
  isManualMode: boolean;
5
5
  isPending: boolean;
6
- lastError: Error | null;
7
6
  setManualMode: (manualMode: boolean, enabledFor: number) => void;
8
7
  }
9
8
  declare const ManualMode: import("svelte").Component<Props, {}, "">;
@@ -6,7 +6,8 @@
6
6
  createResourceQuery,
7
7
  } from '@viamrobotics/svelte-sdk'
8
8
 
9
- import Query from '../../query.svelte'
9
+ import ApiSection from '../../api-section.svelte'
10
+ import { ResourceTriplets } from '../../../resource-triplet'
10
11
 
11
12
  import { getJointPositionLimits, type KinematicsJSON } from './joint-position-limits'
12
13
  import MoveToJointPositions from './move-to-joint-positions.svelte'
@@ -49,14 +50,19 @@
49
50
  )
50
51
  </script>
51
52
 
52
- <Query query={jointPositionsQuery}>
53
+ <ApiSection
54
+ method="MoveToJointPositions"
55
+ api={ResourceTriplets.Arm}
56
+ queries={[jointPositionsQuery, kinematicsQuery]}
57
+ mutations={[moveToJointPosMutation]}
58
+ class="grow flex-col gap-4"
59
+ >
53
60
  {#if jointPositionsQuery.data}
54
61
  <MoveToJointPositions
55
62
  positions={jointPositionsQuery.data.values}
56
63
  {moveToJointPositions}
57
- lastError={moveToJointPosMutation.error}
58
64
  {jointLimitsDegrees}
59
65
  isMoving={motionTracking.isTracking}
60
66
  />
61
67
  {/if}
62
- </Query>
68
+ </ApiSection>
@@ -3,7 +3,6 @@
3
3
 
4
4
  import AngleUnitToggle from '../../angle-unit-toggle.svelte'
5
5
  import CopyButton from '../../copy-button.svelte'
6
- import ErrorDisplay from '../../error.svelte'
7
6
  import PasteButton from '../../paste-button.svelte'
8
7
  import { degreesToRadians, formatNumeric, radiansToDegrees } from '../../../format'
9
8
 
@@ -23,18 +22,11 @@
23
22
  positions: number[]
24
23
  /** Sends the move. Rejects when it fails. */
25
24
  moveToJointPositions: (jointPositions: number[]) => Promise<void>
26
- lastError: Error | null
27
25
  jointLimitsDegrees: JointLimit[]
28
26
  isMoving?: boolean
29
27
  }
30
28
 
31
- const {
32
- positions,
33
- moveToJointPositions,
34
- lastError,
35
- jointLimitsDegrees,
36
- isMoving = false,
37
- }: Props = $props()
29
+ const { positions, moveToJointPositions, jointLimitsDegrees, isMoving = false }: Props = $props()
38
30
 
39
31
  const targets = useEditedTargets<number>(
40
32
  (index) => positions[index] ?? 0,
@@ -126,6 +118,4 @@
126
118
  {isMoving}
127
119
  />
128
120
  {/if}
129
-
130
- <ErrorDisplay {lastError} />
131
121
  </div>
@@ -3,7 +3,6 @@ interface Props {
3
3
  positions: number[];
4
4
  /** Sends the move. Rejects when it fails. */
5
5
  moveToJointPositions: (jointPositions: number[]) => Promise<void>;
6
- lastError: Error | null;
7
6
  jointLimitsDegrees: JointLimit[];
8
7
  isMoving?: boolean;
9
8
  }
@@ -10,7 +10,8 @@
10
10
  useRobotClient,
11
11
  } from '@viamrobotics/svelte-sdk'
12
12
 
13
- import Queries from '../../queries.svelte'
13
+ import ApiSection from '../../api-section.svelte'
14
+ import { ResourceTriplets } from '../../../resource-triplet'
14
15
 
15
16
  import {
16
17
  canPlanMotion,
@@ -78,7 +79,7 @@
78
79
 
79
80
  const moveMutation = createResourceMutation(motionClient, 'move')
80
81
  const moveToPosMutation = createResourceMutation(armClient, 'moveToPosition')
81
- const lastError = $derived(mode === 'motion' ? moveMutation.error : moveToPosMutation.error)
82
+ const activeMutation = $derived(mode === 'motion' ? moveMutation : moveToPosMutation)
82
83
 
83
84
  const motionTracking = useArmMotionTracking(armClient, {
84
85
  isMovePending: () => moveMutation.isPending || moveToPosMutation.isPending,
@@ -129,7 +130,13 @@
129
130
  {/if}
130
131
  {/snippet}
131
132
 
132
- <div class="flex flex-col gap-4">
133
+ <ApiSection
134
+ method="MoveToPosition"
135
+ api={ResourceTriplets.Arm}
136
+ queries={[frameSystemQuery, activeQuery]}
137
+ mutations={[activeMutation]}
138
+ class="grow flex-col gap-4"
139
+ >
133
140
  {#if motionAvailable}
134
141
  <Label position="top">
135
142
  <span class="flex items-center gap-1 text-xs">
@@ -184,18 +191,15 @@
184
191
  {/snippet}
185
192
  </Banner>
186
193
  {/if}
187
- <Queries queries={[frameSystemQuery, activeQuery]}>
188
- <!-- Re-seed the editor on a mode change: the two modes report the pose in different frames. -->
189
- {#key mode}
190
- {#if endPosition}
191
- <MoveToPosition
192
- {endPosition}
193
- {moveToPosition}
194
- {lastError}
195
- isMoving={motionTracking.isTracking}
196
- {description}
197
- />
198
- {/if}
199
- {/key}
200
- </Queries>
201
- </div>
194
+ <!-- Re-seed the editor on a mode change: the two modes report the pose in different frames. -->
195
+ {#key mode}
196
+ {#if endPosition}
197
+ <MoveToPosition
198
+ {endPosition}
199
+ {moveToPosition}
200
+ isMoving={motionTracking.isTracking}
201
+ {description}
202
+ />
203
+ {/if}
204
+ {/key}
205
+ </ApiSection>
@@ -25,7 +25,6 @@
25
25
 
26
26
  import { Button, Icon, Tooltip } from '@viamrobotics/prime-core'
27
27
 
28
- import ErrorDisplay from '../../error.svelte'
29
28
  import PoseEditor from '../../pose-editor.svelte'
30
29
  import StatusPill from '../../status-pill.svelte'
31
30
 
@@ -34,7 +33,6 @@
34
33
  interface Props {
35
34
  endPosition: Pose
36
35
  moveToPosition: (position: Pose) => void
37
- lastError: Error | null
38
36
  isMoving?: boolean
39
37
  description?: Snippet
40
38
  }
@@ -42,7 +40,6 @@
42
40
  const {
43
41
  endPosition,
44
42
  moveToPosition,
45
- lastError,
46
43
  isMoving = false,
47
44
  description: customDescription,
48
45
  }: Props = $props()
@@ -142,5 +139,4 @@
142
139
  {/if}
143
140
  </span>
144
141
  </div>
145
- <ErrorDisplay {lastError} />
146
142
  </div>
@@ -3,7 +3,6 @@ import type { Snippet } from 'svelte';
3
3
  interface Props {
4
4
  endPosition: Pose;
5
5
  moveToPosition: (position: Pose) => void;
6
- lastError: Error | null;
7
6
  isMoving?: boolean;
8
7
  description?: Snippet;
9
8
  }