@@ -32,46 +32,6 @@ local function with_conflict_check(current_session, on_restore)
3232 end
3333end
3434
35- --- Show ACP session picker
36- --- @param sessions agentic.acp.SessionInfo[]
37- --- @param current_session agentic.SessionManager
38- local function show_acp_picker (sessions , current_session )
39- local items = {}
40- for _ , s in ipairs (sessions ) do
41- local date = s .updatedAt and s .updatedAt :sub (1 , 16 ):gsub (" T" , " " )
42- or " unknown date"
43- local title = s .title or " (no title)"
44- table.insert (items , {
45- display = string.format (" %s - %s" , date , title ),
46- session_id = s .sessionId ,
47- title = s .title ,
48- updated_at = date ,
49- })
50- end
51-
52- vim .schedule (function ()
53- vim .ui .select (items , {
54- prompt = " Select session to restore:" ,
55- format_item = function (item )
56- return item .display
57- end ,
58- }, function (choice )
59- if not choice then
60- return
61- end
62-
63- with_conflict_check (current_session , function ()
64- current_session :load_acp_session (
65- choice .session_id ,
66- choice .title ,
67- choice .updated_at
68- )
69- current_session .widget :show ()
70- end )
71- end )
72- end )
73- end
74-
7535--- Show session picker and restore selected session
7636--- @param current_session agentic.SessionManager
7737function SessionRestore .show_picker (current_session )
@@ -93,7 +53,41 @@ function SessionRestore.show_picker(current_session)
9353 return
9454 end
9555
96- show_acp_picker (sessions , current_session )
56+ local items = {}
57+ for _ , s in ipairs (sessions ) do
58+ local date = s .updatedAt
59+ and s .updatedAt :sub (1 , 16 ):gsub (" T" , " " )
60+ or " unknown date"
61+ local title = s .title or " (no title)"
62+ table.insert (items , {
63+ display = string.format (" %s - %s" , date , title ),
64+ session_id = s .sessionId ,
65+ title = s .title ,
66+ updated_at = date ,
67+ })
68+ end
69+
70+ vim .schedule (function ()
71+ vim .ui .select (items , {
72+ prompt = " Select session to restore:" ,
73+ format_item = function (item )
74+ return item .display
75+ end ,
76+ }, function (choice )
77+ if not choice then
78+ return
79+ end
80+
81+ with_conflict_check (current_session , function ()
82+ current_session :load_acp_session (
83+ choice .session_id ,
84+ choice .title ,
85+ choice .updated_at
86+ )
87+ current_session .widget :show ()
88+ end )
89+ end )
90+ end )
9791 end )
9892 end )
9993end
10296--- @param current_session agentic.SessionManager
10397--- @param session_id string
10498function SessionRestore .restore_by_id (current_session , session_id )
105- local cwd = vim .fn .getcwd ()
10699 current_session .agent :when_ready (function ()
107- current_session .agent :list_sessions (cwd , function (result , err )
108- if err or not result then
109- Logger .notify (
110- " Failed to list sessions: "
111- .. (err and err .message or " unknown error" ),
112- vim .log .levels .WARN
113- )
114- return
115- end
116-
117- local match = nil
118- for _ , s in ipairs (result .sessions or {}) do
119- if s .sessionId == session_id then
120- match = s
121- break
122- end
123- end
124-
125- if not match then
126- Logger .notify (
127- " Session not found: " .. session_id ,
128- vim .log .levels .WARN
129- )
130- return
131- end
132-
133- local title = match .title or " (no title)"
134- local date = match .updatedAt
135- and match .updatedAt :sub (1 , 16 ):gsub (" T" , " " )
136- or " unknown date"
137-
138- vim .schedule (function ()
139- with_conflict_check (current_session , function ()
140- current_session :load_acp_session (session_id , title , date )
141- current_session .widget :show ()
142- end )
100+ vim .schedule (function ()
101+ with_conflict_check (current_session , function ()
102+ current_session :load_acp_session (session_id , nil , nil )
103+ current_session .widget :show ()
143104 end )
144105 end )
145106 end )
0 commit comments