Skip to content

[DEV] LLMInputBox 페이지별 연결#88

Open
drddyn wants to merge 3 commits intodevelopfrom
dev/llm-input-api
Open

[DEV] LLMInputBox 페이지별 연결#88
drddyn wants to merge 3 commits intodevelopfrom
dev/llm-input-api

Conversation

@drddyn
Copy link
Owner

@drddyn drddyn commented Mar 16, 2026

🔗 관련 이슈

close #55

✨ 요약

페이지별 맞는 훅을 LLMInputBox에 연결합니다

📝 작업 내용

  • 섹션 페이지 내 -> usePostSectionInSectionPage
  • 매거진 페이지 내 ->usePostSection
  • 찜한 페이지, 둘러보기 -> usePostMagazine

drddyn added 3 commits March 16, 2026 22:25
- explore와 loved 일시 매거진 생성(usePostMagazine)으로 이어지도록 수정
@drddyn drddyn self-assigned this Mar 16, 2026
@vercel
Copy link

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mine Ready Ready Preview, Comment Mar 16, 2026 3:04pm

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 LLMInputBox 컴포넌트의 기능을 확장하여 사용자가 현재 보고 있는 페이지의 맥락에 따라 다양한 방식으로 콘텐츠를 생성하고 상호작용할 수 있도록 합니다. 매거진 페이지, 섹션 페이지, 또는 일반 둘러보기 페이지에서 LLMInputBox를 통해 섹션을 추가하거나 새로운 매거진을 생성하는 등의 작업을 수행할 수 있도록 백엔드 API와 프론트엔드 로직을 연결합니다.

Highlights

  • 새로운 API 엔드포인트 및 타입 추가: 매거진에 섹션을 추가하거나 매거진 내 특정 섹션 페이지에 섹션을 추가하기 위한 API 함수와 관련 타입이 정의되었습니다.
  • 새로운 React 훅 구현: usePostAddSectionusePostAddSectionInSectionPage 훅이 추가되어 섹션 추가 API 호출을 관리합니다.
  • LLMInputLayout 동적 연결: 현재 페이지 경로에 따라 LLMInputBox가 적절한 섹션 추가 또는 매거진 생성 훅에 동적으로 연결되도록 로직이 개선되었습니다.
  • 프록시 설정 업데이트: 개발 환경의 API 프록시 대상 URL이 변경되었습니다.
Changelog
  • Mine/src/api/magazine.ts
    • RequestAddSection, RequestAddSectionInSectionPage, ResponseAddSection, ResponseAddSectionInSectionPage 타입과 postAddSection, postAddSectionInSectionPage 함수가 추가되었습니다.
  • Mine/src/components/LLMInputLayout.tsx
    • LLMInputBoxonSend 핸들러가 현재 라우트(섹션 페이지, 매거진 페이지, 기타)에 따라 usePostAddSection, usePostAddSectionInSectionPage, usePostMagazine 훅 중 하나를 사용하도록 동적으로 설정되었습니다.
    • 로그인 상태 및 숨겨진 경로에 따라 컴포넌트 렌더링 여부가 결정되었습니다.
  • Mine/src/hooks/usePostAddSection.ts
    • magazineIdmessage를 받아 매거진에 섹션을 추가하는 useMutation 훅이 새로 추가되었습니다.
  • Mine/src/hooks/usePostAddSectionInSectionPage.ts
    • magazineId, sectionId, message를 받아 특정 섹션 페이지에 섹션을 추가하는 useMutation 훅이 새로 추가되었습니다.
  • Mine/src/types/magazine.ts
    • 섹션 추가 요청 및 응답에 필요한 RequestAddSection, RequestAddSectionInSectionPage, ResponseAddSection, ResponseAddSectionInSectionPage 타입 정의가 추가되었습니다.
  • Mine/vite.config.ts
    • 개발 서버의 /api 프록시 대상이 http://52.63.142.228:8080에서 https://api.minelover.com으로 변경되었습니다.
