Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/app/src/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const dict = {
"command.workspace.toggle.description": "تمكين أو تعطيل مساحات العمل المتعددة في الشريط الجانبي",
"command.session.undo": "تراجع",
"command.session.undo.description": "تراجع عن الرسالة الأخيرة",
"command.session.undo.gitRequired": "لم يتم اكتشاف مستودع Git",
"command.session.redo": "إعادة",
"command.session.redo.description": "إعادة الرسالة التي تم التراجع عنها",
"command.session.compact": "ضغط الجلسة",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const dict = {
"command.workspace.toggle.description": "Habilitar ou desabilitar múltiplos espaços de trabalho na barra lateral",
"command.session.undo": "Desfazer",
"command.session.undo.description": "Desfazer a última mensagem",
"command.session.undo.gitRequired": "Nenhum repositório Git detectado",
"command.session.redo": "Refazer",
"command.session.redo.description": "Refazer a última mensagem desfeita",
"command.session.compact": "Compactar sessão",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/bs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const dict = {
"command.workspace.toggle.description": "Omogući ili onemogući više radnih prostora u bočnoj traci",
"command.session.undo": "Poništi",
"command.session.undo.description": "Poništi posljednju poruku",
"command.session.undo.gitRequired": "Git repozitorij nije otkriven",
"command.session.redo": "Vrati",
"command.session.redo.description": "Vrati posljednju poništenu poruku",
"command.session.compact": "Sažmi sesiju",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const dict = {
"command.workspace.toggle.description": "Aktiver eller deaktiver flere arbejdsområder i sidebjælken",
"command.session.undo": "Fortryd",
"command.session.undo.description": "Fortryd den sidste besked",
"command.session.undo.gitRequired": "Intet Git-repository fundet",
"command.session.redo": "Omgør",
"command.session.redo.description": "Omgør den sidste fortrudte besked",
"command.session.compact": "Komprimér session",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const dict = {
"command.workspace.toggle.description": "Mehrere Arbeitsbereiche in der Seitenleiste aktivieren oder deaktivieren",
"command.session.undo": "Rückgängig",
"command.session.undo.description": "Letzte Nachricht rückgängig machen",
"command.session.undo.gitRequired": "Kein Git-Repository erkannt",
"command.session.redo": "Wiederherstellen",
"command.session.redo.description": "Letzte rückgängig gemachte Nachricht wiederherstellen",
"command.session.compact": "Sitzung komprimieren",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const dict = {
"command.workspace.toggle.description": "Enable or disable multiple workspaces in the sidebar",
"command.session.undo": "Undo",
"command.session.undo.description": "Undo the last message",
"command.session.undo.gitRequired": "No Git repository detected",
"command.session.redo": "Redo",
"command.session.redo.description": "Redo the last undone message",
"command.session.compact": "Compact session",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const dict = {
"command.workspace.toggle.description": "Habilitar o deshabilitar múltiples espacios de trabajo en la barra lateral",
"command.session.undo": "Deshacer",
"command.session.undo.description": "Deshacer el último mensaje",
"command.session.undo.gitRequired": "No se detectó ningún repositorio Git",
"command.session.redo": "Rehacer",
"command.session.redo.description": "Rehacer el último mensaje deshecho",
"command.session.compact": "Compactar sesión",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const dict = {
"command.workspace.toggle.description": "Activer ou désactiver plusieurs espaces de travail dans la barre latérale",
"command.session.undo": "Annuler",
"command.session.undo.description": "Annuler le dernier message",
"command.session.undo.gitRequired": "Aucun dépôt Git détecté",
"command.session.redo": "Rétablir",
"command.session.redo.description": "Rétablir le dernier message annulé",
"command.session.compact": "Compacter la session",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const dict = {
"command.workspace.toggle.description": "サイドバーでの複数のワークスペースの有効化・無効化",
"command.session.undo": "元に戻す",
"command.session.undo.description": "最後のメッセージを元に戻す",
"command.session.undo.gitRequired": "Git リポジトリが検出されませんでした",
"command.session.redo": "やり直す",
"command.session.redo.description": "元に戻したメッセージをやり直す",
"command.session.compact": "セッションを圧縮",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const dict = {
"command.workspace.toggle.description": "사이드바에서 다중 작업 공간 활성화 또는 비활성화",
"command.session.undo": "실행 취소",
"command.session.undo.description": "마지막 메시지 실행 취소",
"command.session.undo.gitRequired": "Git 저장소가 감지되지 않았습니다",
"command.session.redo": "다시 실행",
"command.session.redo.description": "마지막 실행 취소된 메시지 다시 실행",
"command.session.compact": "세션 압축",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/no.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const dict = {
"command.workspace.toggle.description": "Aktiver eller deaktiver flere arbeidsområder i sidefeltet",
"command.session.undo": "Angre",
"command.session.undo.description": "Angre siste melding",
"command.session.undo.gitRequired": "Fant ikke noe Git-repositorium",
"command.session.redo": "Gjør om",
"command.session.redo.description": "Gjør om siste angrede melding",
"command.session.compact": "Komprimer sesjon",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const dict = {
"command.workspace.toggle.description": "Włącz lub wyłącz wiele przestrzeni roboczych na pasku bocznym",
"command.session.undo": "Cofnij",
"command.session.undo.description": "Cofnij ostatnią wiadomość",
"command.session.undo.gitRequired": "Nie wykryto repozytorium Git",
"command.session.redo": "Ponów",
"command.session.redo.description": "Ponów ostatnią cofniętą wiadomość",
"command.session.compact": "Kompaktuj sesję",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const dict = {
"command.workspace.toggle.description": "Включить или отключить несколько рабочих пространств в боковой панели",
"command.session.undo": "Отменить",
"command.session.undo.description": "Отменить последнее сообщение",
"command.session.undo.gitRequired": "Репозиторий Git не обнаружен",
"command.session.redo": "Повторить",
"command.session.redo.description": "Повторить отменённое сообщение",
"command.session.compact": "Сжать сессию",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/th.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const dict = {
"command.workspace.toggle.description": "เปิดหรือปิดใช้งานพื้นที่ทำงานหลายรายการในแถบด้านข้าง",
"command.session.undo": "ยกเลิก",
"command.session.undo.description": "ยกเลิกข้อความล่าสุด",
"command.session.undo.gitRequired": "ไม่พบที่เก็บ Git",
"command.session.redo": "ทำซ้ำ",
"command.session.redo.description": "ทำซ้ำข้อความที่ถูกยกเลิกล่าสุด",
"command.session.compact": "บีบอัดเซสชัน",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const dict = {
"command.workspace.toggle.description": "Kenar çubuğunda birden fazla çalışma alanını göster veya gizle",
"command.session.undo": "Geri al",
"command.session.undo.description": "Son mesajı geri al",
"command.session.undo.gitRequired": "Git deposu algılanmadı",
"command.session.redo": "Yinele",
"command.session.redo.description": "Son geri alınan mesajı yinele",
"command.session.compact": "Oturumu sıkıştır",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const dict = {
"command.workspace.toggle.description": "Увімкнути або вимкнути декілька робочих областей на бічній панелі",
"command.session.undo": "Скасувати",
"command.session.undo.description": "Скасувати останнє повідомлення",
"command.session.undo.gitRequired": "Репозиторій Git не виявлено",
"command.session.redo": "Повторити",
"command.session.redo.description": "Повторити останнє скасоване повідомлення",
"command.session.compact": "Стиснути сесію",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const dict = {

"command.session.undo": "撤销",
"command.session.undo.description": "撤销上一条消息",
"command.session.undo.gitRequired": "未检测到 Git 仓库",
"command.session.redo": "重做",
"command.session.redo.description": "重做上一条撤销的消息",
"command.session.compact": "精简会话",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/zht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const dict = {
"command.workspace.toggle.description": "在側邊欄啟用或停用多個工作區",
"command.session.undo": "復原",
"command.session.undo.description": "復原上一則訊息",
"command.session.undo.gitRequired": "未偵測到 Git 儲存庫",
"command.session.redo": "重做",
"command.session.redo.description": "重做上一則復原的訊息",
"command.session.compact": "精簡工作階段",
Expand Down
20 changes: 16 additions & 4 deletions packages/app/src/pages/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import { TerminalPanel } from "@/pages/session/terminal-panel"
import { TerminalPanelV2 } from "@/pages/session/terminal-panel-v2"
import { useComposerCommands } from "@/pages/session/use-composer-commands"
import { useSessionCommands } from "@/pages/session/use-session-commands"
import { supportsSessionHistory } from "@/pages/session/session-history-actions"
import { useSessionHashScroll } from "@/pages/session/use-session-hash-scroll"
import { Identifier } from "@/utils/id"
import { diffs as list } from "@/utils/diffs"
Expand Down Expand Up @@ -650,6 +651,7 @@ export default function Page() {
}, desktopReviewOpen())

const turnDiffs = createMemo(() => list(lastUserMessage()?.summary?.diffs))
const git = createMemo(() => supportsSessionHistory(sync().project?.vcs))
const nogit = createMemo(() => {
const project = sync().project
return !!project && project.vcs !== "git"
Expand Down Expand Up @@ -1915,12 +1917,12 @@ export default function Page() {
const restoring = createMemo(() => (restoreMutation.isPending ? restoreMutation.variables : undefined))

const revert = (input: { sessionID: string; messageID: string }) => {
if (reverting()) return
if (reverting() || !git()) return
return revertMutation.mutateAsync(input)
}

const restore = (id: string) => {
if (!params.id || reverting()) return
if (!params.id || reverting() || !git()) return
return restoreMutation.mutateAsync(id)
}

Expand Down Expand Up @@ -1955,7 +1957,16 @@ export default function Page() {
download()
}

const actions = { revert, openAttachment }
const actions = {
revert,
get revertDisabled() {
return !git()
},
get revertDisabledReason() {
return nogit() ? language.t("command.session.undo.gitRequired") : undefined
},
openAttachment,
}

createEffect(() => {
const sessionID = params.id
Expand Down Expand Up @@ -2187,7 +2198,8 @@ export default function Page() {
? {
items: rolled(),
restoring: restoring(),
disabled: reverting(),
disabled: reverting() || !git(),
disabledReason: nogit() ? language.t("command.session.undo.gitRequired") : undefined,
onRestore: restore,
}
: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type SessionComposerRevertDock = {
items: { id: string; text: string }[]
restoring?: string
disabled?: boolean
disabledReason?: string
onRestore: (id: string) => void
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function SessionComposerRegion(props: {
items={revert.items}
restoring={revert.restoring}
disabled={revert.disabled}
disabledReason={revert.disabledReason}
onRestore={revert.onRestore}
/>
</div>
Expand All @@ -118,6 +119,7 @@ export function SessionComposerRegion(props: {
items={revert.items}
restoring={revert.restoring}
disabled={revert.disabled}
disabledReason={revert.disabledReason}
onRestore={revert.onRestore}
/>
</div>
Expand Down
43 changes: 25 additions & 18 deletions packages/app/src/pages/session/composer/session-revert-dock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { IconButton } from "@opencode-ai/ui/icon-button"
import { ButtonV2 } from "@opencode-ai/ui/v2/button-v2"
import { Icon as IconV2 } from "@opencode-ai/ui/v2/icon"
import { IconButtonV2 } from "@opencode-ai/ui/v2/icon-button-v2"
import { Tooltip } from "@opencode-ai/ui/tooltip"
import { TooltipV2 } from "@opencode-ai/ui/v2/tooltip-v2"
import { useLanguage } from "@/context/language"
import { useSettings } from "@/context/settings"

export function SessionRevertDock(props: {
items: { id: string; text: string }[]
restoring?: string
disabled?: boolean
disabledReason?: string
onRestore: (id: string) => void
}) {
const language = useLanguage()
Expand Down Expand Up @@ -89,15 +92,17 @@ export function SessionRevertDock(props: {
{(item) => (
<div class="flex items-center gap-2 min-w-0 py-1">
<span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">{item.text}</span>
<Button
size="small"
variant="secondary"
class="shrink-0"
disabled={props.disabled || !!props.restoring}
onClick={() => props.onRestore(item.id)}
>
{language.t("session.revertDock.restore")}
</Button>
<Tooltip inactive={!props.disabledReason} value={props.disabledReason} placement="top">
<Button
size="small"
variant="secondary"
class="shrink-0"
disabled={props.disabled || !!props.restoring}
onClick={() => props.onRestore(item.id)}
>
{language.t("session.revertDock.restore")}
</Button>
</Tooltip>
</div>
)}
</For>
Expand Down Expand Up @@ -167,15 +172,17 @@ export function SessionRevertDock(props: {
<span class="min-w-0 flex-1 truncate text-[13px] font-[400] leading-5 tracking-[-0.04px] text-v2-text-text-muted">
{item.text}
</span>
<ButtonV2
size="small"
variant="neutral"
class="shrink-0"
disabled={props.disabled || !!props.restoring}
onClick={() => props.onRestore(item.id)}
>
{language.t("session.revertDock.restore")}
</ButtonV2>
<TooltipV2 inactive={!props.disabledReason} value={props.disabledReason} placement="top">
<ButtonV2
size="small"
variant="neutral"
class="shrink-0"
disabled={props.disabled || !!props.restoring}
onClick={() => props.onRestore(item.id)}
>
{language.t("session.revertDock.restore")}
</ButtonV2>
</TooltipV2>
</div>
)}
</For>
Expand Down
28 changes: 28 additions & 0 deletions packages/app/src/pages/session/session-history-actions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { describe, expect, test } from "bun:test"
import { commandPaletteOptions } from "@/context/command"
import { sessionHistoryActions } from "./session-history-actions"

describe("sessionHistoryActions", () => {
test("enables session history actions for Git projects", () => {
expect(
sessionHistoryActions({
vcs: "git",
sessionID: "session-1",
hasVisibleUserMessage: true,
hasRevert: true,
}),
).toEqual({ undo: true, redo: true, revert: true })
})

test("disables session history actions for non-Git projects", () => {
const actions = sessionHistoryActions({
vcs: undefined,
sessionID: "session-1",
hasVisibleUserMessage: true,
hasRevert: true,
})

expect(actions).toEqual({ undo: false, redo: false, revert: false })
expect(commandPaletteOptions([{ id: "session.undo", title: "Undo", disabled: !actions.undo }])).toEqual([])
})
})
17 changes: 17 additions & 0 deletions packages/app/src/pages/session/session-history-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function supportsSessionHistory(vcs?: string) {
return vcs === "git"
}

export function sessionHistoryActions(input: {
vcs?: string
sessionID?: string
hasVisibleUserMessage: boolean
hasRevert: boolean
}) {
const git = supportsSessionHistory(input.vcs)
return {
undo: git && !!input.sessionID && input.hasVisibleUserMessage,
redo: git && !!input.sessionID && input.hasRevert,
revert: git,
}
}
Loading
Loading