mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
Merge 912bfd1538
into 3caab85931
This commit is contained in:
commit
3e3a92afc9
1 changed files with 22 additions and 6 deletions
28
aider/gui.py
28
aider/gui.py
|
@ -3,10 +3,12 @@
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
import asyncio
|
||||||
|
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
|
|
||||||
from aider import urls
|
from aider import urls
|
||||||
|
from streamlit.runtime.scriptrunner import add_script_run_ctx
|
||||||
from aider.coders import Coder
|
from aider.coders import Coder
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.io import InputOutput
|
from aider.io import InputOutput
|
||||||
|
@ -185,10 +187,16 @@ class GUI:
|
||||||
self.do_add_web_page()
|
self.do_add_web_page()
|
||||||
|
|
||||||
def do_add_files(self):
|
def do_add_files(self):
|
||||||
|
if 'files_being_added' not in st.session_state:
|
||||||
|
st.session_state.files_being_added = set()
|
||||||
|
|
||||||
|
all_files = self.coder.get_all_relative_files()
|
||||||
|
current_files = self.coder.get_inchat_relative_files()
|
||||||
|
|
||||||
fnames = st.multiselect(
|
fnames = st.multiselect(
|
||||||
"Add files to the chat",
|
"Add files to the chat",
|
||||||
self.coder.get_all_relative_files(),
|
all_files,
|
||||||
default=self.state.initial_inchat_files,
|
default=list(current_files),
|
||||||
placeholder="Files to edit",
|
placeholder="Files to edit",
|
||||||
disabled=self.prompt_pending(),
|
disabled=self.prompt_pending(),
|
||||||
help=(
|
help=(
|
||||||
|
@ -198,15 +206,23 @@ class GUI:
|
||||||
)
|
)
|
||||||
|
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
if fname not in self.coder.get_inchat_relative_files():
|
if fname not in current_files and fname not in st.session_state.files_being_added:
|
||||||
self.coder.add_rel_fname(fname)
|
st.session_state.files_being_added.add(fname)
|
||||||
self.info(f"Added {fname} to the chat")
|
asyncio.run(self.add_file_async(fname))
|
||||||
|
|
||||||
for fname in self.coder.get_inchat_relative_files():
|
for fname in current_files:
|
||||||
if fname not in fnames:
|
if fname not in fnames:
|
||||||
self.coder.drop_rel_fname(fname)
|
self.coder.drop_rel_fname(fname)
|
||||||
self.info(f"Removed {fname} from the chat")
|
self.info(f"Removed {fname} from the chat")
|
||||||
|
|
||||||
|
async def add_file_async(self, fname):
|
||||||
|
try:
|
||||||
|
self.coder.add_rel_fname(fname)
|
||||||
|
self.info(f"Added {fname} to the chat")
|
||||||
|
finally:
|
||||||
|
st.session_state.files_being_added.remove(fname)
|
||||||
|
st.rerun()
|
||||||
|
|
||||||
def do_add_web_page(self):
|
def do_add_web_page(self):
|
||||||
with st.popover("Add a web page to the chat"):
|
with st.popover("Add a web page to the chat"):
|
||||||
self.do_web()
|
self.do_web()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue