Skip to content

Commit 44eb1b0

Browse files
committed
fix(web): improve mobile terminal paste UX and layout
- Add comprehensive error handling and user feedback for paste operation - Display toast notifications for clipboard errors, permission issues, and empty clipboard - Reduce spacing in mobile terminal input bar to prevent overflow - Adjust gap, padding values to fit all buttons within screen width
1 parent 008d2ce commit 44eb1b0

2 files changed

Lines changed: 47 additions & 14 deletions

File tree

packages/web/src/features/terminal-panel/uploads/use-paste-drop-upload.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ export function usePasteDropUpload(opts: Options): PasteDropUploadActions {
121121

122122
const clipboard = navigator.clipboard;
123123
if (!clipboard) {
124+
pushToast({
125+
kind: "error",
126+
title: "Paste failed",
127+
body: "Clipboard API not available",
128+
duration: 3_000,
129+
});
124130
return;
125131
}
126132

@@ -146,17 +152,44 @@ export function usePasteDropUpload(opts: Options): PasteDropUploadActions {
146152
return;
147153
}
148154
}
149-
} catch {
155+
} catch (error) {
150156
// Fall back to text read below when image clipboard access is unsupported.
157+
console.debug("Clipboard image read failed, trying text:", error);
151158
}
152159

153-
const readText = clipboard.readText?.bind(clipboard);
154-
if (!readText) {
155-
return;
156-
}
160+
try {
161+
const readText = clipboard.readText?.bind(clipboard);
162+
if (!readText) {
163+
pushToast({
164+
kind: "error",
165+
title: "Paste failed",
166+
body: "Clipboard text read not available",
167+
duration: 3_000,
168+
});
169+
return;
170+
}
157171

158-
await handleText(await readText());
159-
}, [enabled, handleFiles, handleText]);
172+
const text = await readText();
173+
if (!text) {
174+
pushToast({
175+
kind: "info",
176+
title: "Paste",
177+
body: "Clipboard is empty",
178+
duration: 2_000,
179+
});
180+
return;
181+
}
182+
183+
await handleText(text);
184+
} catch (_error) {
185+
pushToast({
186+
kind: "error",
187+
title: "Paste failed",
188+
body: "Could not read from clipboard. Please check permissions.",
189+
duration: 3_000,
190+
});
191+
}
192+
}, [enabled, handleFiles, handleText, pushToast]);
160193

161194
useEffect(() => {
162195
const element = containerRef.current;

packages/web/src/styles/components.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,10 +1354,10 @@
13541354
.mobile-terminal-input-bar {
13551355
display: flex;
13561356
align-items: center;
1357-
gap: 6px;
1357+
gap: 4px;
13581358
flex-shrink: 0;
13591359
min-width: 0;
1360-
padding: 2px var(--sp-3) 2px;
1360+
padding: 2px var(--sp-2) 2px;
13611361
border-top: 1px solid color-mix(in srgb, var(--border) 36%, transparent);
13621362
border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
13631363
background: color-mix(in srgb, var(--bg-page) 90%, var(--bg-surface) 10%);
@@ -1367,8 +1367,8 @@
13671367
display: flex;
13681368
flex: 0 0 auto;
13691369
align-items: center;
1370-
gap: 4px;
1371-
padding-right: 6px;
1370+
gap: 3px;
1371+
padding-right: 4px;
13721372
border-right: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
13731373
}
13741374

@@ -1378,7 +1378,7 @@
13781378
justify-content: center;
13791379
flex: 0 0 auto;
13801380
min-height: 20px;
1381-
padding: 0 7px;
1381+
padding: 0 6px;
13821382
border: 1px solid color-mix(in srgb, var(--border) 74%, transparent);
13831383
border-radius: 3px;
13841384
background: color-mix(in srgb, var(--bg-page) 70%, var(--bg-surface) 30%);
@@ -1397,7 +1397,7 @@
13971397
min-width: 0;
13981398
flex: 1 1 auto;
13991399
justify-content: flex-start;
1400-
gap: 3px;
1400+
gap: 2px;
14011401
overflow-x: auto;
14021402
padding: 0;
14031403
border: none;
@@ -1418,7 +1418,7 @@
14181418
flex: 0 0 auto;
14191419
min-width: 0;
14201420
min-height: 20px;
1421-
padding: 0 6px;
1421+
padding: 0 5px;
14221422
border: 1px solid color-mix(in srgb, var(--border) 74%, transparent);
14231423
border-radius: 3px;
14241424
background: color-mix(in srgb, var(--bg-page) 74%, var(--bg-surface) 26%);

0 commit comments

Comments
 (0)