From 5e0f4de1625957c6ce057ae272aa301fc459d31b Mon Sep 17 00:00:00 2001
From: Jorge Barnaby <jorge.barnaby@gmail.com>
Date: Wed, 16 Apr 2025 11:41:03 -0400
Subject: feat: Add import support for Tab Session Manager (#1246)

* feat: Add import support for Tab Session Manager

* drop unneeded schema fields

---------

Co-authored-by: Mohamed Bassem <me@mbassem.com>
---
 apps/web/components/settings/ImportExport.tsx | 30 ++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

(limited to 'apps/web/components/settings/ImportExport.tsx')

diff --git a/apps/web/components/settings/ImportExport.tsx b/apps/web/components/settings/ImportExport.tsx
index d6086c97..ab4fb640 100644
--- a/apps/web/components/settings/ImportExport.tsx
+++ b/apps/web/components/settings/ImportExport.tsx
@@ -16,6 +16,7 @@ import {
   parseNetscapeBookmarkFile,
   parseOmnivoreBookmarkFile,
   parsePocketBookmarkFile,
+  parseTabSessionManagerStateFile,
 } from "@/lib/importBookmarkParser";
 import { cn } from "@/lib/utils";
 import { useMutation } from "@tanstack/react-query";
@@ -161,7 +162,13 @@ export function ImportExportRow() {
       source,
     }: {
       file: File;
-      source: "html" | "pocket" | "omnivore" | "hoarder" | "linkwarden";
+      source:
+        | "html"
+        | "pocket"
+        | "omnivore"
+        | "hoarder"
+        | "linkwarden"
+        | "tab-session-manager";
     }) => {
       if (source === "html") {
         return await parseNetscapeBookmarkFile(file);
@@ -173,6 +180,8 @@ export function ImportExportRow() {
         return await parseOmnivoreBookmarkFile(file);
       } else if (source === "linkwarden") {
         return await parseLinkwardenBookmarkFile(file);
+      } else if (source === "tab-session-manager") {
+        return await parseTabSessionManagerStateFile(file);
       } else {
         throw new Error("Unknown source");
       }
@@ -345,6 +354,25 @@ export function ImportExportRow() {
             <p>Import</p>
           </FilePickerButton>
         </ImportCard>
+        <ImportCard
+          text="Tab Session Manager"
+          description={t(
+            "settings.import.import_bookmarks_from_tab_session_manager_export",
+          )}
+        >
+          <FilePickerButton
+            size={"sm"}
+            loading={false}
+            accept=".json"
+            multiple={false}
+            className="flex items-center gap-2"
+            onFileSelect={(file) =>
+              runUploadBookmarkFile({ file, source: "tab-session-manager" })
+            }
+          >
+            <p>Import</p>
+          </FilePickerButton>
+        </ImportCard>
         <ImportCard
           text="Hoarder"
           description={t(
-- 
cgit v1.2.3-70-g09d2

