Skip to content

Commit 628c89f

Browse files
committed
chore(ellamaka): remove dead code and format owned files [anomalyco#217]
Remove 46 unused imports, variables and parameters across the session, workbench, desktop main and wopal-space config areas. Unused catch bindings and signature parameters use the project's existing underscore convention. Format the same owned files with Prettier so each touched file leaves the lint and format baseline clean. No behavior changes; verify with: git diff -w. Full-repo oxlint warnings drop from 3800 to 3752.
1 parent d5029a0 commit 628c89f

26 files changed

Lines changed: 1483 additions & 1076 deletions

‎packages/ellamaka-app/src/pages/session/chat-render.utils.test.ts‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
parseSyntheticInjection,
1414
partTitle,
1515
relativizeProjectPath,
16-
type PartClassification,
1716
} from "./chat-render.utils"
1817

1918
function userMessage(id: string): UserMessage {
@@ -107,9 +106,26 @@ describe("isRenderablePart", () => {
107106
test("hides step-start, step-finish and legacy snapshot/patch parts", () => {
108107
const msg = assistantMessage("a1", "u1")
109108
expect(isRenderablePart({ id: "1", sessionID: "s", messageID: "a1", type: "step-start" }, msg)).toBe(false)
110-
expect(isRenderablePart({ id: "2", sessionID: "s", messageID: "a1", type: "step-finish", reason: "x", cost: 0, tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } } }, msg)).toBe(false)
111-
expect(isRenderablePart({ id: "3", sessionID: "s", messageID: "a1", type: "snapshot", snapshot: "x" }, msg)).toBe(false)
112-
expect(isRenderablePart({ id: "4", sessionID: "s", messageID: "a1", type: "patch", hash: "x", files: [] }, msg)).toBe(false)
109+
expect(
110+
isRenderablePart(
111+
{
112+
id: "2",
113+
sessionID: "s",
114+
messageID: "a1",
115+
type: "step-finish",
116+
reason: "x",
117+
cost: 0,
118+
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
119+
},
120+
msg,
121+
),
122+
).toBe(false)
123+
expect(isRenderablePart({ id: "3", sessionID: "s", messageID: "a1", type: "snapshot", snapshot: "x" }, msg)).toBe(
124+
false,
125+
)
126+
expect(
127+
isRenderablePart({ id: "4", sessionID: "s", messageID: "a1", type: "patch", hash: "x", files: [] }, msg),
128+
).toBe(false)
113129
})
114130

115131
test("keeps synthetic text renderable regardless of message role or completion", () => {
@@ -161,7 +177,9 @@ describe("classifyPart", () => {
161177
const u = userMessage("u2")
162178
// wopal-plugin task notifications arrive as plain text parts wrapped in
163179
// <system-reminder>, with no synthetic flag.
164-
expect(classifyPart(textPart("p1", "u2", "<system-reminder>[WOPAL TASK PROGRESS] running</system-reminder>"), u).kind).toBe("injection")
180+
expect(
181+
classifyPart(textPart("p1", "u2", "<system-reminder>[WOPAL TASK PROGRESS] running</system-reminder>"), u).kind,
182+
).toBe("injection")
165183
expect(classifyPart(textPart("p2", "a1", "<rules-context>rule</rules-context>"), a).kind).toBe("injection")
166184
expect(classifyPart(textPart("p3", "a1", "<memory-context>memory</memory-context>"), a).kind).toBe("injection")
167185
// Leading whitespace before the shell still matches.
@@ -310,7 +328,14 @@ describe("extractPromptSummary", () => {
310328
const u = userMessage("u1")
311329
const parts = [
312330
textPart("p1", "u1", "<system-reminder>[WOPAL TASK IDLE] done</system-reminder>"),
313-
{ id: "p2", sessionID: "ses_1", messageID: "u1", type: "text", text: "<rules-context>rules</rules-context>", synthetic: true } as Part,
331+
{
332+
id: "p2",
333+
sessionID: "ses_1",
334+
messageID: "u1",
335+
type: "text",
336+
text: "<rules-context>rules</rules-context>",
337+
synthetic: true,
338+
} as Part,
314339
textPart("p3", "u1", "real prompt"),
315340
]
316341
const summary = extractPromptSummary({ message: u, parts })

‎packages/ellamaka-app/src/pages/session/chat-render.utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function isRunning(message: AssistantMessage): boolean {
7373
* role or completion state. Todo tool parts are owned by the composer todo
7474
* dock and never enter the transcript.
7575
*/
76-
export function isRenderablePart(part: Part, message: Message): boolean {
76+
export function isRenderablePart(part: Part, _message: Message): boolean {
7777
if (HIDDEN_PART_TYPES.has(part.type)) return false
7878
if (part.type === "tool" && HIDDEN_TOOLS.has(part.tool)) return false
7979
return true

‎packages/ellamaka-app/src/pages/session/chat-transcript.test.ts‎

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
import { describe, expect, test } from "bun:test"
2-
import type {
3-
AssistantMessage,
4-
Message,
5-
Part,
6-
SessionStatus,
7-
UserMessage,
8-
} from "@opencode-ai/sdk/v2"
2+
import type { AssistantMessage, Message, Part, SessionStatus, UserMessage } from "@opencode-ai/sdk/v2"
93
import {
104
ASSISTANT_SEGMENT_PARTS,
115
createRowStabilizer,
126
isCompactionMarker,
137
nearestUserTurnID,
148
projectTranscript,
159
rowKey,
16-
type ChatTurn,
17-
type TranscriptPartition,
1810
type TranscriptRow,
1911
} from "./chat-transcript"
2012

@@ -56,18 +48,6 @@ function reasoningPart(id: string, messageID: string, text: string): Part {
5648
return { id, sessionID: "ses_1", messageID, type: "reasoning", text, time: { start: 0, end: 1 } }
5749
}
5850

59-
function toolPart(id: string, messageID: string, tool: string, callID: string): Part {
60-
return {
61-
id,
62-
sessionID: "ses_1",
63-
messageID,
64-
type: "tool",
65-
callID,
66-
tool,
67-
state: { status: "completed", input: {}, output: "", title: tool, metadata: {}, time: { start: 0, end: 1 } },
68-
}
69-
}
70-
7151
function stepStartPart(id: string, messageID: string): Part {
7252
return { id, sessionID: "ses_1", messageID, type: "step-start" }
7353
}
@@ -107,8 +87,12 @@ describe("projectTranscript", () => {
10787
showReasoningSummaries: true,
10888
})
10989

110-
expect(defaultOff.rows.flatMap((row) => (row.type === "assistant" ? row.parts : [])).map((part) => part.id)).toEqual(["r1", "p1"])
111-
expect(defaultOn.rows.flatMap((row) => (row.type === "assistant" ? row.parts : [])).map((part) => part.id)).toEqual(["r1", "p1"])
90+
expect(
91+
defaultOff.rows.flatMap((row) => (row.type === "assistant" ? row.parts : [])).map((part) => part.id),
92+
).toEqual(["r1", "p1"])
93+
expect(defaultOn.rows.flatMap((row) => (row.type === "assistant" ? row.parts : [])).map((part) => part.id)).toEqual(
94+
["r1", "p1"],
95+
)
11296
})
11397

11498
test("groups assistant messages by parentID into stable turns", () => {
@@ -181,11 +165,7 @@ describe("projectTranscript", () => {
181165
test("hides non-renderable parts from assistant segments", () => {
182166
const u1 = userMessage("u1")
183167
const a1 = assistantMessage("a1", "u1")
184-
const parts: Part[] = [
185-
stepStartPart("s1", "a1"),
186-
textPart("p1", "a1", "visible"),
187-
stepStartPart("s2", "a1"),
188-
]
168+
const parts: Part[] = [stepStartPart("s1", "a1"), textPart("p1", "a1", "visible"), stepStartPart("s2", "a1")]
189169

190170
const { rows } = projectTranscript({ messages: [u1, a1], getParts: partsByID(parts), status: idle })
191171

@@ -198,11 +178,7 @@ describe("projectTranscript", () => {
198178
const u1 = userMessage("u1")
199179
const a1 = assistantMessage("a1", "u1")
200180
const a2 = assistantMessage("a2", "u1")
201-
const parts = [
202-
textPart("p1", "u1", "hello"),
203-
textPart("p2", "a1", "中间回复"),
204-
textPart("p3", "a2", "最终回复"),
205-
]
181+
const parts = [textPart("p1", "u1", "hello"), textPart("p2", "a1", "中间回复"), textPart("p3", "a2", "最终回复")]
206182

207183
const { rows } = projectTranscript({ messages: [u1, a1, a2], getParts: partsByID(parts), status: idle })
208184

@@ -222,9 +198,7 @@ describe("projectTranscript", () => {
222198

223199
const { rows } = projectTranscript({ messages: [u1, a1], getParts: partsByID(parts), status: idle })
224200

225-
const assistantRows = rows.filter(
226-
(r): r is Extract<TranscriptRow, { type: "assistant" }> => r.type === "assistant",
227-
)
201+
const assistantRows = rows.filter((r): r is Extract<TranscriptRow, { type: "assistant" }> => r.type === "assistant")
228202
expect(assistantRows).toHaveLength(2)
229203
expect(assistantRows[0]?.metaPartID).toBeUndefined()
230204
expect(assistantRows[1]?.metaPartID).toBe(`p${ASSISTANT_SEGMENT_PARTS + 4}`)
@@ -250,9 +224,9 @@ describe("projectTranscript", () => {
250224
})
251225

252226
const findAssistant = (rows: TranscriptRow[], messageID: string) =>
253-
rows.filter((r): r is Extract<TranscriptRow, { type: "assistant" }> => r.type === "assistant").find(
254-
(r) => r.message.id === messageID,
255-
)
227+
rows
228+
.filter((r): r is Extract<TranscriptRow, { type: "assistant" }> => r.type === "assistant")
229+
.find((r) => r.message.id === messageID)
256230
const firstRow = findAssistant(first.rows, "a1")
257231
const secondRow = findAssistant(second.rows, "a1")
258232
expect(firstRow).toBeDefined()
@@ -492,7 +466,14 @@ describe("compaction marker projection", () => {
492466

493467
test("isCompactionMarker is false for a user message with file or agent parts", () => {
494468
const u1 = userMessage("u1")
495-
const filePart: Part = { id: "f1", sessionID: "ses_1", messageID: "u1", type: "file", mime: "text/plain", url: "file:///x" }
469+
const filePart: Part = {
470+
id: "f1",
471+
sessionID: "ses_1",
472+
messageID: "u1",
473+
type: "file",
474+
mime: "text/plain",
475+
url: "file:///x",
476+
}
496477
expect(isCompactionMarker(u1, partsByID([compactionPart("cp1", "u1"), filePart]))).toBe(false)
497478
})
498479

‎packages/ellamaka-app/src/pages/session/chat-transcript.ts‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import type {
2-
AssistantMessage,
3-
Message,
4-
Part,
5-
SessionStatus,
6-
UserMessage,
7-
} from "@opencode-ai/sdk/v2"
1+
import type { AssistantMessage, Message, Part, SessionStatus, UserMessage } from "@opencode-ai/sdk/v2"
82
import { isRenderablePart } from "./chat-render.utils"
93

104
/**
@@ -81,8 +75,6 @@ export type TranscriptProjection = {
8175
promptIndex: Map<string, string>
8276
}
8377

84-
const emptyParts: Part[] = []
85-
8678
function isUserMessage(message: Message): message is UserMessage {
8779
return message.role === "user"
8880
}
@@ -185,9 +177,6 @@ function buildTurnRows(
185177
rows.push({ type: "user", key: userRowKey(turnID), turnID, message: turn.user, parts: userParts })
186178
}
187179

188-
const running = turn.assistant.some(isRunning)
189-
const active = status.type !== "idle"
190-
191180
for (let messageIndex = 0; messageIndex < turn.assistant.length; messageIndex++) {
192181
const message = turn.assistant[messageIndex]!
193182
const isFinalMessage = messageIndex === turn.assistant.length - 1
@@ -383,7 +372,11 @@ export function projectTranscript(input: TranscriptProjectionInput): TranscriptP
383372
turns.forEach((turn, index) => {
384373
const turnRows = buildTurnRows(turn, getParts, status, live, showReasoningSummaries)
385374
rows.push(...turnRows)
386-
if (!promptIndex.has(turn.id)) promptIndex.set(turn.id, turnRows[0]?.key ?? (isCompactionMarker(turn.user, getParts) ? compactionRowKey(turn.id) : userRowKey(turn.id)))
375+
if (!promptIndex.has(turn.id))
376+
promptIndex.set(
377+
turn.id,
378+
turnRows[0]?.key ?? (isCompactionMarker(turn.user, getParts) ? compactionRowKey(turn.id) : userRowKey(turn.id)),
379+
)
387380

388381
const isLiveTurn = hasLiveTurn && index >= liveTurnIndex
389382
const turnRunning = turn.assistant.some(isRunning)
@@ -397,7 +390,9 @@ export function projectTranscript(input: TranscriptProjectionInput): TranscriptP
397390
}
398391
})
399392

400-
const partition = input.stabilize ? { virtual: [] as TranscriptRow[], direct: [] as TranscriptRow[] } : { virtual, direct }
393+
const partition = input.stabilize
394+
? { virtual: [] as TranscriptRow[], direct: [] as TranscriptRow[] }
395+
: { virtual, direct }
401396
if (input.stabilize) {
402397
// Stabilize across the whole partition in one pass so the cache sweep does
403398
// not evict rows that live in the other half of the partition.

‎packages/ellamaka-app/src/pages/session/composer/session-composer-state.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export const todoState = (input: {
2121
return "close"
2222
}
2323

24-
const idle = { type: "idle" as const }
25-
2624
export function createSessionComposerState(options?: { closeMs?: number | (() => number) }) {
2725
const params = useParams()
2826
const sdk = useSDK()

‎packages/ellamaka-app/src/pages/session/prompt-navigator.test.tsx‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { describe, expect, mock, test } from "bun:test"
33
import { render } from "solid-js/web"
44
import h from "solid-js/h"
5-
import { createSignal } from "solid-js"
65
import type { JSX } from "solid-js"
76
import type { AssistantMessage, Part, UserMessage } from "@opencode-ai/sdk/v2"
87
import { PromptNavigator, type PromptNavigatorProps } from "./prompt-navigator"
@@ -11,7 +10,7 @@ mock.module("@wopal/ui/icon", () => ({
1110
Icon: (props: { name: string }) => <span data-slot="chat-icon" data-icon={props.name} />,
1211
}))
1312

14-
function userMessage(id: string, text: string): UserMessage {
13+
function userMessage(id: string, _text: string): UserMessage {
1514
return {
1615
id,
1716
sessionID: "ses_1",
@@ -124,7 +123,8 @@ describe("PromptNavigator", () => {
124123
<PromptNavigator
125124
{...baseProps({
126125
userMessages: [u1, uNotify, u2],
127-
getParts: (id: string) => (id === "u-notify" ? [syntheticPart] : [textPart(`p-${id}`, id, id === "u1" ? "hello" : "world")]),
126+
getParts: (id: string) =>
127+
id === "u-notify" ? [syntheticPart] : [textPart(`p-${id}`, id, id === "u1" ? "hello" : "world")],
128128
})}
129129
/>
130130
))
@@ -155,7 +155,8 @@ describe("PromptNavigator", () => {
155155
<PromptNavigator
156156
{...baseProps({
157157
userMessages: [u1, uTask, u2],
158-
getParts: (id: string) => (id === "u-task" ? [taskPart] : [textPart(`p-${id}`, id, id === "u1" ? "hello" : "world")]),
158+
getParts: (id: string) =>
159+
id === "u-task" ? [taskPart] : [textPart(`p-${id}`, id, id === "u1" ? "hello" : "world")],
159160
})}
160161
/>
161162
))
@@ -581,13 +582,16 @@ describe("PromptNavigator", () => {
581582
timeline.style.width = "300px"
582583
host.appendChild(timeline)
583584
document.body.appendChild(host)
584-
render(() => (
585-
<PromptNavigator
586-
{...baseProps({
587-
userMessages: [u1],
588-
})}
589-
/>
590-
), timeline)
585+
render(
586+
() => (
587+
<PromptNavigator
588+
{...baseProps({
589+
userMessages: [u1],
590+
})}
591+
/>
592+
),
593+
timeline,
594+
)
591595

592596
const navigator = host.querySelector("[data-component='chat-prompt-navigator']") as HTMLElement
593597
const rail = host.querySelector("[data-component='chat-prompt-rail']") as HTMLElement

‎packages/ellamaka-app/src/pages/session/prompt-navigator.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createEffect, createMemo, createSignal, For, onCleanup, onMount } from "solid-js"
22
import type { AssistantMessage, Part, UserMessage } from "@opencode-ai/sdk/v2"
3-
import { cleanSummary, extractPromptSummary, isInjectionPart, isRenderablePart } from "./chat-render.utils"
3+
import { cleanSummary, extractPromptSummary, isInjectionPart } from "./chat-render.utils"
44
import { isCompactionMarker } from "./chat-transcript"
55

66
export type PromptNavigatorProps = {
@@ -139,10 +139,7 @@ export function PromptNavigator(props: PromptNavigatorProps) {
139139

140140
return (
141141
<div data-component="chat-prompt-navigator">
142-
<div
143-
data-component="chat-prompt-rail"
144-
data-open={open()}
145-
>
142+
<div data-component="chat-prompt-rail" data-open={open()}>
146143
<For each={entries()}>
147144
{(entry) => (
148145
<button

‎packages/ellamaka-app/src/pages/session/session-side-panel.tsx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { useFile, type SelectedLineRange } from "@/context/file"
2020
import { useLanguage } from "@/context/language"
2121
import { useLayout } from "@/context/layout"
2222
import { usePlatform } from "@/context/platform"
23-
import { useSync } from "@/context/sync"
2423
import { createFileTabListSync } from "@/pages/session/file-tab-scroll"
2524
import { FileTabContent } from "@/pages/session/file-tabs"
2625
import { createOpenSessionFileTab, createSessionTabs, getTabReorderIndex, type Sizing } from "@/pages/session/helpers"
@@ -31,11 +30,7 @@ type RenderDiff = VcsFileDiff
3130

3231
function renderDiff(value: unknown): value is RenderDiff {
3332
return (
34-
!!value &&
35-
typeof value === "object" &&
36-
!Array.isArray(value) &&
37-
"file" in value &&
38-
typeof value.file === "string"
33+
!!value && typeof value === "object" && !Array.isArray(value) && "file" in value && typeof value.file === "string"
3934
)
4035
}
4136

@@ -54,7 +49,6 @@ export function SessionSidePanel(props: {
5449
}) {
5550
const layout = useLayout()
5651
const platform = usePlatform()
57-
const sync = useSync()
5852
const file = useFile()
5953
const language = useLanguage()
6054
const command = useCommand()

‎packages/ellamaka-app/src/pages/workbench/dsh-surface.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ export function DshSurface(props: { children: JSX.Element }): JSX.Element {
217217
// B-01: the heal target goes through healTargetUrl so the reload lands on
218218
// the page-origin (proxied) URL, never the raw backend entry.
219219
let iframeEl: HTMLIFrameElement | undefined
220-
let reloadCalls = 0
221220
const heal = createDsh401Healer({
222221
getFrame: () => iframeEl,
223222
refetchEntry: async () => {

0 commit comments

Comments
 (0)