@gemies/sdk 6.3.0 → 6.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 6.3.1
4
+
5
+ - **A turn's attachments keep the order they were sent in** (`TurnAttachments`): a document sent
6
+ between two photos is drawn between them. Pictures next to each other still share a row.
7
+ - **No voice call in a group**: `GemieChatContent` offers none when `group` is set. A call has one
8
+ gemie and a group's turns are its members'; the API refuses one there too.
9
+
3
10
  ## 6.3.0
4
11
 
5
12
  - **A turn's attachments are drawn as media** (`TurnAttachments`, used by every user turn in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
4
4
  "description": "The Gemies SDK: the conversation runtime, chat UI, voice calls and dictation for Oxy apps that talk to a gemie",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -507,10 +507,11 @@ function GemieConversationView({
507
507
  },
508
508
  [composer],
509
509
  );
510
- // Without a call handed down (a text-only entry), the chat is text-only whatever `voice` says.
510
+ // Without a call handed down (a text-only entry), the chat is text-only whatever `voice` says. A
511
+ // group is too: a call has one gemie, and a group's turns are its members' (the server refuses it).
511
512
  const VoiceCall = useContext(VoiceCallContext);
512
513
  const voice = useChatVoice({
513
- options: VoiceCall === null ? false : voiceOptions,
514
+ options: VoiceCall === null || group !== undefined ? false : voiceOptions,
514
515
  conversationId,
515
516
  agentId,
516
517
  isFocused,
@@ -176,26 +176,42 @@ export function TurnAttachments({
176
176
  tone?: Tone;
177
177
  onColor?: string;
178
178
  }) {
179
- const items = getAttachmentsFromContent(content);
180
- if (items.length === 0) return null;
181
- const inline = items.filter((item) => item.type === 'inline-image');
182
- const files = items.filter((item) => item.type === 'file');
179
+ const runs = attachmentRuns(getAttachmentsFromContent(content));
180
+ if (runs.length === 0) return null;
183
181
  return (
184
182
  <View className="gap-2">
185
- {inline.length > 0 ? (
186
- <View className="flex-row flex-wrap gap-2">
187
- {inline.map((item) => (
188
- <Attachment key={item.url} item={item} tone={tone} onColor={onColor} />
189
- ))}
190
- </View>
191
- ) : null}
192
- {files.map((item) => (
193
- <Attachment key={item.fileId} item={item} tone={tone} onColor={onColor} />
194
- ))}
183
+ {runs.map((run) =>
184
+ Array.isArray(run) ? (
185
+ <View key={`images:${run[0]?.url}`} className="flex-row flex-wrap gap-2">
186
+ {run.map((item) => (
187
+ <Attachment key={item.url} item={item} tone={tone} onColor={onColor} />
188
+ ))}
189
+ </View>
190
+ ) : (
191
+ <Attachment key={run.fileId} item={run} tone={tone} onColor={onColor} />
192
+ ),
193
+ )}
195
194
  </View>
196
195
  );
197
196
  }
198
197
 
198
+ type InlineImage = Extract<TurnAttachment, { type: 'inline-image' }>;
199
+
200
+ /**
201
+ * The attachments in the order they were sent, the pictures next to each other drawn as one row.
202
+ * Drawing every picture first put a document sent between two photos after both of them.
203
+ */
204
+ function attachmentRuns(items: readonly TurnAttachment[]): Array<InlineImage[] | FileAttachment> {
205
+ const runs: Array<InlineImage[] | FileAttachment> = [];
206
+ for (const item of items) {
207
+ const last = runs.at(-1);
208
+ if (item.type === 'file') runs.push(item);
209
+ else if (Array.isArray(last)) last.push(item);
210
+ else runs.push([item]);
211
+ }
212
+ return runs;
213
+ }
214
+
199
215
  /** Whether a turn has anything to draw as an attachment. */
200
216
  export function hasAttachments(content: MessageContent | null | undefined): boolean {
201
217
  return getAttachmentsFromContent(content).length > 0;