Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/app/src/components/file-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ export default function FileTree(props: {
const draggable = () => props.draggable ?? true

const key = (p: string) =>
file
(file
.normalize(p)
?? "")
.replace(/[\\/]+$/, "")
.replaceAll("\\", "/")
const chain = props._chain ? [...props._chain, key(props.path)] : [key(props.path)]
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/custom-elements.d.ts
20 changes: 17 additions & 3 deletions packages/app/src/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,21 @@ const getCurrentUrl = () => {
return location.origin
}

const isLocalCurrentUrl = (url: string) => {
try {
const next = new URL(url)
return next.hostname === "localhost" || next.hostname === "127.0.0.1" || next.hostname === "::1"
} catch {
return false
}
}

const getDefaultUrl = () => {
const current = getCurrentUrl()
if (!import.meta.env.DEV && isLocalCurrentUrl(current)) return current
const lsDefault = readDefaultServerUrl()
if (lsDefault) return lsDefault
return getCurrentUrl()
return current
}

const platform: Platform = {
Expand All @@ -119,8 +130,11 @@ const platform: Platform = {
restart,
notify,
getDefaultServer: async () => {
const stored = readDefaultServerUrl()
return stored ? ServerConnection.Key.make(stored) : null
if (import.meta.env.DEV) {
const stored = readDefaultServerUrl()
return stored ? ServerConnection.Key.make(stored) : null
}
return ServerConnection.Key.make(getDefaultUrl())
},
setDefaultServer: writeDefaultServerUrl,
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/pages/layout/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type SessionStore = {
path: { directory: string }
}

export const workspaceKey = (directory: string) => {
const value = directory.replaceAll("\\", "/")
export const workspaceKey = (directory?: string) => {
const value = (directory ?? "").replaceAll("\\", "/")
const drive = value.match(/^([A-Za-z]:)\/+$/)
if (drive) return `${drive[1]}/`
if (/^\/+$/i.test(value)) return "/"
Expand Down
8 changes: 6 additions & 2 deletions packages/app/src/pages/session/session-side-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,23 @@ export function SessionSidePanel(props: {
})
const treeWidth = createMemo(() => (fileOpen() ? `${layout.fileTree.width()}px` : "0px"))

const diffFiles = createMemo(() => props.diffs().map((d) => d.file))
const diffFiles = createMemo(() =>
props.diffs().flatMap((d) => (typeof d.file === "string" && d.file ? [d.file] : [])),
)
const kinds = createMemo(() => {
const merge = (a: "add" | "del" | "mix" | undefined, b: "add" | "del" | "mix") => {
if (!a) return b
if (a === b) return a
return "mix" as const
}

const normalize = (p: string) => p.replaceAll("\\\\", "/").replace(/\/+$/, "")
const normalize = (p?: string) =>
typeof p === "string" ? p.replaceAll("\\\\", "/").replace(/\/+$/, "") : ""

const out = new Map<string, "add" | "del" | "mix">()
for (const diff of props.diffs()) {
const file = normalize(diff.file)
if (!file) continue
const kind = diff.status === "added" ? "add" : diff.status === "deleted" ? "del" : "mix"

out.set(file, kind)
Expand Down
2 changes: 1 addition & 1 deletion packages/enterprise/src/custom-elements.d.ts
Loading