mirror of
https://github.com/aljazceru/claude-code-viewer.git
synced 2026-01-05 14:44:22 +01:00
refactor: firstCommand
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { ParsedCommand } from "../../../../server/core/claude-code/functions/parseCommandXml";
|
||||
import type { ParsedUserMessage } from "../../../../server/core/claude-code/functions/parseUserMessage";
|
||||
|
||||
export const firstCommandToTitle = (firstCommand: ParsedCommand) => {
|
||||
export const firstUserMessageToTitle = (firstCommand: ParsedUserMessage) => {
|
||||
switch (firstCommand.kind) {
|
||||
case "command":
|
||||
if (firstCommand.commandArgs === undefined) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import { useTaskNotifications } from "@/hooks/useTaskNotifications";
|
||||
import { Badge } from "../../../../../../components/ui/badge";
|
||||
import { honoClient } from "../../../../../../lib/api/client";
|
||||
import { useProject } from "../../../hooks/useProject";
|
||||
import { firstCommandToTitle } from "../../../services/firstCommandToTitle";
|
||||
import { firstUserMessageToTitle } from "../../../services/firstCommandToTitle";
|
||||
import { useSession } from "../hooks/useSession";
|
||||
import { useSessionProcess } from "../hooks/useSessionProcess";
|
||||
import { ConversationList } from "./conversationList/ConversationList";
|
||||
@@ -117,8 +117,8 @@ export const SessionPageContent: FC<{
|
||||
<MenuIcon className="w-4 h-4" />
|
||||
</Button>
|
||||
<h1 className="text-lg sm:text-2xl md:text-3xl font-bold break-all overflow-ellipsis line-clamp-1 px-1 sm:px-5 min-w-0">
|
||||
{session.meta.firstCommand !== null
|
||||
? firstCommandToTitle(session.meta.firstCommand)
|
||||
{session.meta.firstUserMessage !== null
|
||||
? firstUserMessageToTitle(session.meta.firstUserMessage)
|
||||
: sessionId}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@@ -3,14 +3,14 @@ import type { FC } from "react";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { parseCommandXml } from "../../../../../../../server/core/claude-code/functions/parseCommandXml";
|
||||
import { parseUserMessage } from "../../../../../../../server/core/claude-code/functions/parseUserMessage";
|
||||
import { MarkdownContent } from "../../../../../../components/MarkdownContent";
|
||||
|
||||
export const UserTextContent: FC<{ text: string; id?: string }> = ({
|
||||
text,
|
||||
id,
|
||||
}) => {
|
||||
const parsed = parseCommandXml(text);
|
||||
const parsed = parseUserMessage(text);
|
||||
|
||||
if (parsed.kind === "command") {
|
||||
return (
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { Session } from "../../../../../../../server/core/types";
|
||||
import { NewChatModal } from "../../../../components/newChat/NewChatModal";
|
||||
import { firstCommandToTitle } from "../../../../services/firstCommandToTitle";
|
||||
import { firstUserMessageToTitle } from "../../../../services/firstCommandToTitle";
|
||||
import { sessionProcessesAtom } from "../../store/sessionProcessesAtom";
|
||||
|
||||
export const SessionsTab: FC<{
|
||||
@@ -86,8 +86,8 @@ export const SessionsTab: FC<{
|
||||
{sortedSessions.map((session) => {
|
||||
const isActive = session.id === currentSessionId;
|
||||
const title =
|
||||
session.meta.firstCommand !== null
|
||||
? firstCommandToTitle(session.meta.firstCommand)
|
||||
session.meta.firstUserMessage !== null
|
||||
? firstUserMessageToTitle(session.meta.firstUserMessage)
|
||||
: session.id;
|
||||
|
||||
const sessionProcess = sessionProcesses.find(
|
||||
|
||||
Reference in New Issue
Block a user