Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 85 additions & 7 deletions ui/src/conversation-panel/core/layout/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, useSlots } from 'vue'
import { computed, ref, useSlots, useTemplateRef } from 'vue'
import type { SidePanelMode } from './types'

const props = withDefaults(
Expand All @@ -9,7 +9,10 @@ const props = withDefaults(
leftMode?: SidePanelMode
rightMode?: SidePanelMode
leftWidth?: number
rightWidth?: number
/** 数字按 px;字符串为 CSS 宽度,可用 cqw 按布局宽度取比例 */
rightWidth?: number | string
/** 挤压态右侧栏可拖动左边缘调整宽度,宽度由外层按 right-resize 更新 */
rightResizable?: boolean
rightDrawerTarget?: HTMLElement
}>(),
{
Expand All @@ -20,18 +23,46 @@ const props = withDefaults(
},
)

defineEmits<{ 'mask-click': [] }>()
const emit = defineEmits<{
'mask-click': []
/** 拖动中的右侧栏宽度与布局宽度(px),由外层限定范围 */
'right-resize': [width: number, layoutWidth: number]
'right-resize-reset': []
}>()

const slots = useSlots()
const hasRight = computed(() => !!slots.right)
const teleportRightDrawer = computed(() => props.rightMode === 'drawer' && !!props.rightDrawerTarget)

const rightWidthStyle = computed(() => (typeof props.rightWidth === 'number' ? `${props.rightWidth}px` : props.rightWidth))

const showMask = computed(() => (props.leftMode === 'drawer' && props.leftOpen) || (props.rightMode === 'drawer' && props.rightOpen))

const layoutRef = useTemplateRef<HTMLElement>('layoutRef')
const showRightResizeHandle = computed(() => props.rightResizable && props.rightMode === 'push' && props.rightOpen)
const rightResizing = ref(false)

// 按住拖拽条开始调整宽度;捕获指针,划过 iframe 时也能持续收到移动事件
const startRightResize = (event: PointerEvent) => {
if (event.button !== 0) return
event.preventDefault()
;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)
rightResizing.value = true
}

// 宽度取布局右边缘到指针的距离,不累计位移,拖出范围再拖回也不会错位
const moveRightResize = (event: PointerEvent) => {
if (!rightResizing.value || !layoutRef.value) return
const rect = layoutRef.value.getBoundingClientRect()
emit('right-resize', Math.round(rect.right - event.clientX), rect.width)
}

const endRightResize = () => (rightResizing.value = false)
</script>

