Skip to content

fix(v2): keep a project's sync status after load and manage its token in the sidebar - #390

Merged
EricWvi merged 2 commits into
ora-space:mainfrom
TannyXie:fix/1227-project-sync-status-ui
Nov 17, 2026
Merged

EricWvi merged 2 commits into
ora-space:mainfrom
TannyXie:fix/1227-project-sync-status-ui

Conversation

@TannyXie

@TannyXie TannyXie commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Refs ora-space/circus#1227

#1057 owner 真实验收发现的两处前端问题(只改 frontend-v2/):

Bug 1:项目页一加载就丢掉同步状态。store.ts 的 connect 把项目映射成 { id, name },丢掉了 syncAt、syncError、syncForcePushed、syncRunning、repositoryTokenConfigured、repositoryTokenSetAt,所以服务端存下的失败原因(包括重启后的「上次同步被中断」)刷新后不显示,进行中的同步按钮也不转。现在这些字段连同项目创建者 id(用于令牌权限)一起进 store,remote.ts 用 projectView 统一映射。

缺口 2:界面上没有令牌状态,也不能更换或清除。项目菜单新增「项目设置」对话框,显示「已配置令牌 · 最后更换时间」或「未配置令牌」:

  • 团队 owner 或项目创建者可以更换令牌:输入框是 password 类型,提交后不回显;关闭对话框时清空输入。
  • 他们也可以清除令牌,清除前二次确认。
  • 两个操作调用已有的 PUT/DELETE …/repository-token,服务端同样只允许 owner 或创建者,其他人返回 403。
  • 其他成员只看到状态,看不到这两个操作。

specs:ADR decisions/cloud/project-git/0-external-repository-pull-and-encrypted-token.md 已是 implemented(I7)。本 PR 只补界面,不改 ADR 和核心用例。

测试:chat 相关测试 52 个全部通过,其中 7 个是新增的:

  • 加载后失败原因可见;
  • 未配置、已配置两种状态的显示;
  • 更换令牌后不回显;
  • 关闭对话框后忘掉输入到一半的令牌;
  • 清除前二次确认;
  • 不是创建者的成员看不到操作。

全量 vitest 939 个通过(既有的 run-flow 在全量运行时会偶发失败,除此之外全部通过);tsc、oxlint、vite build 通过。

… in the sidebar

The chat store dropped every sync field when it loaded projects, so a failure
recorded by the server (including an interrupted sync after a restart) vanished
on load, and an in-flight sync never showed. The project now keeps syncAt,
syncError, syncForcePushed, syncRunning, the token-configured flag and the token
timestamp (plus the creator id, to gate token management).

The project menu gains a settings dialog that reports whether a private-repo
token is configured and when it last changed, and lets a team owner or the
project creator replace or clear it through the existing repository-token API.
The token input is a password and never echoes; other members only see the
status.

@zhangxinhao zhangxinhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM(9353474)

@TannyXie 我看了这个 PR,理解它是要保留项目加载后的同步和令牌状态,并在侧栏提供按权限更换、清除仓库令牌的入口。可以合并,但建议补上加载中同步的状态恢复、新建项目的创建者映射,以及关闭设置后的确认状态重置。相关的 51 个测试全部通过。

  • 🔧 1 处小改已写成建议(P2-2):见行内 suggestion,可以一键采纳,也可以不改或留到以后。
  • 💬 其他建议:P2-1 成员新建项目后看不到令牌操作;P2-3 加载中的同步会永久禁用按钮;nit-1 PR 描述缺少 ADR 状态说明
  • 测试:cd frontend-v2 && npm test -- src/features/chat/page.test.tsx src/features/chat/store.test.ts 通过;没跑全量和 e2e。

涉及鉴权,建议 owner 再看一眼。

没法放到行内的意见

nit-1(可选) 描述已有运行 issue 引用,但缺少团队要求的 ADR 状态说明。建议补上「v2,不涉及 specs」,明确这次仅修改 v2 前端。

以上都是建议,怎么处理由你决定。

自动检视 · 基于 9353474 · 第 1 轮(全量)


/** Whether the signed-in user may manage the project's token: a team owner or the project creator. */
function canManageToken(project: Project, userId: string, role: ReturnType<typeof useRole>): boolean {
return role === 'owner' || project.ownerUserId === userId

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2-1(建议) 这里依赖 ownerUserId 判断项目创建者,但 remote.createProject 仍使用旧的手工映射,没有返回该字段。因此普通成员刚创建项目后打开设置,会看不到设置和清除令牌的操作,直到重新加载或同步项目。建议让 remote.createProject 也使用 projectView(p),同时保留令牌最后更换时间,并补一个成员创建项目后立即管理令牌的测试。

}

return (
<Dialog open={open} onOpenChange={onOpenChange}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2-2(建议) 对话框关闭后组件仍然挂载,因此点击一次「清除令牌」再关闭,重新打开时仍停留在「确认清除?」;这次打开只需点击一次就会删除令牌。未提交的令牌和旧错误也会保留。建议关闭时清空输入、错误及确认状态,让每次打开都重新确认。

Suggested change
<Dialog open={open} onOpenChange={onOpenChange}>
<Dialog open={open} onOpenChange={(next) => {
if (!next) {
setToken('')
setConfirmClear(false)
setError(undefined)
}
onOpenChange(next)
}}>

可直接采纳,也可以不改。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已处理,谢谢。

syncAt: p.syncAt,
syncError: p.syncError,
syncForcePushed: p.syncForcePushed,
syncRunning: p.syncRunning,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2-3(建议) 如果在同步进行中刷新页面,或另一位成员正在同步,这里会保存 syncRunning: true,而 ProjectSyncButton 会据此禁用按钮。当前页面没有接收同步完成事件或刷新项目状态的路径,服务端完成后按钮仍会一直旋转,必须再次刷新页面才能恢复。建议给这种加载状态补充完成对账或显式刷新入口,避免一次性快照永久锁住按钮。

@zhangxinhao zhangxinhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM(14969f8)

@TannyXie 我看了这个 PR,理解它是要保留项目加载后的同步和令牌状态,并在侧栏提供按权限更换、清除仓库令牌的入口;本轮补齐关闭设置时的状态清理。这是第 2 轮,我看了 9353474 之后的改动。本轮增量没有发现新问题,可以合并。上轮 P2-2 和 nit-1 已处理,P2-1、P2-3 仍未处理,本轮不重复提出。

  • ✅ 上轮的 P2-2、nit-1 已处理,谢谢。
  • ⏳ 上轮还没处理的:P2-1、P2-3(仍是建议,不影响合并)。
  • 测试:cd frontend-v2 && npm test -- src/features/chat/page.test.tsx src/features/chat/store.test.ts 通过;没跑全量和 e2e。

涉及鉴权,建议 owner 再看一眼。

以上都是建议,怎么处理由你决定。

自动检视 · 基于 14969f8 · 第 2 轮(增量)

@EricWvi
EricWvi merged commit f456081 into ora-space:main Nov 17, 2026
3 checks passed
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.

3 participants