Skip to content

Commit c9e31fe

Browse files
committed
feat(desktop): make the fallback command scrollable and copyable
The command block is a pre, whose default white-space forbade wrapping, so it simply ran off the dialog. It now stays on one line and scrolls horizontally, which keeps a shell command readable and verbatim rather than folded. Selection is enabled explicitly because _base.scss turns it off on body to make the chrome behave like a native app's, opting only inputs back in -- without that, a command the user must run by hand could not even be selected. A copy button beside it awaits the clipboard write before reporting success, since this is the one command someone reaches for because an install already failed.
1 parent 682d00d commit c9e31fe

4 files changed

Lines changed: 77 additions & 5 deletions

File tree

‎apps/desktop/src/renderer/systems/appUpdate/ui/UpdateAvailableDialog.scss‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
color: var(--sk-color-label-2);
2424
font-family: var(--sk-font-mono, monospace);
2525
overflow-wrap: anywhere;
26+
// Selectable for the same reason as the command block below: it is a path the
27+
// user may need to hand to a shell or a Finder window.
28+
user-select: text;
29+
-webkit-user-select: text;
2630
}
2731

2832
// A local exception to Modal's rule that a dialog never scrolls internally:
@@ -53,15 +57,44 @@
5357
margin-top: var(--sk-space-3);
5458
}
5559