<template>
<!-- 布局壳(纯展示):左/主/右三区 + 挤压/抽屉 + 遮罩。状态由外层传入,自身不含业务。 -->
<div class="relative flex h-full overflow-hidden">
<div ref="layoutRef" class="@container relative flex h-full w-full overflow-hidden" :class="{ 'select-none': rightResizing }">
<aside
class="mk-conversation-side-panel left shrink-0 overflow-hidden"
:class="[leftMode, { open: leftOpen }]"
Expand All @@ -46,14 +77,61 @@ const showMask = computed(() => (props.leftMode === 'drawer' && props.leftOpen)
<aside
v-if="hasRight"
class="mk-conversation-side-panel right shrink-0 overflow-hidden"
:class="[rightMode, { open: rightOpen }]"
:style="{ '--mk-chat-right-width': rightWidth + 'px' }"
:class="[rightMode, { open: rightOpen, resizing: rightResizing }]"
:style="{ '--mk-chat-right-width': rightWidthStyle }"
>
<div class="mk-conversation-side-panel__inner"><slot name="right" /></div>
<div class="mk-conversation-side-panel__inner relative">
<!-- 拖动调整右侧栏宽度,双击恢复默认宽度 -->
<div
v-if="showRightResizeHandle"
class="mk-conversation-resize-handle"
@pointerdown="startRightResize"
@pointermove="moveRightResize"
@pointerup="endRightResize"
@pointercancel="endRightResize"
@lostpointercapture="endRightResize"
@dblclick="emit('right-resize-reset')"
/>
<div class="h-full" :class="{ 'pointer-events-none': rightResizing }"><slot name="right" /></div>
</div>
</aside>

<!-- 点击遮罩收起抽屉侧栏 -->
<div v-if="showMask" class="mk-conversation-mask" @click="$emit('mask-click')" />
</Teleport>
</div>
</template>

<style scoped lang="scss">
/* 拖动时宽度直接跟随指针,不走展开收起的宽度动画 */
.mk-conversation-side-panel.resizing {
transition: none;
}

/* 右侧栏左边缘的拖拽条:悬停或拖动时显示主题色细线 */
.mk-conversation-resize-handle {
bottom: 0;
cursor: col-resize;
left: 0;
position: absolute;
top: 0;
width: 6px;
z-index: 10;

&::after {
background: transparent;
bottom: 0;
content: '';
left: 0;
position: absolute;
top: 0;
transition: background-color 0.15s;
width: 2px;
}

&:hover::after,
.resizing &::after {
background: var(--mk-primary);
}
}
</style>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's a review of the patch.

Bugs / irregularities

  1. &::after selector is corrupted — [IP]ter.
    In the SCSS block the pseudo-element is written as &[IP]ter (and in the hover rules). This is invalid and the resize line will never render. It should be:

    &::after { ... }
    &:hover::after,
    .resizing &::after { background: var(--mk-primary); }

    The .resizing &::after rule also requires an ancestor with .resizing, but right-resizing class is applied to the <aside>, not the wrapper .mk-conversation-side-panel__inner. Verify the selector really matches; otherwise use .mk-conversation-side-panel.resizing .mk-conversation-resize-handle::after.

  2. @container added on the layout root, but no consumer. You reference cqw in the docs for rightWidth, but nothing declares a container query context name nor uses cqw in this file. Either document how --mk-chat-right-width consumes it, or drop @container here (the class only establishes a container if something queries it).

  3. pointermove on the handle without pointer capture flow verification. setPointerCapture is called in startRightResize, so pointermove/pointerup will fire on the handle element even outside it — good. But if event.currentTarget is typed loosely, guard against null. Also consider handling pointerleave only when not captured (currently you rely solely on capture — fine, but note it).

  4. endRightResize is attached to both pointercancel and lostpointercapture — that's redundant but harmless; it just sets a boolean twice.

  5. No cleanup of capture on unmount. If the component unmounts mid-drag, the boolean stays true and the select-none class relies on state that's gone. Minor, but a onBeforeUnmount(() => rightResizing.value = false) is cheap insurance.

  6. rightWidthStyle can return undefined. When rightWidth is undefined, the computed returns undefined, producing '--mk-chat-right-width': undefined. Confirm the CSS has a fallback/default, otherwise the variable may be set to empty unexpectedly. Prefer:

    const rightWidthStyle = computed(() =>
      typeof props.rightWidth === 'number' ? `${props.rightWidth}px`
        : props.rightWidth ?? undefined)
  7. layoutRef with useTemplateRef<HTMLElement>('layoutRef') — the generic should match the ref'd element; HTMLElement is fine for a <div>, just make sure the Vue version supports useTemplateRef (Vue 3.5+). If you're on <3.5, this breaks the build.

  8. emit type signature: 'right-resize-reset': [] is correct, but in the template you call emit('right-resize-reset') — fine. However the mask still uses $emit while others use emit; consistent enough but worth standardizing.

Potential issues

  • Emitting raw pixel width without clamping here is intentional (outer layer clamps), but the outer must also handle a zero/negative value when the pointer passes the right edge (rect.right - clientX can go negative). Note this in the contract or clamp defensively.
  • pointer-events-none on the slot wrapper during resize prevents accidental iframe/text interaction — good, but users can't scroll the panel while dragging. Acceptable, just a UX note.
  • getBoundingClientRect() on every pointermove causes layout read each move. Pointer events can fire at high frequency; consider throttling via requestAnimationFrame, or cache rect.right/rect.width at drag start (only stale if the window resizes mid-drag, which is rare). This is the main perf optimization.
  • rightResizable combined with rightMode === 'push' only shows the handle in push mode. If drawer mode should also be resizable, the condition excludes it — verify that's intended.
  • Teleported drawer slot content also receives a nested pointer-events-none wrapper — same caveat as above.

Optimization suggestions

  1. Fix the [IP]ter corruption first (functional bug).
  2. Cache the layout rect at pointerdown; recompute lazily (e.g., on resize) instead of every move.
  3. Optionally rAF-throttle emit('right-resize', ...) to reduce downstream re-renders.
  4. Add touch-action: none on .mk-conversation-resize-handle so touch pointers don't scroll while resizing.
  5. Consider user-select: none directly on the handle during drag rather than on the whole layout (select-none on root is broad).
  6. Standardize emit usage (emit(...) everywhere vs $emit(...)) and add explicit default for rightResizable in withDefaults if it isn't false by convention.

88 changes: 86 additions & 2 deletions ui/src/conversation-panel/right-sidebar/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { inject, ref } from 'vue'
import { computed, inject, ref, toValue, watch } from 'vue'
import type { ChatRecordMeta } from '../core/types'
import type { PreviewFile } from './file-preview/index'
import type { ChatParagraphSource } from '@/api/types'
import type { InjectionKey } from 'vue'
import type { InjectionKey, MaybeRefOrGetter, Ref } from 'vue'
import { createExecutionDetailStore } from './execution-detail/index'
import { createFilePreviewStore } from './file-preview/index'
import { createKnowledgeSourceStore } from './knowledge-source/index'
Expand All @@ -16,6 +16,35 @@ export const RIGHT_SIDEBAR_PANEL = {

export type RightSidebarPanel = (typeof RIGHT_SIDEBAR_PANEL)[keyof typeof RIGHT_SIDEBAR_PANEL]

/**
* 右侧栏宽度:执行详情、知识来源固定 420px;文件预览默认取对话区一半(420px–960px),可拖动调整并记住。
* 拖动后的宽度至少 420px,并为对话区保留至少 360px;窗口变窄时按当前上限显示,不改写记住的宽度。cqw 以对话布局宽度为基准。
*/
const RIGHT_SIDEBAR_WIDTH = 420
const FILE_PREVIEW_DEFAULT_WIDTH = 'clamp(420px, 50cqw, 960px)'
const FILE_PREVIEW_MIN_WIDTH = 420
const CONVERSATION_MIN_WIDTH = 360
const FILE_PREVIEW_WIDTH_STORAGE_KEY = 'conversation-file-preview-width'

// 读取记住的文件预览宽度;嵌入页禁用存储等读取失败时按未调整处理
function readFilePreviewWidth(): number | null {
try {
const width = Number(localStorage.getItem(FILE_PREVIEW_WIDTH_STORAGE_KEY))
return width >= FILE_PREVIEW_MIN_WIDTH ? width : null
} catch {
return null
}
}

function writeFilePreviewWidth(width: number | null) {
try {
if (width == null) localStorage.removeItem(FILE_PREVIEW_WIDTH_STORAGE_KEY)
else localStorage.setItem(FILE_PREVIEW_WIDTH_STORAGE_KEY, String(width))
} catch {
// 存储不可用时只在本次页面内生效
}
}

/**
* 右侧栏 store:当前面板与右侧开合,组合各面板自己的 store。
* 由 view 创建并 provide;消息底部点击「执行详情」「知识来源」、回答中点击可预览文件时写入对应面板数据并打开右侧。
Expand All @@ -26,6 +55,28 @@ export function createRightSidebarStore() {
const executionDetail = createExecutionDetailStore()
const knowledgeSource = createKnowledgeSourceStore()
const filePreview = createFilePreviewStore()
const filePreviewWidth = ref(readFilePreviewWidth())
/** 只有文件预览可拖动调整宽度 */
const rightResizable = computed(() => panel.value === RIGHT_SIDEBAR_PANEL.FILE_PREVIEW)
const rightWidth = computed(() => {
if (!rightResizable.value) return RIGHT_SIDEBAR_WIDTH
if (filePreviewWidth.value == null) return FILE_PREVIEW_DEFAULT_WIDTH
return `clamp(${FILE_PREVIEW_MIN_WIDTH}px, ${filePreviewWidth.value}px, calc(100cqw - ${CONVERSATION_MIN_WIDTH}px))`
})

// 拖动调整文件预览宽度,按当前布局宽度限定范围后记住
const resizeRight = (width: number, layoutWidth: number) => {
if (!rightResizable.value) return
const maxWidth = Math.max(FILE_PREVIEW_MIN_WIDTH, layoutWidth - CONVERSATION_MIN_WIDTH)
filePreviewWidth.value = Math.round(Math.min(Math.max(width, FILE_PREVIEW_MIN_WIDTH), maxWidth))
writeFilePreviewWidth(filePreviewWidth.value)
}

// 恢复文件预览默认宽度
const resetRightWidth = () => {
filePreviewWidth.value = null
writeFilePreviewWidth(null)
}

const openPanel = (target: RightSidebarPanel) => {
panel.value = target
Expand Down Expand Up @@ -53,6 +104,10 @@ export function createRightSidebarStore() {
return {
panel,
rightSideOpen,
rightWidth,
rightResizable,
resizeRight,
resetRightWidth,
executionDetail,
knowledgeSource,
filePreview,
Expand All @@ -65,6 +120,35 @@ export function createRightSidebarStore() {

export type RightSidebarStore = ReturnType<typeof createRightSidebarStore>

/**
* 挤压态下文件预览与左侧栏互相让位,避免对话区被两侧挤窄:
* 打开文件预览时收起左侧栏,预览关闭或切到其他面板后恢复由预览收起的左侧栏;预览中展开左侧栏则关闭预览。
* 抽屉态两侧都覆盖在对话区上,不处理。
*/
export function bindFilePreviewLeftSide(rightSidebar: RightSidebarStore, leftSideOpen: Ref<boolean>, pushMode: MaybeRefOrGetter<boolean>) {
const previewOpen = computed(() => rightSidebar.rightSideOpen.value && rightSidebar.panel.value === RIGHT_SIDEBAR_PANEL.FILE_PREVIEW)
let collapsedByPreview = false

watch(previewOpen, (open) => {
if (!toValue(pushMode)) {
collapsedByPreview = false
return
}
if (open && leftSideOpen.value) {
collapsedByPreview = true
leftSideOpen.value = false
} else if (!open && collapsedByPreview) {
collapsedByPreview = false
leftSideOpen.value = true
}
})
watch(leftSideOpen, (open) => {
if (!open || !previewOpen.value || !toValue(pushMode)) return
collapsedByPreview = false
rightSidebar.closeRightSide()
})
}

export const RIGHT_SIDEBAR_KEY: InjectionKey<RightSidebarStore> = Symbol('right-sidebar')

export function useRightSidebarStore(): RightSidebarStore {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code Review: Right Sidebar Store Changes

Overall Assessment

The changes are generally well-structured, but there are several issues worth addressing.


Issues & Potential Bugs

1. rightWidth returns mixed types (number | string) — Type inconsistency

const rightWidth = computed(() => {
  if (!rightResizable.value) return RIGHT_SIDEBAR_WIDTH   // number: 420
  ...
  return `clamp(...)`                                      // string
})

The return type is number | string. Callers must handle both. Consider always returning a CSS string (e.g., '420px') for consistency, or documenting the union clearly.

2. readFilePreviewWidth misinterprets null in localStorage

const width = Number(localStorage.getItem(FILE_PREVIEW_WIDTH_STORAGE_KEY))
return width >= FILE_PREVIEW_MIN_WIDTH ? width : null
  • localStorage.getItem returns null when unset → Number(null) === 0, so it's treated as invalid (fine).
  • But storing an empty string "" also becomes 0 (fine).
  • More importantly, NaN from non-numeric storage → comparison is false → returns null. OK, but fragile. Prefer:
const raw = localStorage.getItem(KEY)
if (raw == null) return null
const width = Number(raw)
return Number.isFinite(width) && width >= FILE_PREVIEW_MIN_WIDTH ? width : null

3. bindFilePreviewLeftSide won't restore left sidebar if pushMode changes between open/close

Consider this sequence:

  1. pushMode = true, preview opens → collapsedByPreview = true, left closes.
  2. User toggles pushMode to false while preview is open.
  3. Preview closes → watch fires but pushMode is false, so enters the !toValue(pushMode) branch and resets collapsedByPreview = false without restoring the left sidebar.

The left sidebar stays collapsed unexpectedly. You likely want logic that still restores when not in push mode, or at least document this behavior.

4. watch(previewOpen, ...) lacks { immediate: true } — probably intentional

Since previewOpen starts false, no issue. But be aware if initial state ever changes.

5. resizeRight has an edge case when layoutWidth is 0 or invalid

const maxWidth = Math.max(FILE_PREVIEW_MIN_WIDTH, layoutWidth - CONVERSATION_MIN_WIDTH)

If layoutWidth < CONVERSATION_MIN_WIDTH, maxWidth becomes 420, then Math.min(Math.max(width, 420), 420) = 420. That works but silently forces 420 even when conversation area can't hold it. Acceptable given the comment, but the writeFilePreviewWidth call will still persist that value, potentially overriding a legitimate larger remembered value with 420 on a transient/incorrect layout read. Consider skipping the persist if layoutWidth is suspiciously small.

6. Infinite loop risk between the two watchers

watch(previewOpen, (open) => { if (open && leftSideOpen.value) { ... leftSideOpen.value = false } })
watch(leftSideOpen, (open) => { if (!open || !previewOpen.value) return; ... closeRightSide() })

Trace: preview opens → leftSideOpen = false → second watcher fires (open=false) → returns early. OK.
But consider: preview open + user sets leftSideOpen = true → second watcher fires → closeRightSide() → first watcher sees open=false, collapsedByPreview was set false just before, so no restore. Safe, but tightly coupled — easier to reason about with a single combined function or explicit state machine. Recommend adding a comment explaining why the ordering of collapsedByPreview = false before closeRightSide() matters.

7. cqw unit requires container query context

FILE_PREVIEW_DEFAULT_WIDTH = 'clamp(420px, 50cqw, 960px)' and 100cqw in rightWidth assume the component is inside a container query context. If container-type: inline-size isn't set on an ancestor, cqw resolves against the viewport (or falls back). This should be verified / documented.

8. RESET behavior doesn't re-clamp against current layout

resetRightWidth sets filePreviewWidth = null, which uses the default clamp(420px, 50cqw, 960px). Fine. But note: after reset, the effective width may exceed 100cqw - 360px on narrow screens in the default expression (since default clamp caps at 960px but not at 100cqw - 360px). Inconsistent clamping vs. the remembered-width branch. Consider unifying:

return filePreviewWidth.value == null
  ? `clamp(${MIN}px, min(50cqw, calc(100cqw - ${CONVERSATION_MIN_WIDTH}px)), 960px)`
  : ...

9. Minor: typo risk in comments — Chinese comments mention "可拖动" etc.; ensure team reads them. Not a bug.

10. No cleanup on unmount

createRightSidebarStore creates refs and (in bindFilePreviewLeftSide) watchers. If bindFilePreviewLeftSide is called inside a component setup, watchers auto-dispose. But if called outside a reactive effect scope, they leak. Confirm it's always invoked during setup or wrap in effectScope.


Optimization Suggestions

Suggestion Benefit
Always return CSS-string rightWidth Simpler consumer code
Use a STORAGE_KEY constant shared with tests Avoid magic strings
Debounce writeFilePreviewWidth during drag Avoid excessive localStorage.setItem calls (storage API is synchronous)
Use Number.isFinite guard in readFilePreviewWidth Robustness
Combine two watchers into a single watch([previewOpen, leftSideOpen], ...) with clearer state transitions Easier reasoning
Add explicit type: const filePreviewWidth = ref<number | null>(readFilePreviewWidth()) TS strict inference
Export constants (RIGHT_SIDEBAR_WIDTH, etc.) for reuse/testing Testability

Style Notes

  • Consider extracting inline Chinese comments into English or maintain bilingual docs if this is a shared repo (review request is in English).
  • The @ -1,8 +1,8 @@ diff header hints at a truncated diff; ensure the full file compiles (imports toValue and watch are used only in the new helper — good).

Summary

Functional logic is sound, but I recommend: (1) fix the pushMode toggle edge case in bindFilePreviewLeftSide, (2) harden readFilePreviewWidth with Number.isFinite, (3) unify clamp behavior between default and remembered widths, and (4) debounce persistence writes during drag.

Expand Down
8 changes: 7 additions & 1 deletion ui/src/conversation-panel/view/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ConversationLayout from '../../core/layout/index.vue'
import { CONVERSATION_LIST_KEY } from '../../left-sidebar/conversation-list/index'
import ConversationList from '../../left-sidebar/conversation-list/index.vue'
import ChatPanel from '../../main/chat-panel/index.vue'
import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { CHAT_USER_PROFILE_KEY, DEVICE_KEY, SHOW_SHARE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
import { createChatConversation, createChatUserProfileGetter } from './index'
Expand Down Expand Up @@ -55,6 +55,8 @@ bundle.list.bindLeftSideMode(leftMode)
const rightMode = computed(() => (isMobile.value ? 'drawer' : 'push'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
// 挤压态下文件预览与左侧栏互相让位
bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')

const closeDrawers = () => {
if (leftMode.value === 'drawer') bundle.list.leftSideOpen.value = false
Expand Down Expand Up @@ -83,9 +85,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig
<ConversationLayout
:left-open="bundle.list.leftSideOpen.value"
:right-open="bundle.rightSidebar.rightSideOpen.value"
:right-width="bundle.rightSidebar.rightWidth.value"
:right-resizable="bundle.rightSidebar.rightResizable.value"
:left-mode="leftMode"
:right-mode="rightMode"
@mask-click="closeDrawers"
@right-resize="bundle.rightSidebar.resizeRight"
@right-resize-reset="bundle.rightSidebar.resetRightWidth"
>
<template #left><ConversationList /></template>
<template #main><ChatPanel /></template>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review of the diff:

1. Potential circular/tight coupling
bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, ...) creates a direct temporal dependency: the file preview state must be bound after both bundle.rightSidebar and bundle.list already exist. If initialization order changes (e.g. lazy init, or a refactor of the bundle factory), this silently breaks without a compile error. Consider having the binding logic live inside the bundle factory / right-sidebar module itself instead of the layout component.

2. Reactivity in the predicate
The third argument () => leftMode.value === 'push' is passed as a getter. Confirm the internal implementation calls it reactively (inside a computed/watchEffect) and not just once at bind time—otherwise "push vs drawer" switches won't re-evaluate, causing a stale squeeze behavior on device resize / orientation change.

3. Missing cleanup / unbind
There's no corresponding unbindFilePreviewLeftSide (or onUnmounted cleanup) shown. If the layout can mount/unmount multiple times (HMR, route switching, tests), the binding may leak or double-register. Verify idempotency or add cleanup.

4. Manual .value unwrapping in template

:left-open="bundle.list.leftSideOpen.value"

This forces Vue to touch a ref inside the render function rather than letting auto-unwrapping handle it, and is inconsistent with idiomatic usage. If these are plain refs, passing them in a way that preserves reactivity (e.g. toRef-based getters or keeping them reactive properties) is cleaner and avoids accidental non-reactive copies if someone later wraps them.

5. Event naming consistency
@right-resize and @right-resize-reset are custom events emitted by ConversationLayout; make sure they're declared via defineEmits in the child (and that resizeRight/resetRightWidth signatures match any payload the child emits, e.g. a pixel width). Passing the handler directly as bundle.rightSidebar.resizeRight relies on the method being pre-bound (no this); verify it doesn't depend on its binding context.

6. Width state ownership duplication
rightWidth is now read from bundle.rightSidebar and also presumably mutated via resizeRight. Ensure single source of truth — the resize handler should update the same ref that's fed into :right-width, and that clamping/bounds logic lives in one place (not split between layout and sidebar).

7. Minor style suggestion
Add an explicit return type / guard for the leftMode computed ('push' | 'drawer'), and document why push/drawer corresponds to desktop/mobile, since the inject comment ("左栏为抽屉即手机端") is in Chinese while the rest of the codebase comments appear mixed—consider standardizing.

No functional bugs are evident from the diff itself, but items 1–3 (binding lifecycle/reactivity/cleanup) are the highest-risk areas to verify.

Expand Down
8 changes: 7 additions & 1 deletion ui/src/conversation-panel/view/debug/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ConversationLayout from '../../core/layout/index.vue'
import { CONVERSATION_LIST_KEY } from '../../left-sidebar/conversation-list/index'
import ConversationList from '../../left-sidebar/conversation-list/index.vue'
import ChatPanel from '../../main/chat-panel/index.vue'
import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { DEVICE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
import { createDebugConversation } from './index'
Expand Down Expand Up @@ -56,6 +56,8 @@ const leftMode = computed(() => (debug.expanded.value ? 'push' : 'drawer'))
const rightMode = computed(() => (debug.expanded.value ? 'push' : 'drawer'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
// 挤压态下文件预览与左侧栏互相让位
bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')

// 抽屉态:遮罩点击 / 切换会话 → 收起
const closeDrawers = () => {
Expand Down Expand Up @@ -85,9 +87,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig
<ConversationLayout
:left-open="bundle.list.leftSideOpen.value"
:right-open="bundle.rightSidebar.rightSideOpen.value"
:right-width="bundle.rightSidebar.rightWidth.value"
:right-resizable="bundle.rightSidebar.rightResizable.value"
:left-mode="leftMode"
:right-mode="rightMode"
@mask-click="closeDrawers"
@right-resize="bundle.rightSidebar.resizeRight"
@right-resize-reset="bundle.rightSidebar.resetRightWidth"
>
<template #left><ConversationList /></template>
<template #main>
Expand Down
8 changes: 7 additions & 1 deletion ui/src/conversation-panel/view/embed/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ConversationLayout from '../../core/layout/index.vue'
import { CONVERSATION_LIST_KEY } from '../../left-sidebar/conversation-list/index'
import ConversationList from '../../left-sidebar/conversation-list/index.vue'
import ChatPanel from '../../main/chat-panel/index.vue'
import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { createChatUserProfileGetter } from '../chat/index'
import { CHAT_USER_PROFILE_KEY, DEVICE_KEY, SHOW_SHARE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
Expand Down Expand Up @@ -59,6 +59,8 @@ bundle.list.bindLeftSideMode(leftMode)
const rightMode = computed(() => (isMobile.value ? 'drawer' : 'push'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
// 挤压态下文件预览与左侧栏互相让位
bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')

const closeDrawers = () => {
if (leftMode.value === 'drawer') bundle.list.leftSideOpen.value = false
Expand Down Expand Up @@ -87,9 +89,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig
<ConversationLayout
:left-open="bundle.list.leftSideOpen.value"
:right-open="bundle.rightSidebar.rightSideOpen.value"
:right-width="bundle.rightSidebar.rightWidth.value"
:right-resizable="bundle.rightSidebar.rightResizable.value"
:left-mode="leftMode"
:right-mode="rightMode"
@mask-click="closeDrawers"
@right-resize="bundle.rightSidebar.resizeRight"
@right-resize-reset="bundle.rightSidebar.resetRightWidth"
>
<template #left><ConversationList /></template>
<template #main>
Expand Down
8 changes: 7 additions & 1 deletion ui/src/conversation-panel/view/portal/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PORTAL_CONVERSATION_LIST_KEY } from '../../left-sidebar/portal-conversa
import PortalConversationList from '../../left-sidebar/portal-conversation-list/index.vue'
import PortalApplicationPanel from '../../main/portal-application-panel/index.vue'
import PortalChatPanel from '../../main/portal-chat-panel/index.vue'
import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { createChatUserProfileGetter } from '../chat/index'
import { CHAT_USER_PROFILE_KEY, DEVICE_KEY, SHOW_SHARE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
Expand Down Expand Up @@ -60,6 +60,8 @@ bundle.list.bindLeftSideMode(leftMode)
const rightMode = computed(() => (isMobile.value ? 'drawer' : 'push'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
// 挤压态下文件预览与左侧栏互相让位
bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')

const closeDrawers = () => {
if (leftMode.value === 'drawer') bundle.list.leftSideOpen.value = false
Expand Down Expand Up @@ -89,9 +91,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig
<ConversationLayout
:left-open="bundle.list.leftSideOpen.value"
:right-open="bundle.rightSidebar.rightSideOpen.value"
:right-width="bundle.rightSidebar.rightWidth.value"
:right-resizable="bundle.rightSidebar.rightResizable.value"
:left-mode="leftMode"
:right-mode="rightMode"
@mask-click="closeDrawers"
@right-resize="bundle.rightSidebar.resizeRight"
@right-resize-reset="bundle.rightSidebar.resetRightWidth"
class="portal"
>
<template #left><PortalConversationList /></template>
Expand Down
Loading