feat(settings): add team appearance setting to hide agent features (#411)

* feat(settings): add team appearance setting to hide agent features

Add an Appearance subpage under Team Settings allowing team owners to toggle appearance.hideAgent for the team. Return appearance.hideAgent in the user-metadata API, and conditionally hide the AGENTS.md button, agent chatbot sidebar, and chatbot trigger button in the WebUI.

* refactor(settings): add strongly typed TeamSettingsResponse to remove explicit any

Introduce TeamSettingsResponse and TeamAppearanceSettings in @shumai/dtos, type TeamService.getSettings and updateSettings, and eliminate the explicit any cast in AppearanceSettings.tsx.
This commit is contained in:
Yiling-J
2026-09-17 18:31:43 +08:00
committed by GitHub
parent 7af3647913
commit e2f741eda6
18 changed files with 458 additions and 43 deletions
+8 -2
View File
@@ -363,20 +363,26 @@ describe('TeamService', () => {
})
const settings = await teamService.getSettings(team.id)
expect(settings).toEqual({ semanticSearchEnabled: false })
expect(settings).toEqual({ semanticSearchEnabled: false, appearance: { hideAgent: false } })
await teamService.updateSettings(team.id, 'theme', 'dark')
const newSettings = await teamService.getSettings(team.id)
expect(newSettings).toEqual({ theme: 'dark', semanticSearchEnabled: false })
expect(newSettings).toEqual({
theme: 'dark',
semanticSearchEnabled: false,
appearance: { hideAgent: false },
})
await teamService.updateSettings(team.id, 'transcode.videoStrategy', 'all')
await teamService.updateSettings(team.id, 'transcode.hardwareAcceleration', 'auto')
await teamService.updateSettings(team.id, 'appearance.hideAgent', true)
const finalSettings = await teamService.getSettings(team.id)
expect(finalSettings).toEqual({
theme: 'dark',
transcode: { videoStrategy: 'all', hardwareAcceleration: 'auto' },
appearance: { hideAgent: true },
semanticSearchEnabled: false,
})
})
+25 -12
View File
@@ -19,6 +19,7 @@ import {
UserInfo,
SandboxSettings,
UpdateSandboxSettingsRequest,
TeamSettingsResponse,
} from '@shumai/dtos'
export class TeamService {
@@ -288,53 +289,65 @@ export class TeamService {
})
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async getSettings(teamId: string): Promise<any> {
async getSettings(teamId: string): Promise<TeamSettingsResponse> {
const team = await prisma.team.findUnique({
where: { id: teamId },
})
if (!team) throw new HTTPException(404, { message: 'team not found' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const settings = (team.settings || {}) as any
const settings = (team.settings || {}) as TeamSettingsResponse
const embeddingAgent = await prisma.agent.findFirst({
where: { teamId, type: 'embedding', enabled: true },
})
settings.semanticSearchEnabled = !!embeddingAgent
if (!settings.appearance) {
settings.appearance = { hideAgent: false }
} else if (settings.appearance.hideAgent === undefined) {
settings.appearance.hideAgent = false
}
return settings
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async updateSettings(teamId: string, key: string, value: any): Promise<any> {
async updateSettings(teamId: string, key: string, value: unknown): Promise<TeamSettingsResponse> {
const team = await prisma.team.findUnique({ where: { id: teamId } })
if (!team) throw new HTTPException(404, { message: 'team not found' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const settings = (team.settings || {}) as any
const settings = (team.settings || {}) as TeamSettingsResponse
if (key === 'transcode.videoStrategy') {
if (!settings.transcode) {
settings.transcode = {}
}
settings.transcode.videoStrategy = value
settings.transcode.videoStrategy = value as NonNullable<
TeamSettingsResponse['transcode']
>['videoStrategy']
delete settings['transcode.videoStrategy']
} else if (key === 'transcode.hardwareAcceleration') {
if (!settings.transcode) {
settings.transcode = {}
}
settings.transcode.hardwareAcceleration = value
settings.transcode.hardwareAcceleration = value as NonNullable<
TeamSettingsResponse['transcode']
>['hardwareAcceleration']
delete settings['transcode.hardwareAcceleration']
} else if (key === 'appearance.hideAgent') {
if (!settings.appearance) {
settings.appearance = {}
}
settings.appearance.hideAgent = Boolean(value)
delete settings['appearance.hideAgent']
} else {
settings[key] = value
}
const updated = await prisma.team.update({
where: { id: teamId },
data: { settings },
data: { settings: settings as unknown as PrismaJson.Settings },
})
return updated.settings || {}
return (updated.settings || {}) as TeamSettingsResponse
}
async getSandboxSettings(teamId: string): Promise<SandboxSettings> {