Skip to content

Commit 602b2b5

Browse files
committed
feat(Map): enhance fullscreen handling with ChatGPT host integration
- Updated handleExpand and handleCollapse functions to request fullscreen and inline modes from the ChatGPT host. - Added error handling for fullscreen requests to improve user experience and debugging. This change allows the Map component to better integrate with the ChatGPT environment, providing a smoother user experience when toggling display modes.
1 parent e0d5bb9 commit 602b2b5

File tree

1 file changed

+20
-2
lines changed
  • packages/ui/src/components/Map

1 file changed

+20
-2
lines changed

packages/ui/src/components/Map/Map.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,32 @@ export const Map: React.FC<MapProps> = ({
7373
const isControlled = controlledIsFullscreen !== undefined;
7474
const isFullscreen = isControlled ? controlledIsFullscreen : internalIsFullscreen;
7575

76-
const handleExpand = () => {
76+
const handleExpand = async () => {
77+
// Request fullscreen mode from ChatGPT host
78+
if (window.openai?.requestDisplayMode) {
79+
try {
80+
await window.openai.requestDisplayMode({ mode: 'fullscreen' });
81+
} catch (error) {
82+
console.warn('Failed to request fullscreen mode:', error);
83+
}
84+
}
85+
7786
if (!isControlled) {
7887
setInternalIsFullscreen(true);
7988
}
8089
onToggleFullscreen?.(true);
8190
};
8291

83-
const handleCollapse = () => {
92+
const handleCollapse = async () => {
93+
// Request inline mode from ChatGPT host
94+
if (window.openai?.requestDisplayMode) {
95+
try {
96+
await window.openai.requestDisplayMode({ mode: 'inline' });
97+
} catch (error) {
98+
console.warn('Failed to request inline mode:', error);
99+
}
100+
}
101+
84102
if (!isControlled) {
85103
setInternalIsFullscreen(false);
86104
}

0 commit comments

Comments
 (0)