feat(slides): add a set_speaker_notes agent tool (#153)
The slides AI skill gains a set_speaker_notes tool that writes or clears a page's speaker notes through the existing slides:set-notes IPC (persisted into the .pptx notesSlide part, marks the deck dirty, refreshable via the annotations nonce). DeckAccess grows an optional setSpeakerNotes hook; the AiPanel wires it from a new onSetSpeakerNotes prop supplied by App, which flushes any pending notes edit before invoking the IPC. Split out from #129 per maintainer feedback — single-purpose, without the local-environment bits. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3057,6 +3057,17 @@ export function App() {
|
||||
setPath(p)
|
||||
setDirty(false)
|
||||
}}
|
||||
onSetSpeakerNotes={(i, text) =>
|
||||
flushNotes()
|
||||
.then(() => window.slidesApi.setNotes({ slideIndex: i, text }))
|
||||
.then((ok) => {
|
||||
if (ok) {
|
||||
setDirty(true)
|
||||
setAnnotationsNonce((n) => n + 1)
|
||||
}
|
||||
return ok
|
||||
})
|
||||
}
|
||||
currentFilePath={path}
|
||||
editQueue={editQueue}
|
||||
onQueueEditInstruction={(key, instruction) =>
|
||||
|
||||
@@ -294,6 +294,8 @@ interface AiPanelProps {
|
||||
onUndo?: () => void
|
||||
/** Callback to update the path after AI generation lands on disk (title bar sync) */
|
||||
onPathChange?: (path: string) => void
|
||||
/** Overwrite a page's speaker notes (persisted to the pptx, marks the deck dirty) */
|
||||
onSetSpeakerNotes?: (slideIndex: number, text: string) => Promise<boolean>
|
||||
/** Generation progress callback (for the canvas top progress bar) */
|
||||
onDeckProgress?: (event: DeckProgressEvent | null) => void
|
||||
/** Absolute path of the currently open file (for chat history persistence) */
|
||||
@@ -383,6 +385,7 @@ export function AiPanel({
|
||||
onExpand,
|
||||
onCollapse,
|
||||
onPathChange,
|
||||
onSetSpeakerNotes,
|
||||
onDeckProgress,
|
||||
currentFilePath,
|
||||
editQueue,
|
||||
@@ -497,6 +500,8 @@ export function AiPanel({
|
||||
applySlideRef.current = applySlide
|
||||
const applyDeckRef = useRef(applyDeck)
|
||||
applyDeckRef.current = applyDeck
|
||||
const onSetSpeakerNotesRef = useRef(onSetSpeakerNotes)
|
||||
onSetSpeakerNotesRef.current = onSetSpeakerNotes
|
||||
const onPathChangeRef = useRef(onPathChange)
|
||||
onPathChangeRef.current = onPathChange
|
||||
const onDeckProgressRef = useRef(onDeckProgress)
|
||||
@@ -908,6 +913,7 @@ export function AiPanel({
|
||||
getSelectedIds: () => (queueRunResolverRef.current ? [] : selectedRef.current),
|
||||
applySlide: (i, updated) => applySlideRef.current(i, updated),
|
||||
applyDeck: (all, goTo) => applyDeckRef.current(all, goTo),
|
||||
setSpeakerNotes: (i, text) => onSetSpeakerNotesRef.current?.(i, text) ?? Promise.resolve(false),
|
||||
landGeneratedPages: async (
|
||||
pageMarkers: string[],
|
||||
mode?: 'replace' | 'append' | 'insert_at',
|
||||
|
||||
@@ -101,6 +101,11 @@ export interface DeckAccess {
|
||||
): Promise<{ ok: boolean; error?: string; imageFailures?: { page: number; url: string }[] }>
|
||||
/** Survey: shows a card with options and waits for the user's choices, returning an answer summary. */
|
||||
askClarification?(questions: ClarifyQuestion[]): Promise<{ answers: string; cancelled?: boolean }>
|
||||
/**
|
||||
* Overwrite the speaker notes of a page (persisted into the pptx notesSlide part,
|
||||
* undoable, marks the document dirty). Empty text clears the notes.
|
||||
*/
|
||||
setSpeakerNotes?(slideIndex: number, text: string): Promise<boolean>
|
||||
/**
|
||||
* In-tool image search (embedded in the tool):
|
||||
* given English keywords, returns an array of real image URLs (at most N).
|
||||
@@ -285,6 +290,7 @@ Native tools (only for modifying/refining existing pages, not for generating fro
|
||||
- add_slide clones a layout into a new page (layout-preserving blank page); add_text_box lays out text; add_shape makes color blocks/accent bars (kind supports any OOXML preset geometry rect/roundRect/ellipse/star5…).
|
||||
- For data display use add_chart (native bar/line/pie charts); for structured comparisons use add_table (cells can pre-fill text; later edit_table_cell edits cells, edit_table_structure adds/removes rows/columns); for flows/cycles/hierarchies/lists use add_smartart.
|
||||
- set_slide_background sets a solid background (slideIndex=-1 for all pages); on dark backgrounds remember to lighten the text.
|
||||
- set_speaker_notes writes the page's speaker notes (演讲者备注/备注, shown in presenter view and saved into the .pptx); it does not touch canvas content. Use it when the user asks to add/update/clear notes for a page.
|
||||
- Refine page by page, element by element; 2–4 elements per page is enough — fewer beats crowded.
|
||||
- Keep replies short, say what you did; don't recite tool results back to the user.
|
||||
|
||||
@@ -1173,6 +1179,22 @@ const TOOLS: AgentToolDef[] = [
|
||||
required: ['ops'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'set_speaker_notes',
|
||||
description:
|
||||
"Overwrite the speaker notes (演讲者备注/备注) of a page. Notes are shown in presenter view and saved into the .pptx notesSlide part; they do not affect canvas content. text replaces the page's current notes entirely; pass text:\"\" to clear them. Call when the user asks to add/update/remove notes for a page.",
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
slideIndex: { type: 'integer', description: 'Page number (0-based)' },
|
||||
text: {
|
||||
type: 'string',
|
||||
description: 'Full speaker notes text; paragraphs separated by newlines. Empty string clears the notes.',
|
||||
},
|
||||
},
|
||||
required: ['slideIndex', 'text'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'delete_element',
|
||||
description: 'Delete one element from a page.',
|
||||
@@ -3382,6 +3404,22 @@ async function executeTool(
|
||||
}
|
||||
}
|
||||
|
||||
case 'set_speaker_notes': {
|
||||
const idx = Number(call.input.slideIndex)
|
||||
if (!slides[idx])
|
||||
return fail(t('aiFailSpeakerNotes'), `slideIndex out of range (0-${slides.length - 1})`)
|
||||
const text = String(call.input.text ?? '')
|
||||
const ok = await access.setSpeakerNotes?.(idx, text)
|
||||
if (!ok) return fail(t('aiFailSpeakerNotes'), 'Writing speaker notes failed')
|
||||
return {
|
||||
output: text
|
||||
? `Wrote speaker notes for page ${idx + 1} (${text.length} characters).`
|
||||
: `Cleared speaker notes for page ${idx + 1}.`,
|
||||
mutated: true,
|
||||
summary: t('aiSumSpeakerNotes', { n: idx + 1 }),
|
||||
}
|
||||
}
|
||||
|
||||
case 'delete_element': {
|
||||
const idx = Number(call.input.slideIndex)
|
||||
const sourceId = String(call.input.sourceId ?? '')
|
||||
|
||||
@@ -184,6 +184,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: '表格样式',
|
||||
aiFailChartEdit: '图表编辑',
|
||||
aiFailBackground: '设置背景',
|
||||
aiFailSpeakerNotes: '设置演讲者备注',
|
||||
aiFailDeleteElement: '删除元素',
|
||||
aiFailUngroup: '取消组合',
|
||||
aiSumUngroup: '第 {n} 页取消组合',
|
||||
@@ -233,6 +234,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: '第 {n} 页图表编辑',
|
||||
aiSumBackgroundAll: '设置全部页背景',
|
||||
aiSumBackground: '设置第 {n} 页背景',
|
||||
aiSumSpeakerNotes: '写入第 {n} 页演讲者备注',
|
||||
aiSumDeleteElement: '第 {n} 页删除元素',
|
||||
aiSumSaveTemplate: '保存风格模板"{name}"',
|
||||
aiSumTemplatesEmpty: '风格模板列表(空)',
|
||||
@@ -427,6 +429,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Table style',
|
||||
aiFailChartEdit: 'Edit chart',
|
||||
aiFailBackground: 'Set background',
|
||||
aiFailSpeakerNotes: 'Set speaker notes',
|
||||
aiFailDeleteElement: 'Delete element',
|
||||
aiFailUngroup: 'Ungroup',
|
||||
aiSumUngroup: 'Ungrouped element on slide {n}',
|
||||
@@ -476,6 +479,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Edited chart on slide {n}',
|
||||
aiSumBackgroundAll: 'Set background on all slides',
|
||||
aiSumBackground: 'Set background on slide {n}',
|
||||
aiSumSpeakerNotes: 'Wrote speaker notes on slide {n}',
|
||||
aiSumDeleteElement: 'Deleted element on slide {n}',
|
||||
aiSumSaveTemplate: 'Saved style template "{name}"',
|
||||
aiSumTemplatesEmpty: 'Style templates (empty)',
|
||||
@@ -669,6 +673,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: '表のスタイル',
|
||||
aiFailChartEdit: 'グラフの編集',
|
||||
aiFailBackground: '背景の設定',
|
||||
aiFailSpeakerNotes: '発表者ノートの設定',
|
||||
aiFailDeleteElement: '要素の削除',
|
||||
aiFailUngroup: 'グループ解除',
|
||||
aiSumUngroup: 'スライド {n} のグループを解除',
|
||||
@@ -718,6 +723,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'スライド {n} のグラフを編集',
|
||||
aiSumBackgroundAll: 'すべてのスライドの背景を設定',
|
||||
aiSumBackground: 'スライド {n} の背景を設定',
|
||||
aiSumSpeakerNotes: 'スライド {n} に発表者ノートを書き込み',
|
||||
aiSumDeleteElement: 'スライド {n} の要素を削除',
|
||||
aiSumSaveTemplate: 'スタイル テンプレート「{name}」を保存',
|
||||
aiSumTemplatesEmpty: 'スタイル テンプレート一覧(空)',
|
||||
@@ -912,6 +918,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: '표 스타일',
|
||||
aiFailChartEdit: '차트 편집',
|
||||
aiFailBackground: '배경 설정',
|
||||
aiFailSpeakerNotes: '발표자 노트 설정',
|
||||
aiFailDeleteElement: '요소 삭제',
|
||||
aiFailUngroup: '그룹 해제',
|
||||
aiSumUngroup: '슬라이드 {n} 그룹 해제',
|
||||
@@ -961,6 +968,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: '슬라이드 {n} 차트 편집',
|
||||
aiSumBackgroundAll: '모든 슬라이드 배경 설정',
|
||||
aiSumBackground: '슬라이드 {n} 배경 설정',
|
||||
aiSumSpeakerNotes: '슬라이드 {n} 발표자 노트 작성',
|
||||
aiSumDeleteElement: '슬라이드 {n} 요소 삭제',
|
||||
aiSumSaveTemplate: '스타일 템플릿 "{name}" 저장',
|
||||
aiSumTemplatesEmpty: '스타일 템플릿 목록(비어 있음)',
|
||||
@@ -1157,6 +1165,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Style du tableau',
|
||||
aiFailChartEdit: 'Modifier le graphique',
|
||||
aiFailBackground: "Définir l'arrière-plan",
|
||||
aiFailSpeakerNotes: 'Définir les notes du présentateur',
|
||||
aiFailDeleteElement: "Supprimer l'élément",
|
||||
aiFailUngroup: 'Dissocier',
|
||||
aiSumUngroup: 'Groupe dissocié sur la diapositive {n}',
|
||||
@@ -1206,6 +1215,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Graphique modifié sur la diapositive {n}',
|
||||
aiSumBackgroundAll: 'Arrière-plan défini sur toutes les diapositives',
|
||||
aiSumBackground: 'Arrière-plan défini sur la diapositive {n}',
|
||||
aiSumSpeakerNotes: 'Notes du présentateur écrites sur la diapositive {n}',
|
||||
aiSumDeleteElement: 'Élément supprimé sur la diapositive {n}',
|
||||
aiSumSaveTemplate: 'Modèle de style « {name} » enregistré',
|
||||
aiSumTemplatesEmpty: 'Modèles de style (vide)',
|
||||
@@ -1403,6 +1413,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Tabellenformat',
|
||||
aiFailChartEdit: 'Diagramm bearbeiten',
|
||||
aiFailBackground: 'Hintergrund festlegen',
|
||||
aiFailSpeakerNotes: 'Sprechernotizen festlegen',
|
||||
aiFailDeleteElement: 'Element löschen',
|
||||
aiFailUngroup: 'Gruppierung aufheben',
|
||||
aiSumUngroup: 'Gruppierung auf Folie {n} aufgehoben',
|
||||
@@ -1452,6 +1463,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Diagramm auf Folie {n} bearbeitet',
|
||||
aiSumBackgroundAll: 'Hintergrund für alle Folien festgelegt',
|
||||
aiSumBackground: 'Hintergrund auf Folie {n} festgelegt',
|
||||
aiSumSpeakerNotes: 'Sprechernotizen auf Folie {n} geschrieben',
|
||||
aiSumDeleteElement: 'Element auf Folie {n} gelöscht',
|
||||
aiSumSaveTemplate: 'Stilvorlage „{name}“ gespeichert',
|
||||
aiSumTemplatesEmpty: 'Stilvorlagen (leer)',
|
||||
@@ -1648,6 +1660,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Estilo de tabla',
|
||||
aiFailChartEdit: 'Editar gráfico',
|
||||
aiFailBackground: 'Establecer fondo',
|
||||
aiFailSpeakerNotes: 'Establecer notas del orador',
|
||||
aiFailDeleteElement: 'Eliminar elemento',
|
||||
aiFailUngroup: 'Desagrupar',
|
||||
aiSumUngroup: 'Elemento desagrupado en la diapositiva {n}',
|
||||
@@ -1697,6 +1710,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Gráfico editado en la diapositiva {n}',
|
||||
aiSumBackgroundAll: 'Fondo establecido en todas las diapositivas',
|
||||
aiSumBackground: 'Fondo establecido en la diapositiva {n}',
|
||||
aiSumSpeakerNotes: 'Notas del orador escritas en la diapositiva {n}',
|
||||
aiSumDeleteElement: 'Elemento eliminado en la diapositiva {n}',
|
||||
aiSumSaveTemplate: 'Plantilla de estilo "{name}" guardada',
|
||||
aiSumTemplatesEmpty: 'Plantillas de estilo (vacío)',
|
||||
@@ -1889,6 +1903,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'สไตล์ตาราง',
|
||||
aiFailChartEdit: 'แก้ไขแผนภูมิ',
|
||||
aiFailBackground: 'ตั้งค่าพื้นหลัง',
|
||||
aiFailSpeakerNotes: 'ตั้งค่าบันทึกย่อของผู้บรรยาย',
|
||||
aiFailDeleteElement: 'ลบองค์ประกอบ',
|
||||
aiFailUngroup: 'ยกเลิกการจัดกลุ่ม',
|
||||
aiSumUngroup: 'ยกเลิกการจัดกลุ่มในสไลด์ {n}',
|
||||
@@ -1938,6 +1953,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'แก้ไขแผนภูมิในสไลด์ {n}',
|
||||
aiSumBackgroundAll: 'ตั้งค่าพื้นหลังของทุกสไลด์',
|
||||
aiSumBackground: 'ตั้งค่าพื้นหลังของสไลด์ {n}',
|
||||
aiSumSpeakerNotes: 'เขียนบันทึกย่อของผู้บรรยายบนสไลด์ {n}',
|
||||
aiSumDeleteElement: 'ลบองค์ประกอบในสไลด์ {n}',
|
||||
aiSumSaveTemplate: 'บันทึกเทมเพลตสไตล์ "{name}"',
|
||||
aiSumTemplatesEmpty: 'รายการเทมเพลตสไตล์ (ว่าง)',
|
||||
@@ -2133,6 +2149,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Gaya tabel',
|
||||
aiFailChartEdit: 'Edit bagan',
|
||||
aiFailBackground: 'Atur latar belakang',
|
||||
aiFailSpeakerNotes: 'Atur catatan pembicara',
|
||||
aiFailDeleteElement: 'Hapus elemen',
|
||||
aiFailUngroup: 'Pisahkan grup',
|
||||
aiSumUngroup: 'Memisahkan grup di slide {n}',
|
||||
@@ -2182,6 +2199,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Mengedit bagan di slide {n}',
|
||||
aiSumBackgroundAll: 'Mengatur latar belakang semua slide',
|
||||
aiSumBackground: 'Mengatur latar belakang slide {n}',
|
||||
aiSumSpeakerNotes: 'Menulis catatan pembicara pada slide {n}',
|
||||
aiSumDeleteElement: 'Menghapus elemen di slide {n}',
|
||||
aiSumSaveTemplate: 'Menyimpan templat gaya "{name}"',
|
||||
aiSumTemplatesEmpty: 'Daftar templat gaya (kosong)',
|
||||
@@ -2377,6 +2395,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Стиль таблицы',
|
||||
aiFailChartEdit: 'Правка диаграммы',
|
||||
aiFailBackground: 'Настройка фона',
|
||||
aiFailSpeakerNotes: 'Настройка заметок докладчика',
|
||||
aiFailDeleteElement: 'Удаление элемента',
|
||||
aiFailUngroup: 'Разгруппировка',
|
||||
aiSumUngroup: 'Разгруппирован элемент на слайде {n}',
|
||||
@@ -2426,6 +2445,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Изменена диаграмма на слайде {n}',
|
||||
aiSumBackgroundAll: 'Задан фон для всех слайдов',
|
||||
aiSumBackground: 'Задан фон слайда {n}',
|
||||
aiSumSpeakerNotes: 'Записаны заметки докладчика на слайде {n}',
|
||||
aiSumDeleteElement: 'Удалён элемент на слайде {n}',
|
||||
aiSumSaveTemplate: 'Сохранён шаблон стиля «{name}»',
|
||||
aiSumTemplatesEmpty: 'Шаблоны стиля (пусто)',
|
||||
@@ -2618,6 +2638,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'نمط الجدول',
|
||||
aiFailChartEdit: 'تحرير المخطط',
|
||||
aiFailBackground: 'تعيين الخلفية',
|
||||
aiFailSpeakerNotes: 'تعيين ملاحظات المتحدث',
|
||||
aiFailDeleteElement: 'حذف عنصر',
|
||||
aiFailUngroup: 'فك التجميع',
|
||||
aiSumUngroup: 'تم فك تجميع عنصر في الشريحة {n}',
|
||||
@@ -2667,6 +2688,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'تحرير المخطط في الشريحة {n}',
|
||||
aiSumBackgroundAll: 'تعيين خلفية جميع الشرائح',
|
||||
aiSumBackground: 'تعيين خلفية الشريحة {n}',
|
||||
aiSumSpeakerNotes: 'تمت كتابة ملاحظات المتحدث على الشريحة {n}',
|
||||
aiSumDeleteElement: 'حذف عنصر في الشريحة {n}',
|
||||
aiSumSaveTemplate: 'حفظ قالب النمط "{name}"',
|
||||
aiSumTemplatesEmpty: 'قوالب الأنماط (فارغ)',
|
||||
@@ -2862,6 +2884,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Estilo da tabela',
|
||||
aiFailChartEdit: 'Editar gráfico',
|
||||
aiFailBackground: 'Definir fundo',
|
||||
aiFailSpeakerNotes: 'Definir notas do apresentador',
|
||||
aiFailDeleteElement: 'Excluir elemento',
|
||||
aiFailUngroup: 'Desagrupar',
|
||||
aiSumUngroup: 'Elemento desagrupado no slide {n}',
|
||||
@@ -2911,6 +2934,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Gráfico editado no slide {n}',
|
||||
aiSumBackgroundAll: 'Fundo definido em todos os slides',
|
||||
aiSumBackground: 'Fundo definido no slide {n}',
|
||||
aiSumSpeakerNotes: 'Notas do apresentador escritas no slide {n}',
|
||||
aiSumDeleteElement: 'Elemento excluído no slide {n}',
|
||||
aiSumSaveTemplate: 'Modelo de estilo "{name}" salvo',
|
||||
aiSumTemplatesEmpty: 'Modelos de estilo (vazio)',
|
||||
@@ -3106,6 +3130,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Stile della tabella',
|
||||
aiFailChartEdit: 'Modifica grafico',
|
||||
aiFailBackground: 'Impostazione sfondo',
|
||||
aiFailSpeakerNotes: 'Impostazione note del relatore',
|
||||
aiFailDeleteElement: 'Eliminazione elemento',
|
||||
aiFailUngroup: 'Separa gruppo',
|
||||
aiSumUngroup: 'Gruppo separato nella diapositiva {n}',
|
||||
@@ -3155,6 +3180,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Grafico modificato nella diapositiva {n}',
|
||||
aiSumBackgroundAll: 'Sfondo impostato su tutte le diapositive',
|
||||
aiSumBackground: 'Sfondo impostato nella diapositiva {n}',
|
||||
aiSumSpeakerNotes: 'Note del relatore scritte nella diapositiva {n}',
|
||||
aiSumDeleteElement: 'Elemento eliminato nella diapositiva {n}',
|
||||
aiSumSaveTemplate: 'Modello di stile "{name}" salvato',
|
||||
aiSumTemplatesEmpty: 'Modelli di stile (vuoto)',
|
||||
@@ -3350,6 +3376,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Styl tabeli',
|
||||
aiFailChartEdit: 'Edycja wykresu',
|
||||
aiFailBackground: 'Ustawianie tła',
|
||||
aiFailSpeakerNotes: 'Ustawianie notatek prelegenta',
|
||||
aiFailDeleteElement: 'Usuwanie elementu',
|
||||
aiFailUngroup: 'Rozgrupowanie',
|
||||
aiSumUngroup: 'Rozgrupowano element na slajdzie {n}',
|
||||
@@ -3399,6 +3426,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Edytowano wykres na slajdzie {n}',
|
||||
aiSumBackgroundAll: 'Ustawiono tło wszystkich slajdów',
|
||||
aiSumBackground: 'Ustawiono tło slajdu {n}',
|
||||
aiSumSpeakerNotes: 'Zapisano notatki prelegenta na slajdzie {n}',
|
||||
aiSumDeleteElement: 'Usunięto element na slajdzie {n}',
|
||||
aiSumSaveTemplate: 'Zapisano szablon stylu „{name}”',
|
||||
aiSumTemplatesEmpty: 'Szablony stylu (pusto)',
|
||||
@@ -3595,6 +3623,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Tabelstijl',
|
||||
aiFailChartEdit: 'Grafiek bewerken',
|
||||
aiFailBackground: 'Achtergrond instellen',
|
||||
aiFailSpeakerNotes: 'Sprekersnotities instellen',
|
||||
aiFailDeleteElement: 'Element verwijderen',
|
||||
aiFailUngroup: 'Groep opheffen',
|
||||
aiSumUngroup: 'Groep opgeheven op dia {n}',
|
||||
@@ -3644,6 +3673,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Grafiek bewerkt op dia {n}',
|
||||
aiSumBackgroundAll: "Achtergrond ingesteld op alle dia's",
|
||||
aiSumBackground: 'Achtergrond ingesteld op dia {n}',
|
||||
aiSumSpeakerNotes: 'Sprekersnotities geschreven op dia {n}',
|
||||
aiSumDeleteElement: 'Element verwijderd op dia {n}',
|
||||
aiSumSaveTemplate: 'Stijlsjabloon "{name}" opgeslagen',
|
||||
aiSumTemplatesEmpty: 'Stijlsjablonen (leeg)',
|
||||
@@ -3840,6 +3870,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'Gaya jadual',
|
||||
aiFailChartEdit: 'Edit carta',
|
||||
aiFailBackground: 'Tetapkan latar belakang',
|
||||
aiFailSpeakerNotes: 'Tetapkan nota pembesar suara',
|
||||
aiFailDeleteElement: 'Padam elemen',
|
||||
aiFailUngroup: 'Leraikan kumpulan',
|
||||
aiSumUngroup: 'Meleraikan kumpulan pada slaid {n}',
|
||||
@@ -3889,6 +3920,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'Mengedit carta pada slaid {n}',
|
||||
aiSumBackgroundAll: 'Menetapkan latar belakang semua slaid',
|
||||
aiSumBackground: 'Menetapkan latar belakang slaid {n}',
|
||||
aiSumSpeakerNotes: 'Nota pembesar suara ditulis pada slaid {n}',
|
||||
aiSumDeleteElement: 'Memadam elemen pada slaid {n}',
|
||||
aiSumSaveTemplate: 'Menyimpan templat gaya "{name}"',
|
||||
aiSumTemplatesEmpty: 'Templat gaya (kosong)',
|
||||
@@ -4080,6 +4112,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'סגנון טבלה',
|
||||
aiFailChartEdit: 'עריכת תרשים',
|
||||
aiFailBackground: 'הגדרת רקע',
|
||||
aiFailSpeakerNotes: 'הגדרת הערות דובר',
|
||||
aiFailDeleteElement: 'מחיקת רכיב',
|
||||
aiFailUngroup: 'פירוק קבוצה',
|
||||
aiSumUngroup: 'קבוצה פורקה בשקופית {n}',
|
||||
@@ -4129,6 +4162,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'התרשים נערך בשקופית {n}',
|
||||
aiSumBackgroundAll: 'הרקע הוגדר בכל השקופיות',
|
||||
aiSumBackground: 'הרקע הוגדר בשקופית {n}',
|
||||
aiSumSpeakerNotes: 'נכתבו הערות דובר בשקופית {n}',
|
||||
aiSumDeleteElement: 'רכיב נמחק בשקופית {n}',
|
||||
aiSumSaveTemplate: 'תבנית הסגנון "{name}" נשמרה',
|
||||
aiSumTemplatesEmpty: 'תבניות סגנון (ריק)',
|
||||
@@ -4323,6 +4357,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: 'तालिका शैली',
|
||||
aiFailChartEdit: 'चार्ट संपादित करें',
|
||||
aiFailBackground: 'पृष्ठभूमि सेट करें',
|
||||
aiFailSpeakerNotes: 'वक्ता नोट सेट करें',
|
||||
aiFailDeleteElement: 'तत्व हटाएँ',
|
||||
aiFailUngroup: 'समूह हटाएँ',
|
||||
aiSumUngroup: 'स्लाइड {n} पर समूह हटाया गया',
|
||||
@@ -4372,6 +4407,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: 'स्लाइड {n} पर चार्ट संपादित किया गया',
|
||||
aiSumBackgroundAll: 'सभी स्लाइडों की पृष्ठभूमि सेट की गई',
|
||||
aiSumBackground: 'स्लाइड {n} की पृष्ठभूमि सेट की गई',
|
||||
aiSumSpeakerNotes: 'स्लाइड {n} पर वक्ता नोट लिखे गए',
|
||||
aiSumDeleteElement: 'स्लाइड {n} पर तत्व हटाया गया',
|
||||
aiSumSaveTemplate: 'स्टाइल टेम्पलेट "{name}" सहेजा गया',
|
||||
aiSumTemplatesEmpty: 'स्टाइल टेम्पलेट (खाली)',
|
||||
@@ -4559,6 +4595,7 @@ export const aiStrings = defineStrings({
|
||||
aiFailTableStyle: '表格樣式',
|
||||
aiFailChartEdit: '圖表編輯',
|
||||
aiFailBackground: '設定背景',
|
||||
aiFailSpeakerNotes: '設定演講者備註',
|
||||
aiFailDeleteElement: '刪除元素',
|
||||
aiFailUngroup: '取消組合',
|
||||
aiSumUngroup: '第 {n} 頁取消組合',
|
||||
@@ -4608,6 +4645,7 @@ export const aiStrings = defineStrings({
|
||||
aiSumChartEdit: '第 {n} 頁圖表編輯',
|
||||
aiSumBackgroundAll: '設定全部頁背景',
|
||||
aiSumBackground: '設定第 {n} 頁背景',
|
||||
aiSumSpeakerNotes: '寫入第 {n} 頁演講者備註',
|
||||
aiSumDeleteElement: '第 {n} 頁刪除元素',
|
||||
aiSumSaveTemplate: '儲存風格範本"{name}"',
|
||||
aiSumTemplatesEmpty: '風格範本清單(空)',
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/** set_speaker_notes tool: writes/clears a page's speaker notes through DeckAccess. */
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { createSlidesSkill, type DeckAccess } from '../src/renderer/ai/slides-skill'
|
||||
import type { RenderSlide } from '@genoffice/pptx-render'
|
||||
import type { AgentToolCall } from '../src/shared/ipc'
|
||||
|
||||
const slide = {
|
||||
widthPx: 1280,
|
||||
heightPx: 720,
|
||||
nodes: [],
|
||||
} as unknown as RenderSlide
|
||||
|
||||
function mkAccess(overrides: Partial<DeckAccess> = {}): DeckAccess {
|
||||
return {
|
||||
getSlides: () => [slide],
|
||||
getCurrent: () => 0,
|
||||
getSelectedIds: () => [],
|
||||
applySlide: () => {},
|
||||
applyDeck: () => {},
|
||||
fitWidthPx: 1280,
|
||||
retryBackoffMs: 0,
|
||||
...overrides,
|
||||
} as unknown as DeckAccess
|
||||
}
|
||||
|
||||
const notesCall = (input: Record<string, unknown>): AgentToolCall => ({
|
||||
id: 'notes',
|
||||
name: 'set_speaker_notes',
|
||||
input,
|
||||
})
|
||||
|
||||
describe('set_speaker_notes', () => {
|
||||
it('writes notes for a valid page via access.setSpeakerNotes', async () => {
|
||||
const setSpeakerNotes = vi.fn(async () => true)
|
||||
const r = await createSlidesSkill(mkAccess({ setSpeakerNotes })).executeTool!(
|
||||
notesCall({ slideIndex: 0, text: 'Talk slowly.\nEmphasize the ROI slide.' }),
|
||||
)
|
||||
expect(setSpeakerNotes).toHaveBeenCalledWith(0, 'Talk slowly.\nEmphasize the ROI slide.')
|
||||
expect(r.isError).toBeUndefined()
|
||||
expect(r.mutated).toBe(true)
|
||||
expect(r.output).toContain('Wrote speaker notes')
|
||||
})
|
||||
|
||||
it('rejects an out-of-range slideIndex without calling the writer', async () => {
|
||||
const setSpeakerNotes = vi.fn(async () => true)
|
||||
const r = await createSlidesSkill(mkAccess({ setSpeakerNotes })).executeTool!(
|
||||
notesCall({ slideIndex: 5, text: 'x' }),
|
||||
)
|
||||
expect(r.isError).toBe(true)
|
||||
expect(setSpeakerNotes).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('clears notes when text is empty', async () => {
|
||||
const setSpeakerNotes = vi.fn(async () => true)
|
||||
const r = await createSlidesSkill(mkAccess({ setSpeakerNotes })).executeTool!(
|
||||
notesCall({ slideIndex: 0, text: '' }),
|
||||
)
|
||||
expect(setSpeakerNotes).toHaveBeenCalledWith(0, '')
|
||||
expect(r.output).toContain('Cleared speaker notes')
|
||||
})
|
||||
|
||||
it('reports failure when the write fails', async () => {
|
||||
const setSpeakerNotes = vi.fn(async () => false)
|
||||
const r = await createSlidesSkill(mkAccess({ setSpeakerNotes })).executeTool!(
|
||||
notesCall({ slideIndex: 0, text: 'x' }),
|
||||
)
|
||||
expect(r.isError).toBe(true)
|
||||
expect(r.output).toContain('failed')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user