Skip to content

Commit b099994

Browse files
committed
fix: address additional review feedback
1 parent a71f4de commit b099994

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

frontend/app/view/preview/preview-directory.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ function DirectoryTable({
187187
);
188188

189189
const setEntryManagerProps = useSetAtom(entryManagerOverlayPropsAtom);
190-
const canCreateEntries = useAtomValue(model.statFile).supportsmkdir ?? true;
190+
const stat = useAtomValue(model.statFile);
191+
const canCreateEntries = stat?.supportsmkdir === true;
191192

192193
const updateName = useCallback(
193194
(path: string, isDir: boolean) => {
@@ -327,7 +328,9 @@ function TableBody({
327328
const dummyLineRef = useRef<HTMLDivElement>(null);
328329
const warningBoxRef = useRef<HTMLDivElement>(null);
329330
const conn = useAtomValue(model.connection);
330-
const canCreateEntries = useAtomValue(model.statFile).supportsmkdir ?? true;
331+
const stat = useAtomValue(model.statFile);
332+
const canCreateEntries = stat?.supportsmkdir === true;
333+
const canMutateEntries = stat != null && (stat.path !== "/" || stat.supportsmkdir === true);
331334
const setErrorMsg = useSetAtom(model.errorMsgAtom);
332335

333336
useEffect(() => {
@@ -384,18 +387,22 @@ function TableBody({
384387
click: () => {
385388
table.options.meta.newDirectory();
386389
},
387-
},
388-
{
389-
label: "Rename",
390-
click: () => {
391-
table.options.meta.updateName(finfo.path, finfo.isdir);
392-
},
393-
},
394-
{
395-
type: "separator",
396390
}
397391
);
398392
}
393+
if (canMutateEntries) {
394+
menu.push({
395+
label: "Rename",
396+
click: () => {
397+
table.options.meta.updateName(finfo.path, finfo.isdir);
398+
},
399+
});
400+
}
401+
if (canCreateEntries || canMutateEntries) {
402+
menu.push({
403+
type: "separator",
404+
});
405+
}
399406
menu.push(
400407
{
401408
label: "Copy File Name",
@@ -422,7 +429,7 @@ function TableBody({
422429
label: "Default Settings",
423430
submenu: makeDirectoryDefaultMenuItems(model),
424431
});
425-
if (canCreateEntries) {
432+
if (canMutateEntries) {
426433
menu.push(
427434
{
428435
type: "separator",
@@ -435,7 +442,7 @@ function TableBody({
435442
}
436443
ContextMenuModel.getInstance().showContextMenu(menu, e);
437444
},
438-
[canCreateEntries, conn, setErrorMsg]
445+
[canCreateEntries, canMutateEntries, conn, setErrorMsg]
439446
);
440447

441448
const allRows = table.getRowModel().flatRows;
@@ -580,7 +587,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
580587
const conn = useAtomValue(model.connection);
581588
const blockData = useAtomValue(model.blockAtom);
582589
const finfo = useAtomValue(model.statFile);
583-
const canCreateEntries = finfo?.supportsmkdir ?? true;
590+
const canCreateEntries = finfo?.supportsmkdir === true;
584591
const dirPath = finfo?.path;
585592
const setErrorMsg = useSetAtom(model.errorMsgAtom);
586593

frontend/app/view/term/termwrap.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ export class TermWrap {
323323
if (target instanceof Element && target.closest(".xterm-viewport") != null) {
324324
return;
325325
}
326+
// This relies on xterm.js private internals (`_core._renderService`) because
327+
// there is no public API for measured cell height yet; fall back to 16px
328+
// (a conservative default line height) so wheel deltas still map to lines,
329+
// and revisit this when xterm exposes public cell dimensions.
326330
const cellHeight = (this.terminal as any)?._core?._renderService?.dimensions?.css?.cell?.height ?? 16;
327331
const lineDelta = getWheelLineDelta(event.deltaY, event.deltaMode, cellHeight, this.terminal.rows);
328332
if (lineDelta === 0) {

0 commit comments

Comments
 (0)