chore: remove dead code (59 unused files + ~125 unused exports) (#1835)
* chore: remove dead/unreferenced files across ui, vscode Remove 59 unused source files (components, hooks, lib utils, stores, barrels, and orphaned vscode github modules) that are not imported by any entry-reachable code. Also drop a stale test mock for the removed execCommands module. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * refactor: remove unused exported symbols (types, functions, consts, hooks) Remove exported symbols whose identifier is referenced nowhere in the repository (verified via repo-wide search), across ui types/contracts, lib utilities, sync layer, stores, and components. Also drop the few imports/private helpers orphaned by these removals. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * refactor: remove more unused exports (desktop, shortcuts, worktree, vscode) Continue removing repo-wide unreferenced exported functions, consts and types across lib/desktop, shortcuts, worktreeSessionCreator, sync, and vscode gitService, with cascading orphaned helpers/imports cleaned up. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * chore: add dead-code cleanup tooling * refactor: checkpoint dead-code cleanup * refactor: remove dead-code suppressions --------- Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Serhii Dziupin
Bohdan Triapitsyn
parent
4a37b9a005
commit
00821700de
@@ -1,8 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import type { Part } from "@opencode-ai/sdk/v2";
|
||||
import { isFullySyntheticMessage } from "@/lib/messages/synthetic";
|
||||
|
||||
export interface MessageInfo {
|
||||
interface MessageInfo {
|
||||
id: string;
|
||||
role: string;
|
||||
time?: {
|
||||
@@ -18,92 +17,3 @@ export interface MessageRecord {
|
||||
info: MessageInfo & Record<string, any>;
|
||||
parts: Part[];
|
||||
}
|
||||
|
||||
export function isMessageComplete(messageInfo: MessageInfo, parts: Part[] = []): boolean {
|
||||
if (isFullySyntheticMessage(parts)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const timeInfo = messageInfo?.time ?? {};
|
||||
const completedAt = typeof timeInfo?.completed === 'number' ? timeInfo.completed : undefined;
|
||||
const messageStatus = messageInfo?.status;
|
||||
|
||||
const hasStopFinish = messageInfo.finish === 'stop';
|
||||
|
||||
const hasCompletedFlag = (typeof completedAt === 'number' && completedAt > 0) || messageStatus === 'completed';
|
||||
if (!hasCompletedFlag || !hasStopFinish) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const hasActiveTools = parts.some((part) => {
|
||||
switch (part.type) {
|
||||
case 'reasoning': {
|
||||
const time = (part as any)?.time;
|
||||
return !time || typeof time.end === 'undefined';
|
||||
}
|
||||
case 'tool': {
|
||||
const status = (part as any)?.state?.status;
|
||||
return status === 'running' || status === 'pending';
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return !hasActiveTools;
|
||||
}
|
||||
|
||||
export function getLatestAssistantMessageId(messages: MessageRecord[]): string | null {
|
||||
const assistantMessages = messages
|
||||
.filter(msg => msg.info.role === 'assistant' && !isFullySyntheticMessage(msg.parts))
|
||||
.sort((a, b) => (a.info.id || "").localeCompare(b.info.id || ""));
|
||||
|
||||
return assistantMessages.length > 0
|
||||
? assistantMessages[assistantMessages.length - 1].info.id
|
||||
: null;
|
||||
}
|
||||
|
||||
export function hasAnimatingWork(messages: MessageRecord[]): boolean {
|
||||
if (messages.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const message of messages) {
|
||||
if (message.info.role !== 'assistant') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isFullySyntheticMessage(message.parts)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isMessageComplete(message.info, message.parts)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function shouldContinueStreaming(
|
||||
messages: MessageRecord[],
|
||||
currentStreamingId: string | null
|
||||
): boolean {
|
||||
const latestId = getLatestAssistantMessageId(messages);
|
||||
if (!latestId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentStreamingId && currentStreamingId !== latestId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const latestMessage = messages.find(
|
||||
(msg) => msg.info.id === latestId && !isFullySyntheticMessage(msg.parts)
|
||||
);
|
||||
if (!latestMessage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isMessageComplete(latestMessage.info, latestMessage.parts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user