@open-slide/core 2.3.0 → 2.3.2
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/dist/{config-CDrYgaEj.d.ts → config-DJ8ZOe7C.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{types-DFK02XVv.d.ts → types-tdaXSyah.d.ts} +1 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/{zh-tw-B1pkKQsc.js → zh-tw-DXcqQTrA.js} +5 -0
- package/package.json +9 -2
- package/src/agent/prompt.ts +141 -0
- package/src/agent/provider.ts +123 -0
- package/src/agent/types.ts +151 -0
- package/src/app/components/player.tsx +105 -23
- package/src/app/components/present/curtain.tsx +52 -0
- package/src/app/components/present/last-slide-hint.tsx +36 -0
- package/src/app/components/slide-canvas.tsx +1 -1
- package/src/app/components/thumbnail-rail.tsx +1 -1
- package/src/app/routes/home.tsx +13 -5
- package/src/app/routes/slide.tsx +70 -13
- package/src/editing/placeholder-id.ts +1 -0
- package/src/locale/en.ts +1 -0
- package/src/locale/es.ts +1 -0
- package/src/locale/ja.ts +1 -0
- package/src/locale/types.ts +1 -0
- package/src/locale/zh-cn.ts +1 -0
- package/src/locale/zh-tw.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as Plural, t as Locale } from "./types-
|
|
2
|
-
import { n as OpenSlideConfig, t as OpenSlideAgentConfig } from "./config-
|
|
1
|
+
import { n as Plural, t as Locale } from "./types-tdaXSyah.js";
|
|
2
|
+
import { n as OpenSlideConfig, t as OpenSlideAgentConfig } from "./config-DJ8ZOe7C.js";
|
|
3
3
|
import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
|
|
4
4
|
//#region src/app/components/image-placeholder.d.ts
|
|
5
5
|
type ImagePlaceholderProps = {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "./zh-tw-
|
|
1
|
+
import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "./zh-tw-DXcqQTrA.js";
|
|
2
2
|
import { n as defaultDesign, r as designToCssVars, t as cssVarsToString } from "./design-Cpqx7SJs.js";
|
|
3
3
|
import { Children, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { toast } from "sonner";
|
package/dist/locale/index.d.ts
CHANGED
package/dist/locale/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "../zh-tw-
|
|
1
|
+
import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "../zh-tw-DXcqQTrA.js";
|
|
2
2
|
//#region src/locale/format.ts
|
|
3
3
|
function format(template, vars) {
|
|
4
4
|
return template.replace(/\{(\w+)\}/g, (m, key) => {
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -168,6 +168,7 @@ const en = {
|
|
|
168
168
|
helpAria: "Keyboard shortcuts (?)",
|
|
169
169
|
exitAria: "Exit (Esc)",
|
|
170
170
|
elapsedTime: "Elapsed time",
|
|
171
|
+
lastSlideHint: "Last slide · Press Esc to exit",
|
|
171
172
|
helpEyebrow: "Present mode",
|
|
172
173
|
helpTitle: "Keyboard shortcuts",
|
|
173
174
|
shortcutNext: "Next slide",
|
|
@@ -796,6 +797,7 @@ const es = {
|
|
|
796
797
|
helpAria: "Atajos de teclado (?)",
|
|
797
798
|
exitAria: "Salir (Esc)",
|
|
798
799
|
elapsedTime: "Tiempo transcurrido",
|
|
800
|
+
lastSlideHint: "Última diapositiva · Pulsa Esc para salir",
|
|
799
801
|
helpEyebrow: "Modo presentación",
|
|
800
802
|
helpTitle: "Atajos de teclado",
|
|
801
803
|
shortcutNext: "Diapositiva siguiente",
|
|
@@ -1424,6 +1426,7 @@ const ja = {
|
|
|
1424
1426
|
helpAria: "キーボードショートカット (?)",
|
|
1425
1427
|
exitAria: "終了 (Esc)",
|
|
1426
1428
|
elapsedTime: "経過時間",
|
|
1429
|
+
lastSlideHint: "最後のスライドです · Esc で終了",
|
|
1427
1430
|
helpEyebrow: "発表モード",
|
|
1428
1431
|
helpTitle: "キーボードショートカット",
|
|
1429
1432
|
shortcutNext: "次のスライド",
|
|
@@ -2052,6 +2055,7 @@ const zhCN = {
|
|
|
2052
2055
|
helpAria: "键盘快捷键 (?)",
|
|
2053
2056
|
exitAria: "退出 (Esc)",
|
|
2054
2057
|
elapsedTime: "已用时",
|
|
2058
|
+
lastSlideHint: "已是最后一页 · 按 Esc 退出放映",
|
|
2055
2059
|
helpEyebrow: "演示模式",
|
|
2056
2060
|
helpTitle: "键盘快捷键",
|
|
2057
2061
|
shortcutNext: "下一张",
|
|
@@ -2680,6 +2684,7 @@ const zhTW = {
|
|
|
2680
2684
|
helpAria: "鍵盤快速鍵 (?)",
|
|
2681
2685
|
exitAria: "離開 (Esc)",
|
|
2682
2686
|
elapsedTime: "已耗時",
|
|
2687
|
+
lastSlideHint: "已是最後一頁 · 按 Esc 結束播放",
|
|
2683
2688
|
helpEyebrow: "簡報模式",
|
|
2684
2689
|
helpTitle: "鍵盤快速鍵",
|
|
2685
2690
|
shortcutNext: "下一張",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-slide/core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Runtime and CLI for open-slide — write slides in slides/, we handle the rest.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"env.d.ts",
|
|
30
30
|
"src/app",
|
|
31
31
|
"src/locale",
|
|
32
|
+
"src/agent/prompt.ts",
|
|
33
|
+
"src/agent/provider.ts",
|
|
34
|
+
"src/agent/types.ts",
|
|
35
|
+
"src/editing/placeholder-id.ts",
|
|
36
|
+
"!src/**/*.test.ts",
|
|
37
|
+
"!src/**/*.test.tsx",
|
|
32
38
|
"skills",
|
|
33
39
|
"README.md"
|
|
34
40
|
],
|
|
@@ -93,7 +99,7 @@
|
|
|
93
99
|
},
|
|
94
100
|
"devDependencies": {
|
|
95
101
|
"@playwright/test": "~1.63.0",
|
|
96
|
-
"@types/node": "^26.6.
|
|
102
|
+
"@types/node": "^26.6.6",
|
|
97
103
|
"@types/react": "^19.2.18",
|
|
98
104
|
"@types/react-dom": "^19.2.5",
|
|
99
105
|
"tsdown": "^0.22.14",
|
|
@@ -102,6 +108,7 @@
|
|
|
102
108
|
"scripts": {
|
|
103
109
|
"build": "tsdown",
|
|
104
110
|
"typecheck": "tsc --noEmit",
|
|
111
|
+
"check:pack": "node scripts/check-pack.mjs",
|
|
105
112
|
"test:e2e": "pnpm run build && playwright test"
|
|
106
113
|
}
|
|
107
114
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { UNTITLED_SLIDE_ID_RE } from '../editing/placeholder-id.ts';
|
|
2
|
+
import { parseQuestions } from './provider.ts';
|
|
3
|
+
import type { AgentQuestion, AgentTurnContext } from './types.ts';
|
|
4
|
+
|
|
5
|
+
const PAGE_BY_PAGE =
|
|
6
|
+
'Write a new deck page by page so the user can follow along on the canvas: first replace the file with the imports, meta (keeping its existing createdAt), design and the cover page only, then add each remaining page with its own separate edit, keeping the file compiling after every write.';
|
|
7
|
+
|
|
8
|
+
const DECK_SLUG =
|
|
9
|
+
"This deck's folder still has a placeholder name. Never rename or move the folder yourself: once the deck has content, end your final reply with a slug for it on a line of its own as <deck-slug>short-kebab-case-english-slug</deck-slug>, and open-slide renames the folder from it.";
|
|
10
|
+
|
|
11
|
+
export function systemPromptAppend(askInstruction: string): string {
|
|
12
|
+
return [
|
|
13
|
+
'You are running inside the open-slide dev server, driven from its in-app agent panel in the browser rather than a terminal.',
|
|
14
|
+
'The workspace is an open-slide project: decks live under slides/<id>/index.tsx and the dev server hot-reloads every edit, so the user sees changes immediately.',
|
|
15
|
+
'Use the project skills: create-slide to draft a new deck, apply-comments to resolve @slide-comment markers left by the inspector, create-theme for themes, and slide-authoring as the technical reference before writing a page.',
|
|
16
|
+
PAGE_BY_PAGE,
|
|
17
|
+
'Keep replies short and concrete: the panel is narrow. Prefer doing the work over describing it, and finish with a one-line summary of what changed.',
|
|
18
|
+
askInstruction,
|
|
19
|
+
].join(' ');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function buildTurnPrompt(text: string, context: AgentTurnContext | undefined): string {
|
|
23
|
+
const lines = contextLines(context);
|
|
24
|
+
if (lines.length === 0) return text;
|
|
25
|
+
return `${text}\n\n<open-slide-context>\n${lines.join('\n')}\n</open-slide-context>`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Slide titles and selected text come from deck content, so they sit in their
|
|
29
|
+
// own tags with `<` escaped and can't close the context block.
|
|
30
|
+
const escapeTag = (s: string) => s.replace(/</g, '<');
|
|
31
|
+
|
|
32
|
+
function contextLines(context: AgentTurnContext | undefined): string[] {
|
|
33
|
+
if (!context?.slideId) return [];
|
|
34
|
+
const file = `slides/${context.slideId}/index.tsx`;
|
|
35
|
+
const lines: string[] = [];
|
|
36
|
+
if (context.newDeck) {
|
|
37
|
+
lines.push(
|
|
38
|
+
`${file} is a blank deck created for this request. Draft the deck the user describes into it with the create-slide skill: replace the placeholder page, keep the slide id, and do not create another folder.`,
|
|
39
|
+
'Ask the create-slide scoping questions in a single round, only for what the request leaves unclear; skip any it already answers.',
|
|
40
|
+
PAGE_BY_PAGE,
|
|
41
|
+
DECK_SLUG,
|
|
42
|
+
);
|
|
43
|
+
return lines;
|
|
44
|
+
}
|
|
45
|
+
lines.push(`The user is viewing slide "${context.slideId}": ${file}.`);
|
|
46
|
+
if (UNTITLED_SLIDE_ID_RE.test(context.slideId)) lines.push(DECK_SLUG);
|
|
47
|
+
if (context.slideTitle) {
|
|
48
|
+
lines.push(`<slide-title>${escapeTag(context.slideTitle)}</slide-title>`);
|
|
49
|
+
}
|
|
50
|
+
if (context.pageNumber && context.totalPages) {
|
|
51
|
+
lines.push(
|
|
52
|
+
`They are on page ${context.pageNumber} of ${context.totalPages} (0-based index ${context.pageNumber - 1} in the default export array).`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (context.selection) {
|
|
56
|
+
const { line, column, tagName, text } = context.selection;
|
|
57
|
+
lines.push(
|
|
58
|
+
`They have selected a <${escapeTag(tagName)}> element at ${file}:${line}:${column}.${text ? ' Its text is in <selected-text>.' : ''} "This element" refers to it.`,
|
|
59
|
+
);
|
|
60
|
+
if (text) lines.push(`<selected-text>${escapeTag(text)}</selected-text>`);
|
|
61
|
+
}
|
|
62
|
+
if (context.pendingComments) {
|
|
63
|
+
lines.push(
|
|
64
|
+
`There are ${context.pendingComments} pending @slide-comment markers in this slide's source.`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return lines;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const DECK_SLUG_RE = /\s*<deck-slug>\s*([^<]*?)\s*<\/deck-slug>\s*/gi;
|
|
71
|
+
|
|
72
|
+
export function extractDeckSlug(text: string): string | null {
|
|
73
|
+
let slug: string | null = null;
|
|
74
|
+
for (const match of text.matchAll(DECK_SLUG_RE)) slug = match[1] || slug;
|
|
75
|
+
return slug;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Also drops a tag that is still streaming in, so the marker never flashes
|
|
79
|
+
// in the transcript.
|
|
80
|
+
export function stripDeckSlug(text: string): string {
|
|
81
|
+
return text
|
|
82
|
+
.replace(DECK_SLUG_RE, '\n')
|
|
83
|
+
.replace(/\s*<deck-slug>[^<]*$/i, '')
|
|
84
|
+
.trimEnd();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function applyCommentsPrompt(slideId: string): string {
|
|
88
|
+
return `Use the apply-comments skill to apply every pending @slide-comment marker in slides/${slideId}/index.tsx, then remove the markers.`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const QUESTIONS_RE = /<open-slide-questions>([\s\S]*?)<\/open-slide-questions>/i;
|
|
92
|
+
|
|
93
|
+
export const TEXT_QUESTIONS_INSTRUCTION =
|
|
94
|
+
'You cannot ask the user anything interactively here, and nothing you print in the middle of a turn can be answered. When you need answers before continuing, stop working and end your turn with a final message holding only an <open-slide-questions> block: a JSON array of at most 4 questions shaped like [{"header":"Pages","question":"How many pages?","multiSelect":false,"options":[{"label":"6-10 (Recommended)","description":"Standard length"}]}], each with 2 to 4 options, written in the user\'s language. The panel shows them as a form and sends the answers back as your next message. Write nothing after the block and do not continue the task in the same turn.';
|
|
95
|
+
|
|
96
|
+
// Splits a reply written under TEXT_QUESTIONS_INSTRUCTION into its prose and
|
|
97
|
+
// questions. Returns null when the reply holds no usable block.
|
|
98
|
+
export function extractQuestionBlock(
|
|
99
|
+
text: string,
|
|
100
|
+
): { text: string; questions: AgentQuestion[] } | null {
|
|
101
|
+
const match = QUESTIONS_RE.exec(text);
|
|
102
|
+
if (!match) return null;
|
|
103
|
+
const body = match[1]
|
|
104
|
+
.trim()
|
|
105
|
+
.replace(/^```(?:json)?\s*/i, '')
|
|
106
|
+
.replace(/\s*```$/, '');
|
|
107
|
+
let raw: unknown;
|
|
108
|
+
try {
|
|
109
|
+
raw = JSON.parse(body);
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const questions = parseQuestions({
|
|
114
|
+
questions: Array.isArray(raw) ? raw : (raw as { questions?: unknown } | null)?.questions,
|
|
115
|
+
});
|
|
116
|
+
if (questions.length === 0) return null;
|
|
117
|
+
return { text: text.replace(QUESTIONS_RE, '').trim(), questions };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function answersPrompt(
|
|
121
|
+
questions: AgentQuestion[],
|
|
122
|
+
answers: Record<string, string> | null,
|
|
123
|
+
): string {
|
|
124
|
+
if (!answers) {
|
|
125
|
+
return 'I skipped your questions. Continue the task with your best judgement and sensible defaults.';
|
|
126
|
+
}
|
|
127
|
+
const lines = questions.map((q) => `- ${q.question} ${answers[q.question] || '(no answer)'}`);
|
|
128
|
+
return `My answers:\n${lines.join('\n')}\n\nContinue the task with these answers.`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// For agents whose history can't be rewound: the edited message goes on top
|
|
132
|
+
// of the old conversation, so the agent is told to set that part aside.
|
|
133
|
+
export function editedPrompt(original: string, text: string): string {
|
|
134
|
+
return `I went back and edited an earlier message of mine. Treat everything after it in this conversation, including your replies, as discarded, and respond to the edited version instead. Files keep whatever changes were already made.\n\n<original-message>\n${escapeTag(original)}\n</original-message>\n\n${text}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// For agents rewound to before the edited message: their history forgets the
|
|
138
|
+
// later turns, but the files on disk still hold what those turns wrote.
|
|
139
|
+
export function rewoundPrompt(text: string): string {
|
|
140
|
+
return `${text}\n\n<open-slide-note>I went back and edited this message. Files keep the changes made after it in the discarded part of this conversation, so read the current files before editing them.</open-slide-note>`;
|
|
141
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { AgentEffort, AgentModelOption, AgentProviderId, AgentQuestion } from './types.ts';
|
|
3
|
+
|
|
4
|
+
export type ProviderEvent =
|
|
5
|
+
| { type: 'session-id'; id: string }
|
|
6
|
+
// A point in the provider's own history that a later edit can rewind to.
|
|
7
|
+
| { type: 'checkpoint'; id: string }
|
|
8
|
+
| { type: 'text-start'; id: string }
|
|
9
|
+
| { type: 'text-delta'; id: string; text: string }
|
|
10
|
+
| { type: 'text-end'; id: string; text: string | null }
|
|
11
|
+
| { type: 'tool-start'; id: string; name: string; title: string; detail: string | null }
|
|
12
|
+
| { type: 'tool-end'; id: string; ok: boolean }
|
|
13
|
+
| { type: 'error'; text: string }
|
|
14
|
+
| { type: 'result'; durationMs: number | null; costUsd: number | null }
|
|
15
|
+
// Questions the agent wrote into its reply instead of asking through a
|
|
16
|
+
// tool: the turn ends, and the answers arrive as the next prompt.
|
|
17
|
+
| { type: 'questions'; questions: AgentQuestion[] };
|
|
18
|
+
|
|
19
|
+
export type PermissionRequest = { tool: string; title: string; detail: string | null };
|
|
20
|
+
|
|
21
|
+
export type ProviderRunOptions = {
|
|
22
|
+
cwd: string;
|
|
23
|
+
// Directories the agent may write to without asking: the deck and asset
|
|
24
|
+
// folders. Edits anywhere else (configs, package.json) need approval.
|
|
25
|
+
writableRoots: string[];
|
|
26
|
+
prompt: string;
|
|
27
|
+
systemPromptAppend: string;
|
|
28
|
+
resume: string | null;
|
|
29
|
+
resumeAt: string | null;
|
|
30
|
+
model: string | null;
|
|
31
|
+
effort: AgentEffort | null;
|
|
32
|
+
signal: AbortSignal;
|
|
33
|
+
emit: (event: ProviderEvent) => void;
|
|
34
|
+
askUser: (questions: AgentQuestion[]) => Promise<Record<string, string> | null>;
|
|
35
|
+
requestPermission: (request: PermissionRequest) => Promise<boolean>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export interface AgentProvider {
|
|
39
|
+
id: AgentProviderId;
|
|
40
|
+
name: string;
|
|
41
|
+
sdkPackage: string;
|
|
42
|
+
cliCommand: string;
|
|
43
|
+
askInstruction: string;
|
|
44
|
+
canRewind: boolean;
|
|
45
|
+
models(): Promise<AgentModelOption[]>;
|
|
46
|
+
run(opts: ProviderRunOptions): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class ProviderUnavailableError extends Error {
|
|
50
|
+
constructor(provider: AgentProvider) {
|
|
51
|
+
super(
|
|
52
|
+
`${provider.name} is not connected: install ${provider.sdkPackage} in this workspace to use it from the agent panel.`,
|
|
53
|
+
);
|
|
54
|
+
this.name = 'ProviderUnavailableError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const DETAIL_MAX = 400;
|
|
59
|
+
|
|
60
|
+
export function clipDetail(value: unknown): string | null {
|
|
61
|
+
if (value === undefined || value === null) return null;
|
|
62
|
+
const text = typeof value === 'string' ? value : safeJson(value);
|
|
63
|
+
if (!text) return null;
|
|
64
|
+
const oneLine = text.replace(/\s+/g, ' ').trim();
|
|
65
|
+
return oneLine.length > DETAIL_MAX ? `${oneLine.slice(0, DETAIL_MAX - 1)}…` : oneLine;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function safeJson(value: unknown): string {
|
|
69
|
+
try {
|
|
70
|
+
return JSON.stringify(value);
|
|
71
|
+
} catch {
|
|
72
|
+
return String(value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function isInsideRoots(cwd: string, file: unknown, roots: string[]): boolean {
|
|
77
|
+
if (typeof file !== 'string' || !file) return false;
|
|
78
|
+
const resolved = path.resolve(cwd, file);
|
|
79
|
+
return roots.some((root) => {
|
|
80
|
+
const rel = path.relative(root, resolved);
|
|
81
|
+
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function relativeToCwd(cwd: string, file: unknown): string | null {
|
|
86
|
+
if (typeof file !== 'string' || !file) return null;
|
|
87
|
+
const normalizedCwd = cwd.replace(/[\\/]+$/, '');
|
|
88
|
+
if (file.startsWith(normalizedCwd)) {
|
|
89
|
+
const rest = file.slice(normalizedCwd.length).replace(/^[\\/]+/, '');
|
|
90
|
+
return rest || '.';
|
|
91
|
+
}
|
|
92
|
+
return file;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function parseQuestions(input: Record<string, unknown>): AgentQuestion[] {
|
|
96
|
+
const raw = Array.isArray(input.questions) ? input.questions : [];
|
|
97
|
+
const questions: AgentQuestion[] = [];
|
|
98
|
+
for (const q of raw) {
|
|
99
|
+
if (!q || typeof q !== 'object') continue;
|
|
100
|
+
const r = q as Record<string, unknown>;
|
|
101
|
+
const options = Array.isArray(r.options)
|
|
102
|
+
? r.options
|
|
103
|
+
.map((o) => {
|
|
104
|
+
if (!o || typeof o !== 'object') return null;
|
|
105
|
+
const opt = o as Record<string, unknown>;
|
|
106
|
+
if (typeof opt.label !== 'string') return null;
|
|
107
|
+
return {
|
|
108
|
+
label: opt.label,
|
|
109
|
+
description: typeof opt.description === 'string' ? opt.description : undefined,
|
|
110
|
+
};
|
|
111
|
+
})
|
|
112
|
+
.filter((o): o is { label: string; description: string | undefined } => o !== null)
|
|
113
|
+
: [];
|
|
114
|
+
if (typeof r.question !== 'string') continue;
|
|
115
|
+
questions.push({
|
|
116
|
+
header: typeof r.header === 'string' ? r.header : '',
|
|
117
|
+
question: r.question,
|
|
118
|
+
options,
|
|
119
|
+
multiSelect: r.multiSelect === true,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return questions;
|
|
123
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const AGENT_PROVIDER_IDS = ['claude', 'codex'] as const;
|
|
2
|
+
|
|
3
|
+
export type AgentProviderId = (typeof AGENT_PROVIDER_IDS)[number];
|
|
4
|
+
|
|
5
|
+
export const AGENT_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const;
|
|
6
|
+
|
|
7
|
+
export type AgentEffort = (typeof AGENT_EFFORTS)[number];
|
|
8
|
+
|
|
9
|
+
export function isAgentProviderId(value: unknown): value is AgentProviderId {
|
|
10
|
+
return typeof value === 'string' && (AGENT_PROVIDER_IDS as readonly string[]).includes(value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isAgentEffort(value: unknown): value is AgentEffort {
|
|
14
|
+
return typeof value === 'string' && (AGENT_EFFORTS as readonly string[]).includes(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type AgentModelOption = {
|
|
18
|
+
// Empty when the option stands for the CLI's own default model.
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
efforts: AgentEffort[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type AgentProviderStatus = {
|
|
25
|
+
id: AgentProviderId;
|
|
26
|
+
name: string;
|
|
27
|
+
sdkPackage: string;
|
|
28
|
+
sdkVersion: string | null;
|
|
29
|
+
cliCommand: string;
|
|
30
|
+
cliFound: boolean;
|
|
31
|
+
cliVersion: string | null;
|
|
32
|
+
ready: boolean;
|
|
33
|
+
models: AgentModelOption[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type AgentStatus = {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
packageManager: string;
|
|
39
|
+
providers: AgentProviderStatus[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type AgentQuestionOption = { label: string; description?: string };
|
|
43
|
+
|
|
44
|
+
export type AgentQuestion = {
|
|
45
|
+
header: string;
|
|
46
|
+
question: string;
|
|
47
|
+
options: AgentQuestionOption[];
|
|
48
|
+
multiSelect: boolean;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type AgentItem =
|
|
52
|
+
| {
|
|
53
|
+
kind: 'user';
|
|
54
|
+
id: string;
|
|
55
|
+
ts: string;
|
|
56
|
+
text: string;
|
|
57
|
+
// The provider history point just before this message, so editing it
|
|
58
|
+
// can rewind the agent's conversation there.
|
|
59
|
+
resumeAt?: string;
|
|
60
|
+
newDeck?: boolean;
|
|
61
|
+
}
|
|
62
|
+
| { kind: 'assistant'; id: string; ts: string; text: string; streaming: boolean }
|
|
63
|
+
| {
|
|
64
|
+
kind: 'tool';
|
|
65
|
+
id: string;
|
|
66
|
+
ts: string;
|
|
67
|
+
name: string;
|
|
68
|
+
title: string;
|
|
69
|
+
detail: string | null;
|
|
70
|
+
status: 'running' | 'done' | 'error';
|
|
71
|
+
}
|
|
72
|
+
| {
|
|
73
|
+
kind: 'question';
|
|
74
|
+
id: string;
|
|
75
|
+
ts: string;
|
|
76
|
+
questions: AgentQuestion[];
|
|
77
|
+
answers: Record<string, string> | null;
|
|
78
|
+
status: 'pending' | 'answered' | 'cancelled';
|
|
79
|
+
}
|
|
80
|
+
| {
|
|
81
|
+
kind: 'permission';
|
|
82
|
+
id: string;
|
|
83
|
+
ts: string;
|
|
84
|
+
tool: string;
|
|
85
|
+
title: string;
|
|
86
|
+
detail: string | null;
|
|
87
|
+
status: 'pending' | 'allowed' | 'denied';
|
|
88
|
+
}
|
|
89
|
+
| { kind: 'error'; id: string; ts: string; text: string }
|
|
90
|
+
| {
|
|
91
|
+
kind: 'result';
|
|
92
|
+
id: string;
|
|
93
|
+
ts: string;
|
|
94
|
+
durationMs: number | null;
|
|
95
|
+
costUsd: number | null;
|
|
96
|
+
aborted: boolean;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type AgentSessionStatus = 'idle' | 'running';
|
|
100
|
+
|
|
101
|
+
export type AgentSessionSummary = {
|
|
102
|
+
id: string;
|
|
103
|
+
provider: AgentProviderId;
|
|
104
|
+
title: string;
|
|
105
|
+
createdAt: string;
|
|
106
|
+
updatedAt: string;
|
|
107
|
+
status: AgentSessionStatus;
|
|
108
|
+
slideId: string | null;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type AgentSession = AgentSessionSummary & {
|
|
112
|
+
providerSessionId: string | null;
|
|
113
|
+
providerCheckpoint?: string | null;
|
|
114
|
+
// Set once the oldest items were dropped to stay under the item cap.
|
|
115
|
+
trimmed?: boolean;
|
|
116
|
+
items: AgentItem[];
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type AgentTurnContext = {
|
|
120
|
+
slideId?: string;
|
|
121
|
+
slideTitle?: string;
|
|
122
|
+
pageNumber?: number;
|
|
123
|
+
totalPages?: number;
|
|
124
|
+
pendingComments?: number;
|
|
125
|
+
selection?: { line: number; column: number; tagName: string; text: string } | null;
|
|
126
|
+
newDeck?: boolean;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type RespondPayload =
|
|
130
|
+
| { answers: Record<string, string> }
|
|
131
|
+
| { allow: boolean }
|
|
132
|
+
| { cancel: true };
|
|
133
|
+
|
|
134
|
+
export type AgentStreamEvent =
|
|
135
|
+
| { type: 'session'; session: AgentSessionSummary }
|
|
136
|
+
| { type: 'session-removed'; sessionId: string }
|
|
137
|
+
| { type: 'item'; sessionId: string; item: AgentItem }
|
|
138
|
+
| { type: 'delta'; sessionId: string; itemId: string; text: string }
|
|
139
|
+
| { type: 'truncate'; sessionId: string; itemId: string }
|
|
140
|
+
| { type: 'slide-renamed'; from: string; to: string };
|
|
141
|
+
|
|
142
|
+
export function sessionSummary(session: AgentSession): AgentSessionSummary {
|
|
143
|
+
const {
|
|
144
|
+
providerSessionId: _p,
|
|
145
|
+
providerCheckpoint: _c,
|
|
146
|
+
trimmed: _t,
|
|
147
|
+
items: _i,
|
|
148
|
+
...summary
|
|
149
|
+
} = session;
|
|
150
|
+
return summary;
|
|
151
|
+
}
|
|
@@ -12,9 +12,16 @@ import { usePrefersReducedMotion } from '../lib/use-prefers-reduced-motion';
|
|
|
12
12
|
import { OverviewGrid } from './overview-grid';
|
|
13
13
|
import { PresentBlackoutOverlay } from './present/blackout-overlay';
|
|
14
14
|
import { PresentControlBar } from './present/control-bar';
|
|
15
|
+
import {
|
|
16
|
+
afterPaint,
|
|
17
|
+
CURTAIN_FADE_MS,
|
|
18
|
+
PresentCurtain,
|
|
19
|
+
whenFullscreenSettled,
|
|
20
|
+
} from './present/curtain';
|
|
15
21
|
import { PresentHelpOverlay } from './present/help-overlay';
|
|
16
22
|
import { PresentJumpInput } from './present/jump-input';
|
|
17
23
|
import { PresentLaserPointer } from './present/laser-pointer';
|
|
24
|
+
import { PresentLastSlideHint } from './present/last-slide-hint';
|
|
18
25
|
import { PresentProgressBar } from './present/progress-bar';
|
|
19
26
|
import { useIdle } from './present/use-idle';
|
|
20
27
|
import { usePointerNearBottom } from './present/use-pointer-near-bottom';
|
|
@@ -48,6 +55,8 @@ type Props = {
|
|
|
48
55
|
* without entering fullscreen. Defaults to true for back-compat.
|
|
49
56
|
*/
|
|
50
57
|
fullscreen?: boolean;
|
|
58
|
+
/** Fade in from black on mount and fade to black before calling `onExit`. */
|
|
59
|
+
curtain?: boolean;
|
|
51
60
|
};
|
|
52
61
|
|
|
53
62
|
export function Player({
|
|
@@ -62,9 +71,13 @@ export function Player({
|
|
|
62
71
|
slideId,
|
|
63
72
|
onSwitchSlide,
|
|
64
73
|
fullscreen = true,
|
|
74
|
+
curtain = false,
|
|
65
75
|
}: Props) {
|
|
66
76
|
const isMobile = useIsMobile();
|
|
67
77
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
78
|
+
const fade = curtain && !prefersReducedMotion;
|
|
79
|
+
const [curtainOpaque, setCurtainOpaque] = useState(fade);
|
|
80
|
+
const exitingRef = useRef(false);
|
|
68
81
|
const rootRef = useRef<HTMLDivElement | null>(null);
|
|
69
82
|
// Mirrored as state so descendants portaling *into* the player subtree
|
|
70
83
|
// (tooltips, popovers — the body is outside the fullscreen tree) re-render
|
|
@@ -93,6 +106,28 @@ export function Player({
|
|
|
93
106
|
const canPrev = index > 0;
|
|
94
107
|
const canNext = index < pages.length - 1;
|
|
95
108
|
|
|
109
|
+
// Stepping past either end nudges the slide like a rubber band so the
|
|
110
|
+
// press visibly registered; past the last slide a hint says how to leave.
|
|
111
|
+
const nudgeRef = useRef<HTMLDivElement | null>(null);
|
|
112
|
+
const [lastSlideHintAt, setLastSlideHintAt] = useState(0);
|
|
113
|
+
const bumpEdge = useCallback(
|
|
114
|
+
(direction: 'start' | 'end') => {
|
|
115
|
+
if (!controls) return;
|
|
116
|
+
if (direction === 'end') setLastSlideHintAt(Date.now());
|
|
117
|
+
if (prefersReducedMotion) return;
|
|
118
|
+
const offset = direction === 'end' ? -14 : 14;
|
|
119
|
+
nudgeRef.current?.animate(
|
|
120
|
+
[
|
|
121
|
+
{ transform: 'translateX(0)' },
|
|
122
|
+
{ transform: `translateX(${offset}px)`, offset: 0.3 },
|
|
123
|
+
{ transform: 'translateX(0)' },
|
|
124
|
+
],
|
|
125
|
+
{ duration: 360, easing: 'cubic-bezier(0.2, 0.8, 0.3, 1)' },
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
[controls, prefersReducedMotion],
|
|
129
|
+
);
|
|
130
|
+
|
|
96
131
|
const stepControllerRef = useRef<StepController | null>(null);
|
|
97
132
|
const [entryDirection, setEntryDirection] = useState<EntryDirection>('jump');
|
|
98
133
|
const [stepAggregate, setStepAggregate] = useState<StepAggregate>({
|
|
@@ -116,14 +151,34 @@ export function Player({
|
|
|
116
151
|
[index, onIndexChange],
|
|
117
152
|
);
|
|
118
153
|
|
|
154
|
+
const exitTimerRef = useRef<number | null>(null);
|
|
155
|
+
useEffect(
|
|
156
|
+
() => () => {
|
|
157
|
+
if (exitTimerRef.current !== null) window.clearTimeout(exitTimerRef.current);
|
|
158
|
+
},
|
|
159
|
+
[],
|
|
160
|
+
);
|
|
161
|
+
const requestExit = useCallback(() => {
|
|
162
|
+
if (!fade) {
|
|
163
|
+
onExit();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (exitingRef.current) return;
|
|
167
|
+
exitingRef.current = true;
|
|
168
|
+
setCurtainOpaque(true);
|
|
169
|
+
exitTimerRef.current = window.setTimeout(onExit, CURTAIN_FADE_MS);
|
|
170
|
+
}, [fade, onExit]);
|
|
171
|
+
|
|
119
172
|
const goPrev = useCallback(() => {
|
|
120
173
|
if (stepControllerRef.current?.retreat()) return;
|
|
121
174
|
if (index > 0) handleIndexChange(index - 1);
|
|
122
|
-
|
|
175
|
+
else bumpEdge('start');
|
|
176
|
+
}, [index, handleIndexChange, bumpEdge]);
|
|
123
177
|
const goNext = useCallback(() => {
|
|
124
178
|
if (stepControllerRef.current?.advance()) return;
|
|
125
179
|
if (index < pages.length - 1) handleIndexChange(index + 1);
|
|
126
|
-
|
|
180
|
+
else bumpEdge('end');
|
|
181
|
+
}, [index, pages.length, handleIndexChange, bumpEdge]);
|
|
127
182
|
|
|
128
183
|
const overlayActive = controls && (overviewOpen || helpOpen);
|
|
129
184
|
const overlayActiveRef = useRef(overlayActive);
|
|
@@ -178,8 +233,8 @@ export function Player({
|
|
|
178
233
|
useClickPageNavigation({
|
|
179
234
|
ref: rootRef,
|
|
180
235
|
enabled: !overlayActive,
|
|
181
|
-
canPrev,
|
|
182
|
-
canNext,
|
|
236
|
+
canPrev: canPrev || controls,
|
|
237
|
+
canNext: canNext || controls,
|
|
183
238
|
onPrev: goPrev,
|
|
184
239
|
onNext: goNext,
|
|
185
240
|
onViewportClick: controls && isMobile ? handleMobileViewportClick : undefined,
|
|
@@ -216,11 +271,33 @@ export function Player({
|
|
|
216
271
|
useEffect(() => {
|
|
217
272
|
if (!allowExit) return;
|
|
218
273
|
const onFsChange = () => {
|
|
219
|
-
if (!document.fullscreenElement && !windowedRef.current)
|
|
274
|
+
if (!document.fullscreenElement && !windowedRef.current) requestExit();
|
|
220
275
|
};
|
|
221
276
|
document.addEventListener('fullscreenchange', onFsChange);
|
|
222
277
|
return () => document.removeEventListener('fullscreenchange', onFsChange);
|
|
223
|
-
}, [
|
|
278
|
+
}, [requestExit, allowExit]);
|
|
279
|
+
|
|
280
|
+
// Wait out the browser's own fullscreen animation before revealing the
|
|
281
|
+
// first slide, otherwise the fade plays while the screen is still resizing.
|
|
282
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: runs once on mount
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
if (!fade) return;
|
|
285
|
+
let cancelPaint = () => {};
|
|
286
|
+
const reveal = () => {
|
|
287
|
+
cancelPaint = afterPaint(() => {
|
|
288
|
+
if (!exitingRef.current) setCurtainOpaque(false);
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
if (!fullscreen || document.fullscreenElement) {
|
|
292
|
+
reveal();
|
|
293
|
+
return () => cancelPaint();
|
|
294
|
+
}
|
|
295
|
+
const cancelWait = whenFullscreenSettled(reveal);
|
|
296
|
+
return () => {
|
|
297
|
+
cancelWait();
|
|
298
|
+
cancelPaint();
|
|
299
|
+
};
|
|
300
|
+
}, []);
|
|
224
301
|
|
|
225
302
|
const toggleFullscreen = useCallback(() => {
|
|
226
303
|
setWindowed((w) => !w);
|
|
@@ -296,7 +373,7 @@ export function Player({
|
|
|
296
373
|
setBlackout(null);
|
|
297
374
|
return;
|
|
298
375
|
}
|
|
299
|
-
if (allowExit)
|
|
376
|
+
if (allowExit) requestExit();
|
|
300
377
|
return;
|
|
301
378
|
}
|
|
302
379
|
|
|
@@ -364,7 +441,7 @@ export function Player({
|
|
|
364
441
|
helpOpen,
|
|
365
442
|
blackout,
|
|
366
443
|
allowExit,
|
|
367
|
-
|
|
444
|
+
requestExit,
|
|
368
445
|
goNext,
|
|
369
446
|
goPrev,
|
|
370
447
|
handleIndexChange,
|
|
@@ -403,26 +480,29 @@ export function Player({
|
|
|
403
480
|
controls && (hideCursor ? 'cursor-none' : 'cursor-default'),
|
|
404
481
|
)}
|
|
405
482
|
>
|
|
406
|
-
<
|
|
407
|
-
|
|
483
|
+
<div ref={nudgeRef} className="h-full w-full">
|
|
484
|
+
<SlideCanvas flat design={design}>
|
|
485
|
+
{/* Keyed per deck so a presenter-driven deck switch cuts instead of
|
|
408
486
|
animating a transition between two unrelated decks. */}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
487
|
+
<SlideTransitionLayer
|
|
488
|
+
key={slideId}
|
|
489
|
+
pages={pages}
|
|
490
|
+
index={index}
|
|
491
|
+
total={pages.length}
|
|
492
|
+
moduleTransition={transition}
|
|
493
|
+
disabled={prefersReducedMotion}
|
|
494
|
+
stepControllerRef={stepControllerRef}
|
|
495
|
+
entryDirection={entryDirection}
|
|
496
|
+
onStepAggregateChange={handleAggregateChange}
|
|
497
|
+
/>
|
|
498
|
+
</SlideCanvas>
|
|
499
|
+
</div>
|
|
421
500
|
|
|
422
501
|
{controls && (
|
|
423
502
|
<div data-osd-chrome style={{ display: 'contents' }}>
|
|
424
503
|
<PresentProgressBar index={index} total={pages.length} visible={chromeVisible} />
|
|
425
504
|
<PresentBlackoutOverlay mode={blackout} />
|
|
505
|
+
<PresentLastSlideHint shownAt={lastSlideHintAt} />
|
|
426
506
|
<PresentJumpInput pageCount={pages.length} onJump={handleIndexChange} />
|
|
427
507
|
<PresentLaserPointer enabled={laser} />
|
|
428
508
|
<PresentControlBar
|
|
@@ -444,7 +524,7 @@ export function Player({
|
|
|
444
524
|
onPresenter={() => slideId && openPresenterWindow(slideId)}
|
|
445
525
|
onToggleFullscreen={toggleFullscreen}
|
|
446
526
|
onHelp={() => setHelpOpen(true)}
|
|
447
|
-
onExit={
|
|
527
|
+
onExit={requestExit}
|
|
448
528
|
/>
|
|
449
529
|
<OverviewGrid
|
|
450
530
|
pages={pages}
|
|
@@ -460,6 +540,8 @@ export function Player({
|
|
|
460
540
|
<PresentHelpOverlay open={helpOpen} onOpenChange={setHelpOpen} container={rootEl} />
|
|
461
541
|
</div>
|
|
462
542
|
)}
|
|
543
|
+
|
|
544
|
+
{fade && <PresentCurtain opaque={curtainOpaque} className="absolute z-[100]" />}
|
|
463
545
|
</div>
|
|
464
546
|
);
|
|
465
547
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cn } from '@/lib/utils';
|
|
2
|
+
|
|
3
|
+
export const CURTAIN_FADE_MS = 400;
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
opaque: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function PresentCurtain({ opaque, className }: Props) {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
aria-hidden
|
|
14
|
+
className={cn(
|
|
15
|
+
'pointer-events-none inset-0 bg-black transition-opacity ease-in-out',
|
|
16
|
+
opaque ? 'opacity-100' : 'opacity-0',
|
|
17
|
+
className,
|
|
18
|
+
)}
|
|
19
|
+
style={{ transitionDuration: `${CURTAIN_FADE_MS}ms` }}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Two frames so the opaque state is painted before the fade starts;
|
|
25
|
+
// a single rAF can land in the same style recalc and skip the transition.
|
|
26
|
+
export function afterPaint(cb: () => void): () => void {
|
|
27
|
+
let inner = 0;
|
|
28
|
+
const outer = requestAnimationFrame(() => {
|
|
29
|
+
inner = requestAnimationFrame(cb);
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
cancelAnimationFrame(outer);
|
|
33
|
+
cancelAnimationFrame(inner);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function whenFullscreenSettled(cb: () => void, maxWaitMs = 800): () => void {
|
|
38
|
+
let fired = false;
|
|
39
|
+
const timer = window.setTimeout(done, maxWaitMs);
|
|
40
|
+
document.addEventListener('fullscreenchange', done);
|
|
41
|
+
function done() {
|
|
42
|
+
if (fired) return;
|
|
43
|
+
fired = true;
|
|
44
|
+
cleanup();
|
|
45
|
+
cb();
|
|
46
|
+
}
|
|
47
|
+
function cleanup() {
|
|
48
|
+
window.clearTimeout(timer);
|
|
49
|
+
document.removeEventListener('fullscreenchange', done);
|
|
50
|
+
}
|
|
51
|
+
return cleanup;
|
|
52
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { usePanelMount } from '@/components/panel/panel-shell';
|
|
3
|
+
import { useLocale } from '@/lib/use-locale';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
|
|
6
|
+
const VISIBLE_MS = 1800;
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
shownAt: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function PresentLastSlideHint({ shownAt }: Props) {
|
|
13
|
+
const t = useLocale();
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!shownAt) return;
|
|
17
|
+
setOpen(true);
|
|
18
|
+
const id = window.setTimeout(() => setOpen(false), VISIBLE_MS);
|
|
19
|
+
return () => window.clearTimeout(id);
|
|
20
|
+
}, [shownAt]);
|
|
21
|
+
const { mounted, animVisible } = usePanelMount(open);
|
|
22
|
+
if (!mounted) return null;
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
role="status"
|
|
26
|
+
className={cn(
|
|
27
|
+
'pointer-events-none absolute bottom-10 left-1/2 z-30 -translate-x-1/2 rounded-full bg-black/70 px-3.5 py-1.5 text-[12px] text-white/85 shadow-lg backdrop-blur-md motion-safe:transition-[opacity,translate]',
|
|
28
|
+
animVisible
|
|
29
|
+
? 'opacity-100 motion-safe:duration-200'
|
|
30
|
+
: 'translate-y-1 opacity-0 motion-safe:duration-200',
|
|
31
|
+
)}
|
|
32
|
+
>
|
|
33
|
+
{t.present.lastSlideHint}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -51,7 +51,7 @@ export function SlideCanvas({
|
|
|
51
51
|
<div ref={containerRef} className={cn('relative h-full w-full', flat && 'overflow-hidden')}>
|
|
52
52
|
<div
|
|
53
53
|
className={cn(
|
|
54
|
-
'overflow-hidden bg-white text-black',
|
|
54
|
+
'overflow-hidden bg-white text-start text-black',
|
|
55
55
|
!flat && 'rounded-[6px] shadow-floating',
|
|
56
56
|
)}
|
|
57
57
|
style={
|
|
@@ -568,7 +568,7 @@ function HorizontalVirtualThumbList({
|
|
|
568
568
|
aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
|
|
569
569
|
aria-current={active ? 'page' : undefined}
|
|
570
570
|
className={cn(
|
|
571
|
-
'group/thumb relative flex shrink-0 flex-col items-center gap-1.5 rounded-[6px] outline-none motion-safe:transition-[scale] motion-safe:duration-100 active:scale-[0.985]',
|
|
571
|
+
'group/thumb relative flex shrink-0 flex-col items-center gap-1.5 rounded-[6px] text-left outline-none motion-safe:transition-[scale] motion-safe:duration-100 active:scale-[0.985]',
|
|
572
572
|
'focus-visible:ring-1 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-sidebar',
|
|
573
573
|
)}
|
|
574
574
|
>
|
package/src/app/routes/home.tsx
CHANGED
|
@@ -323,10 +323,12 @@ function SortControl({ value, onChange }: { value: SortKey; onChange: (next: Sor
|
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
// Offered even before an agent is connected: the new deck opens the agent
|
|
327
|
+
// panel, which walks first-time users through installing one.
|
|
326
328
|
function useCreateDeckWithAgent() {
|
|
327
|
-
const { provider } = useAgentStatus();
|
|
329
|
+
const { enabled, provider } = useAgentStatus();
|
|
328
330
|
const start = useCreateDeck();
|
|
329
|
-
if (!
|
|
331
|
+
if (!enabled) return null;
|
|
330
332
|
return { provider, start };
|
|
331
333
|
}
|
|
332
334
|
|
|
@@ -339,7 +341,11 @@ function NewDeckButton() {
|
|
|
339
341
|
size="sm"
|
|
340
342
|
className="h-8 shrink-0"
|
|
341
343
|
onClick={agent.start}
|
|
342
|
-
title={
|
|
344
|
+
title={
|
|
345
|
+
agent.provider
|
|
346
|
+
? format(t.agent.createDeckWith, { provider: agent.provider.name })
|
|
347
|
+
: t.agent.createDeck
|
|
348
|
+
}
|
|
343
349
|
>
|
|
344
350
|
<Plus />
|
|
345
351
|
{t.agent.createDeck}
|
|
@@ -404,8 +410,10 @@ function EmptyState({ isDraft, folderName }: { isDraft: boolean; folderName?: st
|
|
|
404
410
|
</p>
|
|
405
411
|
{agent ? (
|
|
406
412
|
<Button size="sm" className="mt-4" onClick={agent.start}>
|
|
407
|
-
<ProviderLogo provider={agent.provider.id} />
|
|
408
|
-
{
|
|
413
|
+
{agent.provider ? <ProviderLogo provider={agent.provider.id} /> : <Plus />}
|
|
414
|
+
{agent.provider
|
|
415
|
+
? format(t.agent.createDeckWith, { provider: agent.provider.name })
|
|
416
|
+
: t.agent.createDeck}
|
|
409
417
|
</Button>
|
|
410
418
|
) : (
|
|
411
419
|
<p className="mt-1.5 text-[13px] leading-relaxed text-muted-foreground">
|
package/src/app/routes/slide.tsx
CHANGED
|
@@ -87,6 +87,12 @@ import { PdfProgressToast, PptxProgressToast } from '../components/export-progre
|
|
|
87
87
|
import { NotesDrawer } from '../components/notes-drawer';
|
|
88
88
|
import { OverviewGrid } from '../components/overview-grid';
|
|
89
89
|
import { openPresenterWindow, Player } from '../components/player';
|
|
90
|
+
import {
|
|
91
|
+
afterPaint,
|
|
92
|
+
CURTAIN_FADE_MS,
|
|
93
|
+
PresentCurtain,
|
|
94
|
+
whenFullscreenSettled,
|
|
95
|
+
} from '../components/present/curtain';
|
|
90
96
|
import { SlideCanvas } from '../components/slide-canvas';
|
|
91
97
|
import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/slide-preload-layer';
|
|
92
98
|
import { SlideTransitionLayer } from '../components/slide-transition-layer';
|
|
@@ -166,6 +172,55 @@ export function Slide() {
|
|
|
166
172
|
const narrowToolbar = useMediaQuery('(max-width: 639.98px)');
|
|
167
173
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
168
174
|
|
|
175
|
+
// 'entering' darkens the editor before the Player mounts; 'leaving' keeps
|
|
176
|
+
// the editor dark after the Player unmounts, then fades it back in.
|
|
177
|
+
const [curtain, setCurtain] = useState<'entering' | 'leaving' | null>(null);
|
|
178
|
+
const curtainTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
179
|
+
useEffect(
|
|
180
|
+
() => () => {
|
|
181
|
+
if (curtainTimerRef.current) clearTimeout(curtainTimerRef.current);
|
|
182
|
+
},
|
|
183
|
+
[],
|
|
184
|
+
);
|
|
185
|
+
const present = useCallback(
|
|
186
|
+
(mode: 'window' | 'fullscreen') => {
|
|
187
|
+
if (prefersReducedMotion) {
|
|
188
|
+
setPlayMode(mode);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (curtainTimerRef.current) return;
|
|
192
|
+
setCurtain('entering');
|
|
193
|
+
// Fullscreen is requested when the Player mounts; the delay stays well
|
|
194
|
+
// inside the browser's transient user-activation window.
|
|
195
|
+
curtainTimerRef.current = setTimeout(() => {
|
|
196
|
+
curtainTimerRef.current = null;
|
|
197
|
+
setCurtain(null);
|
|
198
|
+
setPlayMode(mode);
|
|
199
|
+
}, CURTAIN_FADE_MS);
|
|
200
|
+
},
|
|
201
|
+
[prefersReducedMotion],
|
|
202
|
+
);
|
|
203
|
+
const exitPresent = useCallback(() => {
|
|
204
|
+
setPlayMode(null);
|
|
205
|
+
if (!prefersReducedMotion) setCurtain('leaving');
|
|
206
|
+
}, [prefersReducedMotion]);
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
if (curtain !== 'leaving' || playMode) return;
|
|
209
|
+
let cancelPaint = () => {};
|
|
210
|
+
const reveal = () => {
|
|
211
|
+
cancelPaint = afterPaint(() => setCurtain(null));
|
|
212
|
+
};
|
|
213
|
+
if (!document.fullscreenElement) {
|
|
214
|
+
reveal();
|
|
215
|
+
return () => cancelPaint();
|
|
216
|
+
}
|
|
217
|
+
const cancelWait = whenFullscreenSettled(reveal);
|
|
218
|
+
return () => {
|
|
219
|
+
cancelWait();
|
|
220
|
+
cancelPaint();
|
|
221
|
+
};
|
|
222
|
+
}, [curtain, playMode]);
|
|
223
|
+
|
|
169
224
|
const modulePages = useMemo(() => slide?.default ?? [], [slide]);
|
|
170
225
|
const [pages, setPages] = useState<typeof modulePages>(modulePages);
|
|
171
226
|
useEffect(() => {
|
|
@@ -335,7 +390,7 @@ export function Slide() {
|
|
|
335
390
|
// When showSlideUi is false the read-only <Player> is rendered and owns
|
|
336
391
|
// keyboard navigation (including step-aware advance/retreat). Attaching this
|
|
337
392
|
// page-nav handler too would race it and skip <Steps> reveals, so bail out.
|
|
338
|
-
if (playMode || !showSlideUi) return;
|
|
393
|
+
if (playMode || curtain || !showSlideUi) return;
|
|
339
394
|
const onKey = (e: KeyboardEvent) => {
|
|
340
395
|
if (
|
|
341
396
|
isTypingTarget(e.target) ||
|
|
@@ -368,12 +423,12 @@ export function Slide() {
|
|
|
368
423
|
return;
|
|
369
424
|
}
|
|
370
425
|
if (e.key === 'f' || e.key === 'F') {
|
|
371
|
-
|
|
426
|
+
present('fullscreen');
|
|
372
427
|
} else if (e.key === 'Enter') {
|
|
373
|
-
|
|
428
|
+
present('window');
|
|
374
429
|
} else if (e.key === 'p' || e.key === 'P') {
|
|
375
430
|
if (slideId) openPresenterWindow(slideId);
|
|
376
|
-
|
|
431
|
+
present('window');
|
|
377
432
|
} else if (import.meta.env.DEV && (e.key === 'd' || e.key === 'D')) {
|
|
378
433
|
setDesignOpen((v) => !v);
|
|
379
434
|
} else if (import.meta.env.DEV && (e.key === 'a' || e.key === 'A')) {
|
|
@@ -382,7 +437,7 @@ export function Slide() {
|
|
|
382
437
|
};
|
|
383
438
|
window.addEventListener('keydown', onKey);
|
|
384
439
|
return () => window.removeEventListener('keydown', onKey);
|
|
385
|
-
}, [index, goTo, playMode, slideId, overviewOpen, toggleAgent]);
|
|
440
|
+
}, [index, goTo, playMode, curtain, slideId, overviewOpen, toggleAgent, present]);
|
|
386
441
|
|
|
387
442
|
if (error) {
|
|
388
443
|
return (
|
|
@@ -423,8 +478,9 @@ export function Slide() {
|
|
|
423
478
|
transition={presented.slide.transition}
|
|
424
479
|
index={presented.index}
|
|
425
480
|
onIndexChange={presentReady ? goTo : noop}
|
|
426
|
-
onExit={
|
|
481
|
+
onExit={exitPresent}
|
|
427
482
|
controls
|
|
483
|
+
curtain={!prefersReducedMotion}
|
|
428
484
|
slideId={presented.slideId}
|
|
429
485
|
onSwitchSlide={switchPresentedSlide}
|
|
430
486
|
fullscreen={playMode === 'fullscreen'}
|
|
@@ -801,7 +857,7 @@ export function Slide() {
|
|
|
801
857
|
size="sm"
|
|
802
858
|
variant="brand"
|
|
803
859
|
aria-label={t.slide.present}
|
|
804
|
-
onClick={() =>
|
|
860
|
+
onClick={() => present(isMobile ? 'window' : 'fullscreen')}
|
|
805
861
|
className="rounded-r-none px-2.5 lg:px-3"
|
|
806
862
|
>
|
|
807
863
|
<Play className="size-3.5 fill-current" />
|
|
@@ -821,12 +877,12 @@ export function Slide() {
|
|
|
821
877
|
</DropdownMenuTrigger>
|
|
822
878
|
<DropdownMenuContent align="end" className="min-w-[200px]">
|
|
823
879
|
<DropdownMenuGroup>
|
|
824
|
-
<DropdownMenuItem onClick={() =>
|
|
880
|
+
<DropdownMenuItem onClick={() => present('window')}>
|
|
825
881
|
<Play />
|
|
826
882
|
{t.slide.presentInWindow}
|
|
827
883
|
<DropdownMenuShortcut>↵</DropdownMenuShortcut>
|
|
828
884
|
</DropdownMenuItem>
|
|
829
|
-
<DropdownMenuItem onClick={() =>
|
|
885
|
+
<DropdownMenuItem onClick={() => present('fullscreen')}>
|
|
830
886
|
<Maximize />
|
|
831
887
|
{t.slide.presentFullscreen}
|
|
832
888
|
<DropdownMenuShortcut>F</DropdownMenuShortcut>
|
|
@@ -834,7 +890,7 @@ export function Slide() {
|
|
|
834
890
|
<DropdownMenuItem
|
|
835
891
|
onClick={() => {
|
|
836
892
|
if (slideId) openPresenterWindow(slideId);
|
|
837
|
-
|
|
893
|
+
present('window');
|
|
838
894
|
}}
|
|
839
895
|
>
|
|
840
896
|
<MonitorSpeaker />
|
|
@@ -957,11 +1013,11 @@ export function Slide() {
|
|
|
957
1013
|
currentIndex={index}
|
|
958
1014
|
exporting={exporting}
|
|
959
1015
|
handlers={{
|
|
960
|
-
onPresentWindow: () =>
|
|
961
|
-
onPresentFullscreen: () =>
|
|
1016
|
+
onPresentWindow: () => present('window'),
|
|
1017
|
+
onPresentFullscreen: () => present('fullscreen'),
|
|
962
1018
|
onPresenterView: () => {
|
|
963
1019
|
if (slideId) openPresenterWindow(slideId);
|
|
964
|
-
|
|
1020
|
+
present('window');
|
|
965
1021
|
},
|
|
966
1022
|
onCopyLink: copyLink,
|
|
967
1023
|
onOverview: () => setOverviewOpen(true),
|
|
@@ -976,6 +1032,7 @@ export function Slide() {
|
|
|
976
1032
|
/>
|
|
977
1033
|
)}
|
|
978
1034
|
</div>
|
|
1035
|
+
<PresentCurtain opaque={curtain !== null} className="fixed z-[1000]" />
|
|
979
1036
|
</InspectorProvider>
|
|
980
1037
|
</HistoryProvider>
|
|
981
1038
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const UNTITLED_SLIDE_ID_RE = /^untitled(-\d+)?$/;
|
package/src/locale/en.ts
CHANGED
|
@@ -178,6 +178,7 @@ export const en: Locale = {
|
|
|
178
178
|
helpAria: 'Keyboard shortcuts (?)',
|
|
179
179
|
exitAria: 'Exit (Esc)',
|
|
180
180
|
elapsedTime: 'Elapsed time',
|
|
181
|
+
lastSlideHint: 'Last slide · Press Esc to exit',
|
|
181
182
|
helpEyebrow: 'Present mode',
|
|
182
183
|
helpTitle: 'Keyboard shortcuts',
|
|
183
184
|
shortcutNext: 'Next slide',
|
package/src/locale/es.ts
CHANGED
|
@@ -180,6 +180,7 @@ export const es: Locale = {
|
|
|
180
180
|
helpAria: 'Atajos de teclado (?)',
|
|
181
181
|
exitAria: 'Salir (Esc)',
|
|
182
182
|
elapsedTime: 'Tiempo transcurrido',
|
|
183
|
+
lastSlideHint: 'Última diapositiva · Pulsa Esc para salir',
|
|
183
184
|
helpEyebrow: 'Modo presentación',
|
|
184
185
|
helpTitle: 'Atajos de teclado',
|
|
185
186
|
shortcutNext: 'Diapositiva siguiente',
|
package/src/locale/ja.ts
CHANGED
package/src/locale/types.ts
CHANGED
package/src/locale/zh-cn.ts
CHANGED
package/src/locale/zh-tw.ts
CHANGED