Activity
  • 현재까지 이 PR에 대한 특별한 활동은 없습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 LLMInputBox 컴포넌트를 여러 페이지에 연결하고, 각 페이지의 컨텍스트에 맞는 API를 호출하도록 하는 변경 사항을 포함하고 있습니다. 전반적으로 PR의 목표는 잘 달성되었으나, 코드의 가독성과 유지보수성을 높일 수 있는 몇 가지 개선점이 보입니다. 특히, 중복되는 타입 정의를 제거하고, React hook과 컴포넌트 로직을 더 간결하게 리팩토링하는 것을 제안합니다. 또한, 사용자 경험에 영향을 줄 수 있는 alert 사용 대신 다른 오류 처리 방식을 고려해 보시는 것이 좋겠습니다.

},
onError: (error) => {
console.log('섹션 생성:', error)
alert('섹션 생성에 실패했습니다.')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

alert()는 사용자의 흐름을 방해하고 좋지 않은 사용자 경험을 제공할 수 있습니다. 에러 메시지를 표시하기 위해 토스트 UI 컴포넌트나 페이지 내 메시지 영역을 사용하는 것을 고려해 보세요. 이는 사용자에게 더 나은 피드백을 제공하고 애플리케이션의 일관성을 유지하는 데 도움이 됩니다.

References
  1. Using a consistent toast message for user feedback, especially for error messages, aligns with providing a better and more consistent user experience across different actions within the same conceptual flow.

},
onError: (error) => {
console.log('섹션 생성:', error)
alert('섹션 생성에 실패했습니다.')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

alert()는 사용자의 흐름을 방해하고 좋지 않은 사용자 경험을 제공할 수 있습니다. 에러 메시지를 표시하기 위해 토스트 UI 컴포넌트나 페이지 내 메시지 영역을 사용하는 것을 고려해 보세요. 이는 사용자에게 더 나은 피드백을 제공하고 애플리케이션의 일관성을 유지하는 데 도움이 됩니다.

References
  1. Using a consistent toast message for user feedback, especially for error messages, aligns with providing a better and more consistent user experience across different actions within the same conceptual flow.

Comment on lines +100 to +103
const body = {
message: message,
}
const res = await axiosInstance.post(`api/magazines/${magazineId}/interact`, body)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

body 객체를 생성하는 부분을 객체 속성 축약 구문을 사용하여 간소화하고, axiosInstance.post 호출에 직접 인라인으로 전달할 수 있습니다. 이렇게 하면 코드가 더 간결해집니다.

    const res = await axiosInstance.post(`api/magazines/${magazineId}/interact`, { message })

Comment on lines +111 to +114
const body = {
message: message,
}
const res = await axiosInstance.post(`api/magazines/${magazineId}/sections/${sectionId}/interact`, body)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 함수에서도 마찬가지로 body 객체 생성을 간소화하고 axiosInstance.post 호출에 인라인으로 전달하여 코드를 더 간결하게 만들 수 있습니다.

    const res = await axiosInstance.post(`api/magazines/${magazineId}/sections/${sectionId}/interact`, { message })

Comment on lines +25 to +53
let handleSend = (value: string) => {
console.log('기본 전송:', value)
}
if (!isLoggedIn || isHiddenPath) return null
if (!isHiddenPath && sectionMatch) {
const { magazineId, sectionId } = sectionMatch.params
handleSend = async (value: string) => {
postAddInSectionPageMutation.mutate({
magazineId: Number(magazineId),
sectionId: Number(sectionId),
message: value,
})
}
} else if (!isHiddenPath && magazineMatch && isNumericMagazineId) {
const { magazineId } = magazineMatch.params
handleSend = async (value: string) => {
postAddSectionMutation.mutate({
magazineId: Number(magazineId),
message: value,
})
}
} else if (!isHiddenPath) {
handleSend = async (value: string) => {
postMagazineMutation.mutate({
topic: value,
user_mood: '',
})
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

handleSend 함수를 결정하는 로직이 다소 복잡하고 여러 번 재할당되고 있습니다. 이 로직을 하나의 함수로 통합하여 가독성을 높이고, 불필요한 async 키워드와 중복되는 !isHiddenPath 조건 체크를 제거하는 것이 좋습니다. 또한 let을 사용한 재할당 대신 const로 함수를 한 번만 정의하면 코드의 흐름을 파악하기 더 쉬워집니다.

    if (!isLoggedIn || isHiddenPath) return null

    const handleSend = (value: string) => {
        if (sectionMatch) {
            const { magazineId, sectionId } = sectionMatch.params
            postAddInSectionPageMutation.mutate({
                magazineId: Number(magazineId),
                sectionId: Number(sectionId),
                message: value,
            })
        } else if (magazineMatch && isNumericMagazineId) {
            const { magazineId } = magazineMatch.params
            postAddSectionMutation.mutate({
                magazineId: Number(magazineId),
                message: value,
            })
        } else {
            postMagazineMutation.mutate({
                topic: value,
                user_mood: '',
            })
        }
    }

export default function usePostAddSection() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: ({ magazineId, message }: RequestAddSection) => postAddSection({ magazineId, message }),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

mutationFn에 전달된 화살표 함수는 postAddSection 함수를 그대로 호출하고 있습니다. 이 경우, 함수 자체를 직접 전달하여 코드를 더 간결하게 만들 수 있습니다.

Suggested change
mutationFn: ({ magazineId, message }: RequestAddSection) => postAddSection({ magazineId, message }),
mutationFn: postAddSection,

Comment on lines +8 to +9
mutationFn: ({ magazineId, sectionId, message }: RequestAddSectionInSectionPage) =>
postAddSectionInSectionPage({ magazineId, sectionId, message }),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

mutationFn에 전달된 화살표 함수는 postAddSectionInSectionPage 함수를 그대로 호출하고 있습니다. 이 경우, 함수 자체를 직접 전달하여 코드를 더 간결하게 만들 수 있습니다.

        mutationFn: postAddSectionInSectionPage,

Comment on lines +165 to +177
export type ResponseAddSectionInSectionPage = {
message: string
actionType: string
section: {
heading: string
paragraphs: Paragraph[]
sectionId: number
thumbnailUrl: string
layoutType: string
layoutHint: string
displayOrder: number
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ResponseAddSectionInSectionPage 타입이 ResponseAddSection 타입과 완전히 동일합니다. 코드 중복을 피하고 유지보수성을 높이기 위해 ResponseAddSection 타입을 재사용하는 것이 좋습니다.

export type ResponseAddSectionInSectionPage = ResponseAddSection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DEV] LLMInputBox API 연결

1 participant