Skip to content

Commit 4dc38c3

Browse files
Copilotna-trium-144
andcommitted
Remove sectionId from DynamicMarkdownSection, use section.id directly
Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
1 parent 2270cd1 commit 4dc38c3

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

app/[docs_id]/pageContent.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import clsx from "clsx";
1111
// MarkdownSectionに追加で、ユーザーが今そのセクションを読んでいるかどうか、などの動的な情報を持たせる
1212
export type DynamicMarkdownSection = MarkdownSection & {
1313
inView: boolean;
14-
sectionId: string;
1514
};
1615

1716
interface PageContentProps {
@@ -26,19 +25,17 @@ export function PageContent(props: PageContentProps) {
2625
const [dynamicMdContent, setDynamicMdContent] = useState<
2726
DynamicMarkdownSection[]
2827
>(
29-
props.splitMdContent.map((section, i) => ({
28+
props.splitMdContent.map((section) => ({
3029
...section,
3130
inView: false,
32-
sectionId: section.id || `${props.docs_id}-${i}`,
3331
}))
3432
);
3533

3634
useEffect(() => {
3735
// props.splitMdContentが変わったときにローカルstateとcontextの両方を更新
38-
const newContent = props.splitMdContent.map((section, i) => ({
36+
const newContent = props.splitMdContent.map((section) => ({
3937
...section,
4038
inView: false,
41-
sectionId: section.id || `${props.docs_id}-${i}`,
4239
}));
4340
setDynamicMdContent(newContent);
4441
setSidebarMdContent(props.docs_id, newContent);
@@ -104,7 +101,7 @@ export function PageContent(props: PageContentProps) {
104101
<div>
105102
{/* 右側に表示するチャット履歴欄 */}
106103
{chatHistories
107-
.filter((c) => c.sectionId === section.sectionId)
104+
.filter((c) => c.sectionId === section.id)
108105
.map(({ chatId, messages }) => (
109106
<div
110107
key={chatId}

app/actions/chatActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export async function askAI(params: ChatParams): Promise<ChatResult> {
149149
}
150150
// TODO: どのセクションへの回答にするかをAIに決めさせる
151151
const targetSectionId =
152-
sectionContent.find((s) => s.inView)?.sectionId || "";
152+
sectionContent.find((s) => s.inView)?.id || "";
153153
const newChat = await addChat(params.docsId, targetSectionId, [
154154
{ role: "user", content: userQuestion },
155155
{ role: "ai", content: text },

0 commit comments

Comments
 (0)