From d9956e60ebd92d78ffde075c2367135f690aedd3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 3 Oct 2025 23:53:10 -0500 Subject: [PATCH 1/2] Accept options object in JSRuntimeFS --- src/lib/JSRuntime.ts | 10 ++++++---- src/lib/LightningFSAdapter.ts | 14 +++++++++----- src/lib/ProjectsManager.test.ts | 10 +++++++--- src/lib/fileUtils.test.ts | 12 ++++++++---- src/lib/tmpCleanup.test.ts | 12 ++++++++---- src/lib/tools/TextEditorStrReplaceTool.test.ts | 13 ++++++++----- src/lib/tools/TextEditorViewTool.test.ts | 13 ++++++++----- src/lib/tools/TextEditorWriteTool.test.ts | 13 ++++++++----- 8 files changed, 62 insertions(+), 35 deletions(-) diff --git a/src/lib/JSRuntime.ts b/src/lib/JSRuntime.ts index 349d789c..54aefebd 100644 --- a/src/lib/JSRuntime.ts +++ b/src/lib/JSRuntime.ts @@ -5,11 +5,13 @@ export interface JSRuntimeFS { // Core file operations with proper overloads for type safety readFile(path: string): Promise; - readFile(path: string, encoding: 'utf8'): Promise; - readFile(path: string, encoding: string): Promise; - readFile(path: string, encoding?: string): Promise; + readFile(path: string, options: 'utf8'): Promise; + readFile(path: string, options: string): Promise; + readFile(path: string, options: { encoding: 'utf8' }): Promise; + readFile(path: string, options: { encoding: string }): Promise; + readFile(path: string, options?: string | { encoding?: string }): Promise; - writeFile(path: string, data: string | Uint8Array, encoding?: string): Promise; + writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise; // readdir overloads for different return types readdir(path: string): Promise; diff --git a/src/lib/LightningFSAdapter.ts b/src/lib/LightningFSAdapter.ts index 77dfedfb..413944b6 100644 --- a/src/lib/LightningFSAdapter.ts +++ b/src/lib/LightningFSAdapter.ts @@ -9,14 +9,18 @@ export class LightningFSAdapter implements JSRuntimeFS { constructor(private lightningFS: LightningFS.PromisifiedFS) {} async readFile(path: string): Promise; - async readFile(path: string, encoding: 'utf8'): Promise; - async readFile(path: string, encoding: string): Promise; - async readFile(path: string, encoding?: string): Promise; - async readFile(path: string, encoding?: string): Promise { + async readFile(path: string, options: 'utf8'): Promise; + async readFile(path: string, options: string): Promise; + async readFile(path: string, options: { encoding: 'utf8' }): Promise; + async readFile(path: string, options: { encoding: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise { + const encoding = typeof options === 'string' ? options : options?.encoding; return this.lightningFS.readFile(path, encoding); } - async writeFile(path: string, data: string | Uint8Array, encoding?: string): Promise { + async writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise { + const encoding = typeof options === 'string' ? options : options?.encoding; return this.lightningFS.writeFile(path, data, encoding); } diff --git a/src/lib/ProjectsManager.test.ts b/src/lib/ProjectsManager.test.ts index 5e43cf2a..22b59ea6 100644 --- a/src/lib/ProjectsManager.test.ts +++ b/src/lib/ProjectsManager.test.ts @@ -41,15 +41,19 @@ class MockFS implements JSRuntimeFS { private dirs: Set = new Set(); async readFile(path: string): Promise; - async readFile(path: string, encoding: "utf8"): Promise; - async readFile(path: string, encoding: string): Promise; - async readFile(path: string, encoding?: string): Promise { + async readFile(path: string, options: 'utf8'): Promise; + async readFile(path: string, options: string): Promise; + async readFile(path: string, options: { encoding: 'utf8' }): Promise; + async readFile(path: string, options: { encoding: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise { const content = this.files.get(path); if (content === undefined) { const error = new Error(`ENOENT: no such file or directory, open '${path}'`) as NodeJS.ErrnoException; error.code = 'ENOENT'; throw error; } + const encoding = typeof options === 'string' ? options : options?.encoding; if (encoding === 'utf8') { if (typeof content === 'string') { return content; diff --git a/src/lib/fileUtils.test.ts b/src/lib/fileUtils.test.ts index e75495e1..801fe30d 100644 --- a/src/lib/fileUtils.test.ts +++ b/src/lib/fileUtils.test.ts @@ -13,12 +13,16 @@ class MockFS implements JSRuntimeFS { } async readFile(path: string): Promise; - async readFile(path: string, encoding: 'utf8'): Promise; - async readFile(path: string, encoding: string): Promise; - async readFile(path: string, encoding?: string): Promise { + async readFile(path: string, options: 'utf8'): Promise; + async readFile(path: string, options: string): Promise; + async readFile(path: string, options: { encoding: 'utf8' }): Promise; + async readFile(path: string, options: { encoding: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise { const data = this.files.get(path); if (!data) throw new Error(`File not found: ${path}`); + const encoding = typeof options === 'string' ? options : options?.encoding; if (encoding === 'utf8') { return typeof data === 'string' ? data : new TextDecoder().decode(data); } @@ -26,7 +30,7 @@ class MockFS implements JSRuntimeFS { return data; } - async writeFile(path: string, data: string | Uint8Array): Promise { + async writeFile(path: string, data: string | Uint8Array, _options?: string | { encoding?: string }): Promise { this.files.set(path, data); } diff --git a/src/lib/tmpCleanup.test.ts b/src/lib/tmpCleanup.test.ts index 9ba27c96..eabf2f42 100644 --- a/src/lib/tmpCleanup.test.ts +++ b/src/lib/tmpCleanup.test.ts @@ -26,15 +26,19 @@ class MockFS implements JSRuntimeFS { } async readFile(path: string): Promise; - async readFile(path: string, encoding: 'utf8'): Promise; - async readFile(path: string, encoding: string): Promise; - async readFile(path: string, encoding?: string): Promise { + async readFile(path: string, options: 'utf8'): Promise; + async readFile(path: string, options: string): Promise; + async readFile(path: string, options: { encoding: 'utf8' }): Promise; + async readFile(path: string, options: { encoding: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise { const file = this.files.get(path); if (!file || file.isDir) throw new Error(`File not found: ${path}`); + const encoding = typeof options === 'string' ? options : options?.encoding; return encoding === 'utf8' ? file.content.toString() : new Uint8Array(); } - async writeFile(path: string, data: string | Uint8Array): Promise { + async writeFile(path: string, data: string | Uint8Array, _options?: string | { encoding?: string }): Promise { this.files.set(path, { content: data, mtimeMs: Date.now(), isDir: false }); } diff --git a/src/lib/tools/TextEditorStrReplaceTool.test.ts b/src/lib/tools/TextEditorStrReplaceTool.test.ts index 3b7df782..b439282d 100644 --- a/src/lib/tools/TextEditorStrReplaceTool.test.ts +++ b/src/lib/tools/TextEditorStrReplaceTool.test.ts @@ -14,18 +14,21 @@ class MockFS implements JSRuntimeFS { } async readFile(path: string): Promise; - async readFile(path: string, encoding: 'utf8'): Promise; - async readFile(path: string, encoding: string): Promise; - async readFile(path: string, encoding?: string): Promise; - async readFile(path: string, encoding?: string): Promise { + async readFile(path: string, options: 'utf8'): Promise; + async readFile(path: string, options: string): Promise; + async readFile(path: string, options: { encoding: 'utf8' }): Promise; + async readFile(path: string, options: { encoding: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise { const content = this.files.get(path); if (content === undefined) { throw new Error(`File not found: ${path}`); } + const encoding = typeof options === 'string' ? options : options?.encoding; return encoding ? content : new TextEncoder().encode(content); } - async writeFile(path: string, data: string | Uint8Array, _encoding?: string): Promise { + async writeFile(path: string, data: string | Uint8Array, _options?: string | { encoding?: string }): Promise { const content = typeof data === 'string' ? data : new TextDecoder().decode(data); this.files.set(path, content); } diff --git a/src/lib/tools/TextEditorViewTool.test.ts b/src/lib/tools/TextEditorViewTool.test.ts index 03e81b73..eddabc93 100644 --- a/src/lib/tools/TextEditorViewTool.test.ts +++ b/src/lib/tools/TextEditorViewTool.test.ts @@ -41,15 +41,18 @@ class MockFS implements JSRuntimeFS { } async readFile(path: string): Promise; - async readFile(path: string, encoding: 'utf8'): Promise; - async readFile(path: string, encoding: string): Promise; - async readFile(path: string, encoding?: string): Promise; - async readFile(path: string, encoding?: string): Promise { + async readFile(path: string, options: 'utf8'): Promise; + async readFile(path: string, options: string): Promise; + async readFile(path: string, options: { encoding: 'utf8' }): Promise; + async readFile(path: string, options: { encoding: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise { const content = this.files.get(path); if (content === undefined) { throw new Error(`File not found: ${path}`); } + const encoding = typeof options === 'string' ? options : options?.encoding; // If no encoding specified, return Uint8Array if (!encoding) { // For binary files, return mock binary data with null bytes @@ -70,7 +73,7 @@ class MockFS implements JSRuntimeFS { return content; } - async writeFile(path: string, data: string | Uint8Array, _encoding?: string): Promise { + async writeFile(path: string, data: string | Uint8Array, _options?: string | { encoding?: string }): Promise { const content = typeof data === 'string' ? data : new TextDecoder().decode(data); this.files.set(path, content); } diff --git a/src/lib/tools/TextEditorWriteTool.test.ts b/src/lib/tools/TextEditorWriteTool.test.ts index 34c1ffc9..17169b4f 100644 --- a/src/lib/tools/TextEditorWriteTool.test.ts +++ b/src/lib/tools/TextEditorWriteTool.test.ts @@ -13,18 +13,21 @@ class MockFS implements JSRuntimeFS { } async readFile(path: string): Promise; - async readFile(path: string, encoding: 'utf8'): Promise; - async readFile(path: string, encoding: string): Promise; - async readFile(path: string, encoding?: string): Promise; - async readFile(path: string, encoding?: string): Promise { + async readFile(path: string, options: 'utf8'): Promise; + async readFile(path: string, options: string): Promise; + async readFile(path: string, options: { encoding: 'utf8' }): Promise; + async readFile(path: string, options: { encoding: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise; + async readFile(path: string, options?: string | { encoding?: string }): Promise { const content = this.files.get(path); if (content === undefined) { throw new Error(`File not found: ${path}`); } + const encoding = typeof options === 'string' ? options : options?.encoding; return encoding ? content : new TextEncoder().encode(content); } - async writeFile(path: string, data: string | Uint8Array, _encoding?: string): Promise { + async writeFile(path: string, data: string | Uint8Array, _options?: string | { encoding?: string }): Promise { const content = typeof data === 'string' ? data : new TextDecoder().decode(data); this.files.set(path, content); } From 4e163a032f8d306a88b5fa90e8c7119a4e428256 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 3 Oct 2025 23:53:33 -0500 Subject: [PATCH 2/2] Safe area inset improvements --- package-lock.json | 16 +++ package.json | 1 + src/components/AppLayout.tsx | 28 ++-- src/components/CreditsDialog.tsx | 2 +- src/components/OnboardingDialog.tsx | 10 +- src/components/ProjectSidebar.tsx | 64 ++++----- src/components/SettingsLayout.tsx | 6 +- src/components/Shakespeare/PreviewPane.tsx | 144 ++++++++++----------- src/components/ui/toast.tsx | 2 +- src/index.css | 19 +-- src/pages/ProjectView.tsx | 94 +++++++------- 11 files changed, 201 insertions(+), 185 deletions(-) diff --git a/package-lock.json b/package-lock.json index e2fec05c..8aea64c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,6 +79,7 @@ "streamdown": "~1.0.0", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", + "tailwindcss-safe-area": "^0.8.0", "turndown": "^7.2.1", "uri-templates": "^0.2.0", "use-stick-to-bottom": "^1.1.1", @@ -10092,6 +10093,21 @@ "tailwindcss": ">=3.0.0 || insiders" } }, + "node_modules/tailwindcss-safe-area": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/tailwindcss-safe-area/-/tailwindcss-safe-area-0.8.0.tgz", + "integrity": "sha512-OIKZfSvinI9kZ3hduoSxqP8EfW2rXoKvHnNyTDY2zwem06IIRtLcKdMe0nF98o+Xluk5Fy7mmesr1rSXg/wkhA==", + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/mvllow" + }, + "peerDependencies": { + "tailwindcss": "^2.0.0 || >=3.0.0" + } + }, "node_modules/tailwindcss/node_modules/postcss-selector-parser": { "version": "6.1.2", "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", diff --git a/package.json b/package.json index 8761be75..cfb24d13 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "streamdown": "~1.0.0", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", + "tailwindcss-safe-area": "^0.8.0", "turndown": "^7.2.1", "uri-templates": "^0.2.0", "use-stick-to-bottom": "^1.1.1", diff --git a/src/components/AppLayout.tsx b/src/components/AppLayout.tsx index cc9552ed..69311d9a 100644 --- a/src/components/AppLayout.tsx +++ b/src/components/AppLayout.tsx @@ -72,20 +72,22 @@ export function AppLayout({ return (
{/* Mobile Header */} -
-
- {showSidebar && ( - - )} +
+
+
+ {showSidebar && ( + + )} +
+ {headerContent}
- {headerContent}
{/* Mobile Sidebar Overlay - show if showSidebar is true and sidebar is visible */} diff --git a/src/components/CreditsDialog.tsx b/src/components/CreditsDialog.tsx index 8b4de085..a9ac5295 100644 --- a/src/components/CreditsDialog.tsx +++ b/src/components/CreditsDialog.tsx @@ -399,7 +399,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro return ( - e.preventDefault()} className="max-w-lg w-full max-h-[75vh] overflow-hidden flex flex-col sm:max-w-lg sm:max-h-[75vh] max-sm:w-full max-sm:h-full max-sm:max-w-none max-sm:max-h-none max-sm:m-0 max-sm:rounded-none"> + e.preventDefault()} className="max-w-lg w-full max-h-[75vh] overflow-hidden flex flex-col sm:max-w-lg sm:max-h-[75vh] max-sm:w-full max-sm:h-dvh-safe max-sm:max-w-none max-sm:max-h-none max-sm:m-0 max-sm:rounded-none"> {lightningInvoice ? ( diff --git a/src/components/OnboardingDialog.tsx b/src/components/OnboardingDialog.tsx index ba098e24..1ab8e51e 100644 --- a/src/components/OnboardingDialog.tsx +++ b/src/components/OnboardingDialog.tsx @@ -171,7 +171,7 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps) return ( <> - + {step === 'open-source' && ( @@ -275,13 +275,15 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps) {step === 'open-source' && (
-

Shakespeare is Open Source software that runs entirely in your web browser

+

+ Shakespeare is Open Source software that runs entirely in your web browser +

-

Your browser connects directly to third-party AI providers of your choice

+

Your device connects directly to third-party AI providers of your choice

@@ -303,7 +305,7 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)

- Shakespeare is not a cloud service. It's Open Source software that runs in your web browser. + Shakespeare is not a cloud service. It's Open Source software that runs on your device. You agree to the Terms of Service of AI providers you interact with. Shakespeare is provided "as is" without warranty of any kind.

diff --git a/src/components/ProjectSidebar.tsx b/src/components/ProjectSidebar.tsx index ec800bc0..03022f82 100644 --- a/src/components/ProjectSidebar.tsx +++ b/src/components/ProjectSidebar.tsx @@ -131,34 +131,36 @@ export function ProjectSidebar({ return (
{/* Header with Logo */} -
-
- - {(onToggleSidebar || (onClose && isMobile)) && ( -
- -
- )} +
+
+
+ + {(onToggleSidebar || (onClose && isMobile)) && ( +
+ +
+ )} +
@@ -229,8 +231,8 @@ export function ProjectSidebar({
{/* Settings and Help at Bottom */} -
-
+
+
- -
); } \ No newline at end of file diff --git a/src/components/SettingsLayout.tsx b/src/components/SettingsLayout.tsx index 6cf9ea0c..ba1fe434 100644 --- a/src/components/SettingsLayout.tsx +++ b/src/components/SettingsLayout.tsx @@ -120,10 +120,10 @@ export function SettingsLayout() { if (isMobile) { return ( -
+
{/* Mobile Header */} -
-
+
+
+ )} + + +
+ )} + /> +
+ + {/* Content area */} +
+ {hasBuiltProject ? ( +