summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-02 10:55:15 -0600
committerAdam <[email protected]>2026-02-02 14:24:23 -0600
commit3b93e8d95cfc30d1a85fbb76694bdb7f49dff1e9 (patch)
tree1d3c5b40c80f64de6bb5fc26870dd1f2f6367e35 /packages/app/src
parent23631a93935a33fb8e44272ba1572e3475a223c2 (diff)
downloadopencode-3b93e8d95cfc30d1a85fbb76694bdb7f49dff1e9.tar.gz
opencode-3b93e8d95cfc30d1a85fbb76694bdb7f49dff1e9.zip
fix(app): added/deleted file status now correctly calculated
Diffstat (limited to 'packages/app/src')
-rw-r--r--packages/app/src/components/file-tree.tsx49
-rw-r--r--packages/app/src/pages/session.tsx4
2 files changed, 49 insertions, 4 deletions
diff --git a/packages/app/src/components/file-tree.tsx b/packages/app/src/components/file-tree.tsx
index d43310b19..19f5e9a3b 100644
--- a/packages/app/src/components/file-tree.tsx
+++ b/packages/app/src/components/file-tree.tsx
@@ -130,10 +130,57 @@ export default function FileTree(props: {
const nodes = file.tree.children(props.path)
const current = filter()
if (!current) return nodes
- return nodes.filter((node) => {
+
+ const parent = (path: string) => {
+ const idx = path.lastIndexOf("/")
+ if (idx === -1) return ""
+ return path.slice(0, idx)
+ }
+
+ const leaf = (path: string) => {
+ const idx = path.lastIndexOf("/")
+ return idx === -1 ? path : path.slice(idx + 1)
+ }
+
+ const out = nodes.filter((node) => {
if (node.type === "file") return current.files.has(node.path)
return current.dirs.has(node.path)
})
+
+ const seen = new Set(out.map((node) => node.path))
+
+ for (const dir of current.dirs) {
+ if (parent(dir) !== props.path) continue
+ if (seen.has(dir)) continue
+ out.push({
+ name: leaf(dir),
+ path: dir,
+ absolute: dir,
+ type: "directory",
+ ignored: false,
+ })
+ seen.add(dir)
+ }
+
+ for (const item of current.files) {
+ if (parent(item) !== props.path) continue
+ if (seen.has(item)) continue
+ out.push({
+ name: leaf(item),
+ path: item,
+ absolute: item,
+ type: "file",
+ ignored: false,
+ })
+ seen.add(item)
+ }
+
+ return out.toSorted((a, b) => {
+ if (a.type !== b.type) {
+ return a.type === "directory" ? -1 : 1
+ }
+ return a.name.localeCompare(b.name)
+ })
})
const Node = (
diff --git a/packages/app/src/pages/session.tsx b/packages/app/src/pages/session.tsx
index 772ad063b..540046c09 100644
--- a/packages/app/src/pages/session.tsx
+++ b/packages/app/src/pages/session.tsx
@@ -500,9 +500,7 @@ export default function Page() {
const out = new Map<string, "add" | "del" | "mix">()
for (const diff of diffs()) {
const file = normalize(diff.file)
- const add = diff.additions > 0
- const del = diff.deletions > 0
- const kind = add && del ? "mix" : add ? "add" : del ? "del" : "mix"
+ const kind = diff.status === "added" ? "add" : diff.status === "deleted" ? "del" : "mix"
out.set(file, kind)