feat(core): completely remove the dependence on EditorHost (#13110)

Close [AI-260](https://linear.app/affine-design/issue/AI-260)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added theme support to AI chat and message components, enabling
dynamic theming based on the current app theme.
* Introduced a reactive theme signal to the theme service for improved
theme handling.
* Integrated notification and theme services across various AI chat,
playground, and message components for consistent user experience.

* **Refactor**
* Simplified component APIs by removing dependencies on editor host and
related properties across AI chat, message, and tool components.
* Centralized and streamlined clipboard and markdown conversion
utilities, reducing external dependencies.
* Standardized the interface for context file addition and improved type
usage for better consistency.
* Reworked notification service to a class-based implementation for
improved encapsulation.
* Updated AI chat components to use injected notification and theme
services instead of host-based retrieval.

* **Bug Fixes**
* Improved reliability of copy and notification actions by decoupling
them from editor host dependencies.

* **Chores**
* Updated and cleaned up internal imports and removed unused properties
to enhance maintainability.
  * Added test IDs for sidebar close button to improve test reliability.
  * Updated test prompts in end-to-end tests for consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Wu Yue
2025-07-09 18:16:55 +08:00
committed by GitHub
parent dace1d1738
commit d10e5ee92f
48 changed files with 523 additions and 435 deletions
@@ -1,5 +1,22 @@
import { ColorScheme } from '@blocksuite/affine/model';
import { createSignalFromObservable } from '@blocksuite/affine-shared/utils';
import type { Signal } from '@preact/signals-core';
import { Entity, LiveData } from '@toeverything/infra';
export class AppTheme extends Entity {
theme$ = new LiveData<string | undefined>(undefined);
themeSignal: Signal<ColorScheme>;
constructor() {
super();
const { signal, cleanup } = createSignalFromObservable<ColorScheme>(
this.theme$.map(theme =>
theme === 'dark' ? ColorScheme.Dark : ColorScheme.Light
),
ColorScheme.Light
);
this.themeSignal = signal;
this.disposables.push(cleanup);
}
}
@@ -26,7 +26,7 @@ function Container({
const ToggleButton = ({ onToggle }: { onToggle?: () => void }) => {
return (
<IconButton size="24" onClick={onToggle}>
<IconButton size="24" onClick={onToggle} data-testid="right-sidebar-close">
<RightSidebarIcon />
</IconButton>
);