56-
.sk-update-fallback-command {
60+
.sk-update-fallback-command-row {
61+
display: flex;
62+
align-items: flex-start;
63+
gap: var(--sk-space-2);
5764
margin: var(--sk-space-2) 0 0;
65+
}
66+
67+
// Kept on ONE line and scrolled horizontally rather than wrapped. A wrapped
68+
// shell command is harder to read and harder to retype correctly, and the
69+
// whole point of this block is that the user runs it verbatim. `min-width: 0`
70+
// is what lets the flex child actually shrink far enough for the scroll to
71+
// engage instead of widening the dialog.
72+
//
73+
// `user-select` is not redundant: `_base.scss` sets `user-select: none` on
74+
// `body` so the app's chrome behaves like a native app's, and opts only
75+
// inputs back in. Without this the user could not select the command at all,
76+
// which for a command they must run by hand is the difference between a
77+
// usable instruction and a picture of one.
78+
.sk-update-fallback-command {
79+
flex: 1 1 auto;
80+
min-width: 0;
81+
margin: 0;
5882
padding: var(--sk-space-3);
5983
border-radius: var(--sk-radius-sm);
6084
background: var(--sk-color-bg-secondary);
6185
font-family: var(--sk-font-mono, monospace);
6286
font-size: 12px;
6387
line-height: 1.5;
64-
overflow-wrap: anywhere;
88+
white-space: pre;
89+
overflow-x: auto;
90+
user-select: text;
91+
-webkit-user-select: text;
92+
}
93+
94+
// Fixed-size so the wrapped command text (flex: 1 1 auto, min-width: 0 above)
95+
// never squeezes it out of view at a narrow dialog width.
96+
.sk-update-fallback-copy {
97+
flex: none;
6598
}
6699

67100
.sk-update-actions {

‎apps/desktop/src/renderer/systems/appUpdate/ui/UpdateReadyDialog.stories.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export default meta;
1313
type Story = StoryObj<typeof UpdateReadyDialog>;
1414

1515
const OFFER = makeAppUpdateOffer();
16-
const PATH = '/Applications/SkillKeeper-0.7.0.dmg';
16+
// Matches the fixture offer's version, and points where a DOWNLOADED artifact
17+
// actually lands (the app-data `update/` directory), not at /Applications --
18+
// an earlier value said 0.7.0 under /Applications above a body reading 1.4.2,
19+
// which is a state the app can never be in.
20+
const PATH = '/Users/you/.config/skillkeeper/update/SkillKeeper_1.4.2_aarch64.dmg';
1721

1822
export const Default: Story = {
1923
render: () => {

‎apps/desktop/src/renderer/systems/appUpdate/ui/UpdateReadyDialog.tsx‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
* again" button takes its place instead -- the fallback command above (when
3232
* shown) is unaffected either way, since it names no downloaded file.
3333
*/
34-
import { Modal, Button } from '@/shared/ui';
34+
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
35+
import { Modal, Button, Icon } from '@/shared/ui';
3536
import { useSkillkeeperStore } from '@/app/store';
3637
import { useTranslator } from '@/systems/i18n';
3738
import { bridgeClient } from '@/services/bridge';
@@ -59,6 +60,7 @@ export function UpdateReadyDialog({ platform = bridgeClient.platform }: UpdateRe
5960
const canInstall = useSkillkeeperStore((s) => s.appUpdateReadyCanInstall);
6061
const closeAppUpdateReady = useSkillkeeperStore((s) => s.closeAppUpdateReady);
6162
const startAppUpdateDownload = useSkillkeeperStore((s) => s.startAppUpdateDownload);
63+
const notify = useSkillkeeperStore((s) => s.notify);
6264
const t = useTranslator();
6365

6466
const version = offer?.version ?? '';
@@ -79,6 +81,19 @@ export function UpdateReadyDialog({ platform = bridgeClient.platform }: UpdateRe
7981
closeAppUpdateReady();
8082
}
8183

84+
// Awaits the write before claiming success, unlike the fire-and-forget copies
85+
// elsewhere in the app. This is the one command a user reaches for BECAUSE
86+
// their install already failed: telling them it is on the clipboard when it
87+
// is not leaves them pasting nothing with no idea why.
88+
async function handleCopyCommand(): Promise<void> {
89+
try {
90+
await writeText(MACOS_QUARANTINE_FALLBACK_COMMAND);
91+
notify({ key: 'appUpdate.commandCopied' }, 'info');
92+
} catch {
93+
notify({ key: 'appUpdate.commandCopyFailed' }, 'error');
94+
}
95+
}
96+
8297
return (
8398
<Modal open={open} onClose={handleCancel} title={t('appUpdate.readyTitle')} className="sk-update-ready">
8499
<p className="sk-update-body">{t('appUpdate.readyBody', { version })}</p>
@@ -87,7 +102,18 @@ export function UpdateReadyDialog({ platform = bridgeClient.platform }: UpdateRe
87102
{showMacFallback && (
88103
<div className="sk-update-fallback">
89104
<p className="sk-update-hint">{t('appUpdate.installFailedFallbackHint')}</p>
90-
<pre className="sk-update-fallback-command">{MACOS_QUARANTINE_FALLBACK_COMMAND}</pre>
105+
<div className="sk-update-fallback-command-row">
106+
<pre className="sk-update-fallback-command">{MACOS_QUARANTINE_FALLBACK_COMMAND}</pre>
107+
<Button
108+
variant="secondary"
109+
className="sk-update-fallback-copy"
110+
onClick={() => void handleCopyCommand()}
111+
aria-label={t('appUpdate.copyCommand')}
112+
title={t('appUpdate.copyCommand')}
113+
>
114+
<Icon name="copy" size={16} />
115+
</Button>
116+
</div>
91117
</div>
92118
)}
93119
<div className="sk-update-actions">

‎locales/en.po‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,5 +1403,14 @@ msgstr "The update could not be installed: {message}"
14031403
msgid "appUpdate.installFailedFallbackHint"
14041404
msgstr "macOS may be refusing to replace the installed app. Run this command in Terminal, then choose Install now again:"
14051405

1406+
msgid "appUpdate.copyCommand"
1407+
msgstr "Copy command"
1408+
1409+
msgid "appUpdate.commandCopied"
1410+
msgstr "Command copied to the clipboard."
1411+
1412+
msgid "appUpdate.commandCopyFailed"
1413+
msgstr "The command could not be copied. Select it and copy it by hand."
1414+
14061415
msgid "appUpdate.downloadAgain"
14071416
msgstr "Download again"

0 commit comments

Comments
 (0)